Skip to content

Commit

Permalink
[Tooling] Guard against null pointer while deleting src-gen
Browse files Browse the repository at this point in the history
The now used findMember method will return null if the resource does not
exist (and, thus, does not have to be deleted anyway).
Furthermore, it will return the container itself if the path is empty.
Hence, the if statement is not needed.
  • Loading branch information
sacnl committed May 16, 2013
1 parent 4e57ff4 commit 4c98d04
Showing 1 changed file with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,9 @@ public void deleteDirectory(String directoryName, String outputConfiguration) {
try {
directoryName = directoryName.replaceAll("^/", "");
IContainer folder = getContainer(outputConfig);
IResource toDelete = folder;
if(!directoryName.isEmpty()) {
toDelete = folder.findMember(directoryName);
}
toDelete.delete(IResource.KEEP_HISTORY, getMonitor());
IResource toDelete = folder.findMember(directoryName);
if(toDelete != null)
toDelete.delete(IResource.KEEP_HISTORY, getMonitor());
} catch (CoreException e) {
throw new RuntimeException(e);
}
Expand Down

0 comments on commit 4c98d04

Please sign in to comment.