matthiasblaesing commented on PR #6329:
URL: https://github.com/apache/netbeans/pull/6329#issuecomment-1849034436

   This seems to be a minimal hotfix:
   
   ```diff
   diff --git 
a/java/java.file.launcher/src/org/netbeans/modules/java/file/launcher/SharedRootData.java
 
b/java/java.file.launcher/src/org/netbeans/modules/java/file/launcher/SharedRootData.java
   index 9939a96e8152..3c9d9099224a 100644
   --- 
a/java/java.file.launcher/src/org/netbeans/modules/java/file/launcher/SharedRootData.java
   +++ 
b/java/java.file.launcher/src/org/netbeans/modules/java/file/launcher/SharedRootData.java
   @@ -25,6 +25,8 @@ import java.util.HashMap;
    import java.util.List;
    import java.util.Map;
    import java.util.TreeMap;
   +import java.util.logging.Level;
   +import java.util.logging.Logger;
    import java.util.stream.Collectors;
    import org.netbeans.api.annotations.common.CheckForNull;
    import org.netbeans.modules.java.file.launcher.api.SourceLauncher;
   @@ -43,6 +45,8 @@ import org.openide.util.Exceptions;
     */
    public class SharedRootData {
   
   +    private static final Logger LOG = 
Logger.getLogger(SharedRootData.class.getName());
   +
        private static final Map<FileObject, SharedRootData> root2Data = new 
HashMap<>();
   
        public static synchronized void ensureRootRegistered(FileObject root) {
   @@ -104,11 +108,14 @@ public class SharedRootData {
            }
            String joinedCommandLine = 
SourceLauncher.joinCommandLines(options.values());
            try {
   -            if 
(!joinedCommandLine.equals(root.getAttribute(SingleSourceFileUtil.FILE_VM_OPTIONS)))
 {
   +            if (
   +                    !root.getFileSystem().isReadOnly() // Skip read-only 
FSes (like JarFileSystem)
   +                    && 
!joinedCommandLine.equals(root.getAttribute(SingleSourceFileUtil.FILE_VM_OPTIONS))
   +            ) {
                    root.setAttribute(SingleSourceFileUtil.FILE_VM_OPTIONS, 
joinedCommandLine);
                }
            } catch (IOException ex) {
   -            Exceptions.printStackTrace(ex);
   +            LOG.log(Level.INFO, "Failed to set " + 
SingleSourceFileUtil.FILE_VM_OPTIONS + " for " + root.getPath(), ex);
            }
        }
   
   diff --git 
a/java/java.file.launcher/src/org/netbeans/modules/java/file/launcher/queries/MultiSourceRootProvider.java
 
b/java/java.file.launcher/src/org/netbeans/modules/java/file/launcher/queries/MultiSourceRootProvider.java
   index 47a8bad00c02..7f5061d3fac4 100644
   --- 
a/java/java.file.launcher/src/org/netbeans/modules/java/file/launcher/queries/MultiSourceRootProvider.java
   +++ 
b/java/java.file.launcher/src/org/netbeans/modules/java/file/launcher/queries/MultiSourceRootProvider.java
   @@ -92,7 +92,7 @@ public class MultiSourceRootProvider implements 
ClassPathProvider {
            if (DISABLE_MULTI_SOURCE_ROOT) return null;
            synchronized (this) {
                //XXX: what happens if there's a Java file in user's home???
   -            if (file.isData() && "text/x-java".equals(file.getMIMEType())) {
   +            if (file.isValid() && file.isData() && 
"text/x-java".equals(file.getMIMEType())) {
                    return file2SourceCP.computeIfAbsent(file, f -> {
                        try {
                            String content = new String(file.asBytes(), 
FileEncodingQuery.getEncoding(file));
   ```
   
   I think the general problem is `Exceptions.printStackTrace(ex);`. That 
function does more than just logging the problem it also seems to block further 
processing. Switching to a regular logger seems sensible and less intrusive.


-- 
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: notifications-unsubscr...@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


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

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

Reply via email to