You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by GitBox <gi...@apache.org> on 2018/09/11 14:45:07 UTC

[GitHub] sdedic commented on a change in pull request #854: [NETBEANS-1197] Avoid ClosedByInterruptException in JarClassLoader

sdedic commented on a change in pull request #854: [NETBEANS-1197] Avoid ClosedByInterruptException in JarClassLoader
URL: https://github.com/apache/incubator-netbeans/pull/854#discussion_r216696741
 
 

 ##########
 File path: platform/o.n.bootstrap/src/org/netbeans/JarClassLoader.java
 ##########
 @@ -893,6 +919,30 @@ protected URL doGetResource(String name) throws MalformedURLException {
                 throw new IOException(ex);
             }
         }
+
+        protected byte[] readClass(String path) throws IOException {
+            /* "FileOutputStream and FileInputStream complicate GC because they both override
+            'finalize()'. Switching to NIO API creates Stream without finalizers and thus relieving
+            GC." However, using NIO means IO operations can fail with a ClosedByInterruptException,
+            for instance if client code starts a new thread which needs to load some new classes,
+            and then interrupts the thread before class loading has finished. See NETBEANS-1197.
+            Note that the old java.io.InterruptedIOException, which could in theory be called even
+            from FileOutputStream/FileInputStream, was seldom seen in practice; see JDK-4385444. */
+            try {
+                return readClassHelper(path, true);
+            } catch (ClosedByInterruptException ex) {
+                LOGGER.log(Level.INFO,
 
 Review comment:
   I would log the event with lower `Level`; the interruption can interfere with class loading at any time for valid reason; no need to alert the user / administrator by logging at INFO.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists