Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NPE after removal of gradle cache #289

Closed
mklaehn opened this Issue Sep 17, 2016 · 3 comments

Comments

Projects
None yet
2 participants
@mklaehn
Copy link

commented Sep 17, 2016

after killing the cradle cache (by deleting it from disk) the following NPE was raised during a build process.

Javadoc for listFiles declares the return value null a possibility in case of I/O Error or the file used for listing is not a directory

java.lang.NullPointerException
at org.netbeans.gradle.project.util.NbFileUtils.getFileFromASubDir(NbFileUtils.java:204)
at org.netbeans.gradle.project.query.GradleCacheByBinaryLookup$NewFormatCacheResult.getRoots(GradleCacheByBinaryLookup.java:135)
at org.netbeans.modules.java.editor.overridden.ComputeOverriders.findBinaryRootsForSourceRoot(ComputeOverriders.java:163)
at org.netbeans.modules.java.editor.overridden.ComputeOverriders.reverseSourceRootsInOrder(ComputeOverriders.java:331)
at org.netbeans.modules.java.editor.overridden.ComputeOverriders.computeUsers(ComputeOverriders.java:383)
at org.netbeans.modules.java.editor.overridden.ComputeOverriders.processImpl(ComputeOverriders.java:226)
at org.netbeans.modules.java.editor.overridden.ComputeOverriders.process(ComputeOverriders.java:177)
at org.netbeans.modules.java.editor.overridden.ComputeAnnotations.computeAnnotations(ComputeAnnotations.java:127)
at org.netbeans.modules.java.editor.overridden.ComputeAnnotations.run(ComputeAnnotations.java:108)
at org.netbeans.modules.parsing.impl.TaskProcessor.callParserResultTask(TaskProcessor.java:584)
[catch] at org.netbeans.modules.parsing.impl.TaskProcessor$RequestPerformer.run(TaskProcessor.java:809)
at org.openide.util.lookup.Lookups.executeWith(Lookups.java:304)
at org.netbeans.modules.parsing.impl.TaskProcessor$RequestPerformer.execute(TaskProcessor.java:725)
at org.netbeans.modules.parsing.impl.TaskProcessor$CompilationJob.run(TaskProcessor.java:686)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1443)
at org.netbeans.modules.openide.util.GlobalLookup.execute(GlobalLookup.java:68)
at org.openide.util.lookup.Lookups.executeWith(Lookups.java:303)
at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2058)

mklaehn added a commit to mklaehn/netbeans-gradle-project that referenced this issue Sep 17, 2016

@mklaehn mklaehn changed the title NPE after removal of grade cache NPE after removal of gradle cache Sep 17, 2016

@kelemen kelemen closed this in 0bd1a45 Sep 17, 2016

@kelemen

This comment has been minimized.

Copy link
Owner

commented Sep 17, 2016

Thanks, this should be fixed in master. Though, I would assume that after restarting NB you would not be able to reproduce the issue anyway because before listFiles, I (implicitly) check for the existance of the directory.

@mklaehn

This comment has been minimized.

Copy link
Author

commented Sep 17, 2016

You are right, a Netbeans restart fixed this problem but while these NPEs popped up they were a inconvenience.
BTW I did check other usages of File.listFiles(FileFilter) and they did seem okay in that they were called only when the File was a directory.

@kelemen

This comment has been minimized.

Copy link
Owner

commented Sep 17, 2016

I should have done that too. Reviewed my usages of File.listFiles and fixed the places where null checks were missing. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.