Skip to content

Commit

Permalink
Patch Update Move Refactoring Null Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
shivam71 committed Nov 4, 2024
1 parent 1814a3e commit aa8e6ab
Showing 1 changed file with 27 additions and 13 deletions.
40 changes: 27 additions & 13 deletions patches/7923_draft.diff
Original file line number Diff line number Diff line change
@@ -1,22 +1,36 @@
diff --git a/java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/refactoring/MoveRefactoring.java b/java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/refactoring/MoveRefactoring.java
index a72abd44ef..199ffad108 100644
index a72abd44ef..72e8bd68ec 100644
--- a/java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/refactoring/MoveRefactoring.java
+++ b/java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/refactoring/MoveRefactoring.java
@@ -423,7 +423,7 @@ public final class MoveRefactoring extends CodeRefactoring {
@@ -420,18 +420,26 @@ public final class MoveRefactoring extends CodeRefactoring {
}

private static Project getSelectedProject(NamedPath selectedProject) {
+ String path = selectedProject == null ? null : selectedProject.getPath();
+ if (path == null) {
+ return null;
+ }
+ FileObject file;
try {
String path = selectedProject.getPath();
return path != null ? FileOwnerQuery.getOwner(Utils.fromUri(path)) : null;
- } catch (MalformedURLException ex) {
+ } catch (MalformedURLException | NullPointerException ex) {
return null;
- String path = selectedProject.getPath();
- return path != null ? FileOwnerQuery.getOwner(Utils.fromUri(path)) : null;
+ file = Utils.fromUri(path);
} catch (MalformedURLException ex) {
- return null;
+ file = null;
}
+ return file == null ? null : FileOwnerQuery.getOwner(file);
}
@@ -432,7 +432,7 @@ public final class MoveRefactoring extends CodeRefactoring {

private static FileObject getSelectedRoot(NamedPath selectedRoot) {
+ String path = selectedRoot == null ? null : selectedRoot.getPath();
+ if (path == null) {
+ return null;
+ }
try {
String path = selectedRoot.getPath();
return path != null ? Utils.fromUri(path) : null;
- } catch (MalformedURLException ex) {
+ } catch (MalformedURLException | NullPointerException ex) {
- String path = selectedRoot.getPath();
- return path != null ? Utils.fromUri(path) : null;
+ return Utils.fromUri(path);
} catch (MalformedURLException ex) {
return null;
}
}

0 comments on commit aa8e6ab

Please sign in to comment.