Re: [PR] [MRESOLVER-536] Followup change: log failures [maven-resolver]

2024-04-17 Thread via GitHub


cstamas merged PR #471:
URL: https://github.com/apache/maven-resolver/pull/471


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



Re: [PR] [MRESOLVER-536] Followup change: log failures [maven-resolver]

2024-04-16 Thread via GitHub


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


##
maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultPathProcessor.java:
##
@@ -21,22 +21,47 @@
 import javax.inject.Named;
 import javax.inject.Singleton;
 
-import java.io.*;
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
 import java.nio.ByteBuffer;
 import java.nio.charset.StandardCharsets;
+import java.nio.file.AccessDeniedException;
+import java.nio.file.FileSystemException;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.StandardCopyOption;
+import java.nio.file.attribute.FileTime;
 
 import org.eclipse.aether.spi.io.PathProcessor;
 import org.eclipse.aether.util.FileUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * A utility class helping with file-based operations.
  */
 @Singleton
 @Named
 public class DefaultPathProcessor implements PathProcessor {
+private final Logger logger = LoggerFactory.getLogger(getClass());
+
+@Override
+public void setLastModified(Path path, long value) throws IOException {
+try {
+Files.setLastModifiedTime(path, FileTime.fromMillis(value));
+} catch (FileSystemException e) {
+// MRESOLVER-536: Java uses generic FileSystemException for some 
weird cases,
+// but some subclasses like AccessDeniedEx should be re-thrown
+if (e instanceof AccessDeniedException) {
+throw e;
+}
+logger.debug("Failed to set last-modified: {}", path, e);

Review Comment:
   fixed



##
maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultPathProcessor.java:
##
@@ -21,22 +21,47 @@
 import javax.inject.Named;
 import javax.inject.Singleton;
 
-import java.io.*;
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
 import java.nio.ByteBuffer;
 import java.nio.charset.StandardCharsets;
+import java.nio.file.AccessDeniedException;
+import java.nio.file.FileSystemException;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.StandardCopyOption;
+import java.nio.file.attribute.FileTime;
 
 import org.eclipse.aether.spi.io.PathProcessor;
 import org.eclipse.aether.util.FileUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * A utility class helping with file-based operations.
  */
 @Singleton
 @Named
 public class DefaultPathProcessor implements PathProcessor {
+private final Logger logger = LoggerFactory.getLogger(getClass());
+
+@Override
+public void setLastModified(Path path, long value) throws IOException {
+try {
+Files.setLastModifiedTime(path, FileTime.fromMillis(value));
+} catch (FileSystemException e) {
+// MRESOLVER-536: Java uses generic FileSystemException for some 
weird cases,
+// but some subclasses like AccessDeniedEx should be re-thrown
+if (e instanceof AccessDeniedException) {
+throw e;
+}
+logger.debug("Failed to set last-modified: {}", path, e);

Review Comment:
   fixed



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



Re: [PR] [MRESOLVER-536] Followup change: log failures [maven-resolver]

2024-04-16 Thread via GitHub


michael-o commented on code in PR #471:
URL: https://github.com/apache/maven-resolver/pull/471#discussion_r1567201048


##
maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultPathProcessor.java:
##
@@ -21,22 +21,47 @@
 import javax.inject.Named;
 import javax.inject.Singleton;
 
-import java.io.*;
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
 import java.nio.ByteBuffer;
 import java.nio.charset.StandardCharsets;
+import java.nio.file.AccessDeniedException;
+import java.nio.file.FileSystemException;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.StandardCopyOption;
+import java.nio.file.attribute.FileTime;
 
 import org.eclipse.aether.spi.io.PathProcessor;
 import org.eclipse.aether.util.FileUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * A utility class helping with file-based operations.
  */
 @Singleton
 @Named
 public class DefaultPathProcessor implements PathProcessor {
+private final Logger logger = LoggerFactory.getLogger(getClass());
+
+@Override
+public void setLastModified(Path path, long value) throws IOException {
+try {
+Files.setLastModifiedTime(path, FileTime.fromMillis(value));
+} catch (FileSystemException e) {
+// MRESOLVER-536: Java uses generic FileSystemException for some 
weird cases,
+// but some subclasses like AccessDeniedEx should be re-thrown
+if (e instanceof AccessDeniedException) {
+throw e;
+}
+logger.debug("Failed to set last-modified: {}", path, e);

Review Comment:
   `"Failed to set last modified date: {}"`



##
maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultPathProcessor.java:
##
@@ -21,22 +21,47 @@
 import javax.inject.Named;
 import javax.inject.Singleton;
 
-import java.io.*;
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
 import java.nio.ByteBuffer;
 import java.nio.charset.StandardCharsets;
+import java.nio.file.AccessDeniedException;
+import java.nio.file.FileSystemException;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.StandardCopyOption;
+import java.nio.file.attribute.FileTime;
 
 import org.eclipse.aether.spi.io.PathProcessor;
 import org.eclipse.aether.util.FileUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * A utility class helping with file-based operations.
  */
 @Singleton
 @Named
 public class DefaultPathProcessor implements PathProcessor {
+private final Logger logger = LoggerFactory.getLogger(getClass());
+
+@Override
+public void setLastModified(Path path, long value) throws IOException {
+try {
+Files.setLastModifiedTime(path, FileTime.fromMillis(value));
+} catch (FileSystemException e) {
+// MRESOLVER-536: Java uses generic FileSystemException for some 
weird cases,
+// but some subclasses like AccessDeniedEx should be re-thrown
+if (e instanceof AccessDeniedException) {
+throw e;
+}
+logger.debug("Failed to set last-modified: {}", path, e);

Review Comment:
   I think this should be even on trace because it can be very verbose



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



Re: [PR] [MRESOLVER-536] Followup change: log failures [maven-resolver]

2024-04-16 Thread via GitHub


cstamas commented on PR #471:
URL: https://github.com/apache/maven-resolver/pull/471#issuecomment-2058654143

   ping @Jurrie


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