-
Notifications
You must be signed in to change notification settings - Fork 38
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
Patch for MoveRefactoring null error fix #309
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. Looks fine to me. 👍
Would you be able to confirm if there are any tests in the netbeans test cases that could cover this NPE flow? Or whether a small test case could be added as part of the upstream PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add any tests around this on NetBeans side?
Hmm I will check for the tests though the change seems almost harmless we are catching an exception which was not being caught where the later is more dangerous . I am not sure of the tests but this NPE is always caught because initially an empty HTML form gets created with none of the fields selected so this always happens by default every time the webview is created . |
Agreed. In this case the method contract is already set to However, it might be better if instead of letting the private static Project getSelectedProject(NamedPath selectedProject) {
String path = selectedProject == null ? null : selectedProject.getPath();
if (path == null) return null;
FileObject file;
try {
file = Utils.fromUri(path);
} catch (MalformedURLException ex) {
file = null;
}
return file == null ? null : FileOwnerQuery.getOwner(file);
}
private static FileObject getSelectedRoot(NamedPath selectedRoot) {
String path = selectedRoot == null ? null : selectedRoot.getPath();
if (path == null) return null;
try {
return Utils.fromUri(path);
} catch (MalformedURLException ex) {
return null;
}
} This would be especially relevant if this is a common scenario like you mentioned, whereby a simple null check outside the try-catch could reduce the slight overhead of setting up the guards. Thoughts? |
a4f1686
to
6d12f01
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @shivam71. Looks ok to me for the interim, until the upstream PR is reviewed and approved. At that point, please update the patch with any changes, as a fresh PR here.
Netbeans PR link #7923