Copilot commented on code in PR #897:
URL: https://github.com/apache/commons-io/pull/897#discussion_r4599455955


##########
src/main/java/org/apache/commons/io/input/ByteBufferCleaner.java:
##########
@@ -113,7 +113,7 @@ private static Cleaner getCleaner() {
             try {
                 return new Java9Cleaner();
             } catch (final Exception e1) {
-                throw new IllegalStateException("Failed to initialize a direct 
ByteBuffer Cleaner.", e);
+                throw new IllegalStateException("Failed to initialize a direct 
ByteBuffer Cleaner.", e1);

Review Comment:
   When `jdk.unsupported` is unresolved on Java 9+, both cleaner constructors 
still fail and eager initialization still throws `ExceptionInInitializerError`. 
This change only corrects the reported cause; it does not add the module-path 
support described in the PR. Add the advertised `jdk.internal.ref.Cleaner` 
fallback while preserving the existing classpath-compatible cleaner path.



##########
pom.xml:
##########
@@ -320,6 +321,35 @@ file comparators, endian transformation classes, and much 
more.
       <properties>
         <maven.compiler.release>8</maven.compiler.release>
       </properties>
+      <build>
+        <plugins>
+          <plugin>
+            <groupId>org.apache.maven.plugins</groupId>
+            <artifactId>maven-surefire-plugin</artifactId>
+            <executions>
+              <execution>
+                <id>default-test-on-classpath</id>
+                <configuration>
+                  <useModulePath>false</useModulePath>
+                  
<reportsDirectory>${project.build.directory}/surefire-reports/classpath</reportsDirectory>
+                </configuration>
+              </execution>
+              <execution>
+                <id>test-on-module-path</id>
+                <phase>test</phase>
+                <goals>
+                  <goal>test</goal>
+                </goals>
+                <configuration>
+                  <useModulePath>true</useModulePath>

Review Comment:
   Without a module descriptor, `useModulePath=true` does not place Commons IO 
on the module path: its automatic module name is only present in the packaged 
JAR, not the compiled classes used here. This execution therefore repeats 
classpath testing and cannot catch the named-module failure targeted by IO-895. 
Add a named-module consumer test against the packaged JAR, with access flags 
targeting `org.apache.commons.io` rather than `ALL-UNNAMED`.



##########
pom.xml:
##########
@@ -320,6 +321,35 @@ file comparators, endian transformation classes, and much 
more.
       <properties>
         <maven.compiler.release>8</maven.compiler.release>
       </properties>
+      <build>
+        <plugins>
+          <plugin>
+            <groupId>org.apache.maven.plugins</groupId>
+            <artifactId>maven-surefire-plugin</artifactId>
+            <executions>
+              <execution>
+                <id>default-test-on-classpath</id>

Review Comment:
   This execution has neither a goal nor a lifecycle binding, and its ID does 
not match Maven's lifecycle-generated default-test execution. Consequently its 
classpath setting and reports directory are never applied to the normal test 
run, which still writes to surefire-reports rather than 
surefire-reports/classpath. Use the default-test ID to configure the existing 
lifecycle execution.



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