mirror of https://github.com/apache/poi.git
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
d7ffe9305d
commit
ad360c8e46
|
@ -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