Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarsten Thoms2019-09-26 17:31:25 -0400
committerKarsten Thoms2019-09-26 17:31:25 -0400
commit17002c7e175bd394dd73c7f9e8680e2228a4d2b9 (patch)
tree6e54e9d47e121f31e5dfe78d36cedf552f97d030
parent41004c3736c509f6d2a2c0f90bca66126054c21f (diff)
downloadeclipse.platform.team-I20191003-1800.tar.gz
eclipse.platform.team-I20191003-1800.tar.xz
eclipse.platform.team-I20191003-1800.zip
Check IResource#getLocation() for null result instead of handling this situation by catching NPEs. Change-Id: I262a7b50d055d9dd83dbf736d413a2d6c66e1063 Signed-off-by: Karsten Thoms <karsten.thoms@itemis.de>
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/InputPatchPage.java19
1 files changed, 9 insertions, 10 deletions
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/InputPatchPage.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/InputPatchPage.java
index 475fb97e6..1d1cf7442 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/InputPatchPage.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/InputPatchPage.java
@@ -293,13 +293,15 @@ public class InputPatchPage extends WizardPage {
IResource[] resources= Utilities.getResources(fTreeViewer.getSelection());
IResource patchFile= resources[0];
if (patchFile != null) {
- try {
- reader= new FileReader(patchFile.getLocation().toFile());
- } catch (FileNotFoundException ex) {
- MessageDialog.openError(null, PatchMessages.InputPatchPage_PatchErrorDialog_title, PatchMessages.InputPatchPage_PatchFileNotFound_message);
- } catch (NullPointerException nex) {
- //in case the path doesn't exist (eg. getLocation() returned null)
+ if (patchFile.getLocation() == null) {
MessageDialog.openError(null, PatchMessages.InputPatchPage_PatchErrorDialog_title, PatchMessages.InputPatchPage_PatchFileNotFound_message);
+ } else {
+ try {
+ reader = new FileReader(patchFile.getLocation().toFile());
+ } catch (FileNotFoundException ex) {
+ MessageDialog.openError(null, PatchMessages.InputPatchPage_PatchErrorDialog_title,
+ PatchMessages.InputPatchPage_PatchFileNotFound_message);
+ }
}
}
fPatchSource= PatchMessages.InputPatchPage_WorkspacePatch_title;
@@ -838,7 +840,7 @@ public class InputPatchPage extends WizardPage {
// readjust selection if there is a patch selected in the workspace or on the clipboard
// check workspace first
IResource patchTarget= fPatchWizard.getTarget();
- if (patchTarget instanceof IFile) {
+ if (patchTarget instanceof IFile && patchTarget.getLocation() != null) {
Reader reader= null;
try {
try {
@@ -854,10 +856,7 @@ public class InputPatchPage extends WizardPage {
}
} catch (FileNotFoundException ex) {
// silently ignored
- } catch (NullPointerException nex) {
- // silently ignored
}
-
} finally {
if (reader != null) {
try {

Back to the top