From 399f15882775c165cc4c3194484006089fe7eeb3 Mon Sep 17 00:00:00 2001 From: Laurent Petit Date: Mon, 15 Oct 2012 18:51:58 +0200 Subject: [PATCH] Get rid of potential NullPointerException when source attachment not found --- ccw.core/src/java/ccw/ClojureCore.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ccw.core/src/java/ccw/ClojureCore.java b/ccw.core/src/java/ccw/ClojureCore.java index e8dd59d2..c9fe41b6 100644 --- a/ccw.core/src/java/ccw/ClojureCore.java +++ b/ccw.core/src/java/ccw/ClojureCore.java @@ -320,7 +320,11 @@ private static IEditorInput findEditorInputInSourceAttachment( // Find outside workspace or in archive final IPath sourceAbsolutePath = toOSAbsoluteIPath(sourceAttachmentPath); - if (sourceAbsolutePath.toFile().isDirectory()) { + final File sourceFile = sourceAbsolutePath.toFile(); + if (!sourceFile.exists()) { + CCWPlugin.logWarning("sourceFile " + sourceFile + " does not exist form sourceAttachmentPath " + sourceAttachmentPath); + // Nothing can be done + } else if (sourceFile.isDirectory()) { final File maybeSourceFile = sourceAbsolutePath.append(searchedPath + "/" + searchedFileName).toFile(); if (maybeSourceFile.exists()) { return new LocalFileStorageEditorInput( @@ -331,7 +335,7 @@ private static IEditorInput findEditorInputInSourceAttachment( } else { ZipFile zipFile; try { - zipFile = new JarFile(sourceAbsolutePath.toFile(), true, JarFile.OPEN_READ); + zipFile = new JarFile(sourceFile, true, JarFile.OPEN_READ); ZipEntry zipEntry = zipFile.getEntry(searchedPath + "/" + searchedFileName); if (zipEntry != null) { return new ZipEntryStorageEditorInput(