This is an automated email from the ASF dual-hosted git repository.
matthiasblaesing pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/netbeans.git
The following commit(s) were added to refs/heads/master by this push:
new 0f346ba27b Fix errors from java multi-file source launcher
new ac3936a4bd Merge pull request #6832 from
matthiasblaesing/fix_multifile_launcher2
0f346ba27b is described below
commit 0f346ba27bd5eacf17a7f169d343e42304ed57ed
Author: Matthias Bläsing <[email protected]>
AuthorDate: Sun Dec 10 18:05:16 2023 +0100
Fix errors from java multi-file source launcher
- Guard against problem writing VM attributes
(check if filesystem is writeable and reduce log severity to info=
- Check FileObject for validity before trying to read from it
---
.../netbeans/modules/java/file/launcher/SharedRootData.java | 11 +++++++++--
.../java/file/launcher/queries/MultiSourceRootProvider.java | 2 +-
2 files changed, 10 insertions(+), 3 deletions(-)
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 9939a96e81..3c9d909922 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 47a8bad00c..7f5061d3fa 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));
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists