Bug 551542 - Avoid handling of NullPointerException

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>
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 475fb97..1d1cf74 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 @@
 				IResource[] resources= Utilities.getResources(fTreeViewer.getSelection());
 				IResource patchFile= resources[0];
 				if (patchFile != null) {
-					try {
-						reader= new FileReader(patchFile.getLocation().toFile());
-					} catch (FileNotFoundException ex) {
+					if (patchFile.getLocation() == null) {
 						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)
-						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 @@
 		// 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 @@
 					}
 				} catch (FileNotFoundException ex) {
 					// silently ignored
-				} catch (NullPointerException nex) {
-					// silently ignored
 				}
-
 			} finally {
 				if (reader != null) {
 					try {