bug 60153: findbugs OBL_UNSATISFIED_OBLIGATION_EXCEPTION_EDGE close opened streams if an exception is raised while decorating the stream
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1763959 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
45d18d5c45
commit
63da9f8d19
@ -92,8 +92,16 @@ public class SheetDataWriter {
|
||||
* @param fd the file to write to
|
||||
*/
|
||||
public Writer createWriter(File fd) throws IOException {
|
||||
final OutputStream decorated = decorateOutputStream(new FileOutputStream(fd));
|
||||
return new BufferedWriter(new OutputStreamWriter(decorated, "UTF-8"));
|
||||
FileOutputStream fos = new FileOutputStream(fd);
|
||||
OutputStream decorated;
|
||||
try {
|
||||
decorated = decorateOutputStream(fos);
|
||||
} catch (final IOException e) {
|
||||
fos.close();
|
||||
throw e;
|
||||
}
|
||||
return new BufferedWriter(
|
||||
new OutputStreamWriter(decorated, "UTF-8"));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -128,7 +136,13 @@ public class SheetDataWriter {
|
||||
*/
|
||||
public InputStream getWorksheetXMLInputStream() throws IOException {
|
||||
File fd = getTempFile();
|
||||
return decorateInputStream(new FileInputStream(fd));
|
||||
FileInputStream fis = new FileInputStream(fd);
|
||||
try {
|
||||
return decorateInputStream(fis);
|
||||
} catch (IOException e) {
|
||||
fis.close();
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user