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


##########
maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultTrackingFileManager.java:
##########
@@ -87,64 +87,71 @@ public Properties update(File file, Map<String, String> 
updates) {
 
     @Override
     public Properties update(Path path, Map<String, String> updates) {
-        Properties props = new Properties();
         try {
             Files.createDirectories(path.getParent());
         } catch (IOException e) {
             LOGGER.warn("Failed to create tracking file parent '{}'", path, e);
             throw new UncheckedIOException(e);
         }
-
-        synchronized (getMutex(path)) {
-            try {
-                long fileSize;
-                try {
-                    fileSize = Files.size(path);
-                } catch (IOException e) {
-                    fileSize = 0L;
+        Properties props = new Properties();
+        synchronized (mutex(path)) {
+            try (FileChannel fileChannel = FileChannel.open(
+                            path, StandardOpenOption.READ, 
StandardOpenOption.WRITE, StandardOpenOption.CREATE);
+                    FileLock unused = fileLock(fileChannel, Math.max(1, 
fileChannel.size()), false)) {
+                if (fileChannel.size() > 0) {

Review Comment:
   Reading will be unable to open absent file, here we may create it (and will 
be 0 byte)



-- 
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: [email protected]

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

Reply via email to