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 committed Dec 5, 2023
1 parent bd726ff commit 4d87175
Showing 1 changed file with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -252,12 +252,26 @@ 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) {
AntScript result = null;
try {
@SuppressWarnings("resource") // intentional return a AntScript without closed stream
OutputStream scriptStream = new BufferedOutputStream(new FileOutputStream(scriptLocation + '/' + scriptName));
try {
result = new AntScript(scriptStream);
} catch (IOException e) {
try {
scriptStream.close();
String message = NLS.bind(Messages.exception_writingFile, scriptLocation + '/' + scriptName);
throw new CoreException(new Status(IStatus.ERROR, PI_PDEBUILD, EXCEPTION_WRITING_FILE, message, e));
} catch (IOException e1) {
// Ignored
}
}
} 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));
}
return result;
}

public void closeScript() {
Expand Down

0 comments on commit 4d87175

Please sign in to comment.