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

Patch for MoveRefactoring null error fix #309

Merged
merged 1 commit into from
Oct 30, 2024

Conversation

shivam71
Copy link
Member

  • The MoveRefactoring with the default visibility option as "Escalate" was not working .
  • The issue seems to be from an uncaught null pointer exception arising somewhere else .
  • It got fixed by minimal changes on NB .
    Netbeans PR link #7923

@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Oct 29, 2024
Copy link
Member

@sid-srini sid-srini left a 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?

Copy link
Member

@Achal1607 Achal1607 left a 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?

@shivam71
Copy link
Member Author

shivam71 commented Oct 29, 2024

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 .

@sid-srini
Copy link
Member

sid-srini commented Oct 29, 2024

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.

Agreed. In this case the method contract is already set to return null in case of a bad URI.

However, it might be better if instead of letting the NullPointerException be thrown, we could test the method argument for null.

        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?

@sid-srini sid-srini added this to the JVSC 23.0.1 milestone Oct 30, 2024
@shivam71 shivam71 force-pushed the MoveRefactoring_Fix_1 branch from a4f1686 to 6d12f01 Compare October 30, 2024 06:42
Copy link
Member

@sid-srini sid-srini left a 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.

@sid-srini sid-srini merged commit 2141e42 into oracle:main Oct 30, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OCA Verified All contributors have signed the Oracle Contributor Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants