Skip to content

Commit

Permalink
AbstractScriptGenerator.newAntScript: revert close Stream #967
Browse files Browse the repository at this point in the history
  • Loading branch information
EcljpseB0T authored and iloveeclipse committed Dec 5, 2023
1 parent bd726ff commit a633bfb
Showing 1 changed file with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,21 @@ public void openScript(String scriptLocation, String scriptName) throws CoreExce
}

protected static AntScript newAntScript(String scriptLocation, String scriptName) throws CoreException {
try (OutputStream scriptStream = new BufferedOutputStream(new FileOutputStream(scriptLocation + '/' + scriptName))) {
return new AntScript(scriptStream);
} catch (IOException e) {
try {
@SuppressWarnings("resource") // intentional return AntScript without closed stream
OutputStream scriptStream = new BufferedOutputStream(new FileOutputStream(scriptLocation + '/' + scriptName));
try {
return new AntScript(scriptStream);
} catch (IOException e) {
try {
scriptStream.close();
} catch (IOException e1) {
e.addSuppressed(e1);
}
String message = NLS.bind(Messages.exception_writingFile, scriptLocation + '/' + scriptName);
throw new CoreException(new Status(IStatus.ERROR, PI_PDEBUILD, EXCEPTION_WRITING_FILE, message, e));
}
} catch (FileNotFoundException e) {
String message = NLS.bind(Messages.exception_writingFile, scriptLocation + '/' + scriptName);
throw new CoreException(new Status(IStatus.ERROR, PI_PDEBUILD, EXCEPTION_WRITING_FILE, message, e));
}
Expand Down

0 comments on commit a633bfb

Please sign in to comment.