elharo commented on a change in pull request #66:
URL: https://github.com/apache/maven-resolver/pull/66#discussion_r471165555



##########
File path: maven-resolver-synccontext-global/pom.xml
##########
@@ -0,0 +1,91 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.maven.resolver</groupId>
+    <artifactId>maven-resolver</artifactId>
+    <version>1.5.1-SNAPSHOT</version>
+  </parent>
+
+  <artifactId>maven-resolver-synccontext-global</artifactId>
+
+  <name>Maven Artifact Resolver Sync Context Global</name>
+  <description>
+      A synchronization context implementation using a global lock.
+  </description>
+
+  <properties>
+    <javaVersion>8</javaVersion>
+    
<Automatic-Module-Name>org.apache.maven.resolver.synccontext.global</Automatic-Module-Name>
+    <Bundle-SymbolicName>${Automatic-Module-Name}</Bundle-SymbolicName>
+  </properties>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.maven.resolver</groupId>
+      <artifactId>maven-resolver-api</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven.resolver</groupId>
+      <artifactId>maven-resolver-impl</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>javax.inject</groupId>
+      <artifactId>javax.inject</artifactId>
+      <scope>provided</scope>

Review comment:
       Where is this provided from? Or are you using this as compile only?

##########
File path: 
maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultSyncContextFactory.java
##########
@@ -30,59 +28,31 @@
 import org.eclipse.aether.artifact.Artifact;
 import org.eclipse.aether.impl.SyncContextFactory;
 import org.eclipse.aether.metadata.Metadata;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.inject.Singleton;
 
 /**
- * A factory to create synchronization contexts. This default implementation 
uses fair global locking
- * based on {@link ReentrantReadWriteLock}. Explicit artifacts and metadata 
passed are ignored.
+ * A factory to create synchronization contexts. This default implementation 
actually does not provide any real

Review comment:
       delete "actually"

##########
File path: 
maven-resolver-synccontext-global/src/main/java/org/eclipse/aether/internal/impl/TrackingFileManager.java
##########
@@ -0,0 +1,151 @@
+package org.eclipse.aether.internal.impl;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.eclipse.aether.SyncContext;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.Closeable;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.RandomAccessFile;
+import java.util.Map;
+import java.util.Properties;
+
+/**
+ * Manages access to a properties file. This override drops internal 
synchronization becauses it
+ * relies on external synchronization provided by outer {@link SyncContext} 
instances.
+ */
+class TrackingFileManager
+{
+
+    private static final Logger LOGGER = LoggerFactory.getLogger( 
TrackingFileManager.class );
+
+    public Properties read( File file )
+    {
+        FileInputStream stream = null;
+        try

Review comment:
       I think you can use try with resources here

##########
File path: 
maven-resolver-synccontext-global/src/main/java/org/eclipse/aether/internal/impl/TrackingFileManager.java
##########
@@ -0,0 +1,151 @@
+package org.eclipse.aether.internal.impl;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.eclipse.aether.SyncContext;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.Closeable;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.RandomAccessFile;
+import java.util.Map;
+import java.util.Properties;
+
+/**
+ * Manages access to a properties file. This override drops internal 
synchronization becauses it
+ * relies on external synchronization provided by outer {@link SyncContext} 
instances.
+ */
+class TrackingFileManager
+{
+
+    private static final Logger LOGGER = LoggerFactory.getLogger( 
TrackingFileManager.class );
+
+    public Properties read( File file )
+    {
+        FileInputStream stream = null;
+        try
+        {
+            if ( !file.exists() )
+            {
+                return null;
+            }
+
+            stream = new FileInputStream( file );
+
+            Properties props = new Properties();
+            props.load( stream );
+
+            return props;
+        }
+        catch ( IOException e )
+        {
+            LOGGER.warn( "Failed to read tracking file {}", file, e );
+        }
+        finally
+        {
+            close( stream, file );
+        }
+
+        return null;
+    }
+
+    public Properties update( File file, Map<String, String> updates )
+    {
+        Properties props = new Properties();
+
+        File directory = file.getParentFile();
+        if ( !directory.mkdirs() && !directory.exists() )
+        {
+            LOGGER.warn( "Failed to create parent directories for tracking 
file {}", file );
+            return props;
+        }
+
+        RandomAccessFile raf = null;
+        try
+        {
+            raf = new RandomAccessFile( file, "rw" );
+
+            if ( file.canRead() )
+            {
+                byte[] buffer = new byte[(int) raf.length()];
+
+                raf.readFully( buffer );

Review comment:
       Files.readAllBytes?

##########
File path: 
maven-resolver-synccontext-global/src/main/java/org/eclipse/aether/internal/impl/TrackingFileManager.java
##########
@@ -0,0 +1,151 @@
+package org.eclipse.aether.internal.impl;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.eclipse.aether.SyncContext;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.Closeable;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.RandomAccessFile;
+import java.util.Map;
+import java.util.Properties;
+
+/**
+ * Manages access to a properties file. This override drops internal 
synchronization becauses it
+ * relies on external synchronization provided by outer {@link SyncContext} 
instances.
+ */
+class TrackingFileManager
+{
+
+    private static final Logger LOGGER = LoggerFactory.getLogger( 
TrackingFileManager.class );
+
+    public Properties read( File file )

Review comment:
       no need for public methods in non-public class

##########
File path: 
maven-resolver-synccontext-global/src/main/java/org/eclipse/aether/internal/impl/TrackingFileManager.java
##########
@@ -0,0 +1,151 @@
+package org.eclipse.aether.internal.impl;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.eclipse.aether.SyncContext;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.Closeable;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.RandomAccessFile;
+import java.util.Map;
+import java.util.Properties;
+
+/**
+ * Manages access to a properties file. This override drops internal 
synchronization becauses it
+ * relies on external synchronization provided by outer {@link SyncContext} 
instances.
+ */
+class TrackingFileManager
+{
+
+    private static final Logger LOGGER = LoggerFactory.getLogger( 
TrackingFileManager.class );
+
+    public Properties read( File file )
+    {
+        FileInputStream stream = null;
+        try
+        {
+            if ( !file.exists() )
+            {
+                return null;
+            }
+
+            stream = new FileInputStream( file );
+
+            Properties props = new Properties();
+            props.load( stream );
+
+            return props;
+        }
+        catch ( IOException e )
+        {
+            LOGGER.warn( "Failed to read tracking file {}", file, e );
+        }
+        finally
+        {
+            close( stream, file );
+        }
+
+        return null;
+    }
+
+    public Properties update( File file, Map<String, String> updates )
+    {
+        Properties props = new Properties();
+
+        File directory = file.getParentFile();
+        if ( !directory.mkdirs() && !directory.exists() )
+        {
+            LOGGER.warn( "Failed to create parent directories for tracking 
file {}", file );
+            return props;
+        }
+
+        RandomAccessFile raf = null;

Review comment:
       try with resources?




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to