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/04/25 05:09:38 UTC

[GitHub] jlahoda closed pull request #510: [NETBEANS-654] Ignoring InvalidFileException while constructing the J…

jlahoda closed pull request #510: [NETBEANS-654] Ignoring InvalidFileException while constructing the J…
URL: https://github.com/apache/incubator-netbeans/pull/510
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/java.source.base/src/org/netbeans/modules/java/source/parsing/JavacParser.java b/java.source.base/src/org/netbeans/modules/java/source/parsing/JavacParser.java
index 78dc9c17b..3aa15da75 100644
--- a/java.source.base/src/org/netbeans/modules/java/source/parsing/JavacParser.java
+++ b/java.source.base/src/org/netbeans/modules/java/source/parsing/JavacParser.java
@@ -727,9 +727,15 @@ static JavacTaskImpl createJavacTask(
             }
             AbstractSourceFileObject source = null;
             if (file != null) {
-                source = FileObjects.sourceFileObject(file, root);
-                if (source.getKind() != Kind.SOURCE) {
-                    source = null;
+                try {
+                    source = FileObjects.sourceFileObject(file, root, null, false);
+                    if (source.getKind() != Kind.SOURCE) {
+                        source = null;
+                    }
+                } catch (FileObjects.InvalidFileException ife) {
+                    //ignore, it will be handled again later, see #parse.
+                } catch (IOException ex) {
+                    throw new IllegalStateException(ex);
                 }
             }
             final JavacTaskImpl javacTask = createJavacTask(cpInfo,
diff --git a/java.source.base/test/unit/src/org/netbeans/modules/java/source/parsing/JavacParserTest.java b/java.source.base/test/unit/src/org/netbeans/modules/java/source/parsing/JavacParserTest.java
index b2acdc890..2f9b75bf7 100644
--- a/java.source.base/test/unit/src/org/netbeans/modules/java/source/parsing/JavacParserTest.java
+++ b/java.source.base/test/unit/src/org/netbeans/modules/java/source/parsing/JavacParserTest.java
@@ -315,6 +315,19 @@ public Void scan(Tree tree, long[] parentSpan) {
         }, true);
     }
     
+    public void testInvalidFile654() throws Exception {
+        FileObject f = createFile("test/Test.java", "package test; class Test { }");
+        JavaSource js = JavaSource.forFileObject(f);
+
+
+        js.runUserActionTask(new Task<CompilationController>() {
+            public void run(CompilationController parameter) throws Exception {
+                f.delete();
+                assertTrue(Phase.RESOLVED.compareTo(parameter.toPhase(Phase.RESOLVED)) <= 0);
+            }
+        }, true);
+    }
+
     public void testIfMissingObjectOnBootCPUseCPToGuessSourceLevel() throws Exception {
         Source ret = guessSourceLevel(false, false, false);
         assertEquals("Downgraded to 1.4", Source.JDK1_4, ret);


 

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