cstamas commented on code in PR #194:
URL: https://github.com/apache/maven-resolver/pull/194#discussion_r979380066


##########
maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/synccontext/named/FileGAVNameMapper.java:
##########
@@ -19,100 +19,32 @@
  * under the License.
  */
 
-import org.eclipse.aether.RepositorySystemSession;
 import org.eclipse.aether.artifact.Artifact;
 import org.eclipse.aether.metadata.Metadata;
-import org.eclipse.aether.named.support.FileSystemFriendly;
-
-import javax.inject.Named;
-import javax.inject.Singleton;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.UncheckedIOException;
-import java.nio.file.Path;
-import java.util.Collection;
-import java.util.TreeSet;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
 
 /**
- * A {@link NameMapper} that creates same name mapping as Takari Local 
Repository does, with
- * {@code baseDir} (local repo). Part of code blatantly copies parts of the 
Takari
- * {@code LockingSyncContext}.
- *
- * @see <a 
href="https://github.com/takari/takari-local-repository/blob/24133e50a0478dccb5620ac2f2255187608f165b/src/main/java/io/takari/aether/concurrency/LockingSyncContext.java";>Takari
- * LockingSyncContext.java</a>
+ * A file system friendly {@link NameMapper} that creates lock names out of 
GAV that are file system friendly. The names
+ * (when considered as file names) are relative, but are unique to {@link 
Artifact} and {@link Metadata} GAV
+ * coordinates.
  */
-@Singleton
-@Named( FileGAVNameMapper.NAME )
-public class FileGAVNameMapper
-    implements NameMapper, FileSystemFriendly
+public class FileGAVNameMapper extends NameMapperSupport implements 
FileSystemFriendlyNameMapper
 {
-    public static final String NAME = "file-gav";
+    private static final String SEPARATOR = "~";
 
     private static final String LOCK_SUFFIX = ".resolverlock";
 
-    private static final char SEPARATOR = '~';
-
-    private final ConcurrentMap<String, Path> baseDirs;
-
-    public FileGAVNameMapper()
-    {
-        this.baseDirs = new ConcurrentHashMap<>();
-    }
-
     @Override
-    public TreeSet<String> nameLocks( final RepositorySystemSession session,
-                                      final Collection<? extends Artifact> 
artifacts,
-                                      final Collection<? extends Metadata> 
metadatas )
+    protected String getArtifactName( Artifact artifact )
     {
-        File localRepositoryBasedir = 
session.getLocalRepository().getBasedir();
-        // here we abuse concurrent hash map to make sure costly 
getCanonicalFile is invoked only once
-        Path baseDir = baseDirs.computeIfAbsent(
-            localRepositoryBasedir.getPath(), k ->
-            {
-                try
-                {
-                    return new File( localRepositoryBasedir, ".locks" 
).getCanonicalFile().toPath();
-                }
-                catch ( IOException e )
-                {
-                    throw new UncheckedIOException( e );
-                }
-            }
-        );
-
-        TreeSet<String> paths = new TreeSet<>();
-        if ( artifacts != null )
-        {
-            for ( Artifact artifact : artifacts )
-            {
-                paths.add( getPath( baseDir, artifact ) + LOCK_SUFFIX );
-            }
-        }
-        if ( metadatas != null )
-        {
-            for ( Metadata metadata : metadatas )
-            {
-                paths.add( getPath( baseDir, metadata ) + LOCK_SUFFIX );
-            }
-        }
-        return paths;
-    }
-
-    private String getPath( final Path baseDir, final Artifact artifact )
-    {
-        // NOTE: Don't use LRM.getPath*() as those paths could be different 
across processes, e.g. due to staging LRMs.
-        String path = artifact.getGroupId()
-            + SEPARATOR + artifact.getArtifactId()
-            + SEPARATOR + artifact.getBaseVersion();
-        return baseDir.resolve( path ).toAbsolutePath().toString();
+        return artifact.getGroupId()
+                + SEPARATOR + artifact.getArtifactId()
+                + SEPARATOR + artifact.getBaseVersion()
+                + LOCK_SUFFIX;
     }

Review Comment:
   Not anymore (original class was basedir + filegav, now is only filegav) -- 
look at providers, this "config" now became basedir(filegav). But exactly due 
providers, this change does not affects existing config.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@maven.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to