Skip to content

Commit da1f7b7

Browse files
author
Maruan Sahyoun
committed
PDFBOX-5660: replace null check which doesn't happen
git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1932957 13f79535-47bb-0310-9956-ffa450edef68
1 parent 3607192 commit da1f7b7

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

pdfbox/src/main/java/org/apache/pdfbox/cos/COSStream.java

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -290,11 +290,10 @@ public OutputStream createRawOutputStream() throws IOException
290290
else
291291
randomAccess = getStreamCache().createBuffer();
292292

293-
OutputStream randomOut = null;
293+
OutputStream randomOut = new RandomAccessOutputStream(randomAccess);
294294

295295
try
296296
{
297-
randomOut = new RandomAccessOutputStream(randomAccess);
298297
FilterOutputStream result = new FilterOutputStream(randomOut)
299298
{
300299
@Override
@@ -318,12 +317,19 @@ public void close() throws IOException
318317
}
319318
};
320319
isWriting = true;
321-
randomOut = null; // ownership transferred to result so don't close it in the finally block
322320
return result;
323321
}
324-
finally
322+
catch (Exception e)
325323
{
326-
if (randomOut != null) randomOut.close();
324+
try
325+
{
326+
randomOut.close();
327+
}
328+
catch (IOException closeEx)
329+
{
330+
e.addSuppressed(closeEx);
331+
}
332+
throw e;
327333
}
328334
}
329335

0 commit comments

Comments
 (0)