Use try with resources. git-svn-id: https://svn.apache.org/repos/asf/commons/proper/imaging/trunk@1775900 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/commons-imaging/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-imaging/commit/df7e6672 Tree: http://git-wip-us.apache.org/repos/asf/commons-imaging/tree/df7e6672 Diff: http://git-wip-us.apache.org/repos/asf/commons-imaging/diff/df7e6672 Branch: refs/heads/master Commit: df7e6672f089706eabb7fcd2e7e27bb8e4d253a1 Parents: c3c8838 Author: Gary D. Gregory <[email protected]> Authored: Fri Dec 23 21:26:48 2016 +0000 Committer: Gary D. Gregory <[email protected]> Committed: Fri Dec 23 21:26:48 2016 +0000 ---------------------------------------------------------------------- .../tiff/datareaders/DataReaderStrips.java | 36 ++++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/commons-imaging/blob/df7e6672/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderStrips.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderStrips.java b/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderStrips.java index ee632e9..3878b26 100644 --- a/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderStrips.java +++ b/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderStrips.java @@ -166,28 +166,28 @@ public final class DataReaderStrips extends ImageDataReader { // this logic will handle all cases not conforming to the // special case handled above - final BitInputStream bis = new BitInputStream(new ByteArrayInputStream(bytes), byteOrder); + try (final BitInputStream bis = new BitInputStream(new ByteArrayInputStream(bytes), byteOrder)) { - int[] samples = new int[bitsPerSampleLength]; - resetPredictor(); - for (int i = 0; i < pixelsPerStrip; i++) { - getSamplesAsBytes(bis, samples); + int[] samples = new int[bitsPerSampleLength]; + resetPredictor(); + for (int i = 0; i < pixelsPerStrip; i++) { + getSamplesAsBytes(bis, samples); - if (x < width) { - samples = applyPredictor(samples); + if (x < width) { + samples = applyPredictor(samples); - photometricInterpreter.interpretPixel( - imageBuilder, samples, x, y); - } + photometricInterpreter.interpretPixel(imageBuilder, samples, x, y); + } - x++; - if (x >= width) { - x = 0; - resetPredictor(); - y++; - bis.flushCache(); - if (y >= yLimit) { - break; + x++; + if (x >= width) { + x = 0; + resetPredictor(); + y++; + bis.flushCache(); + if (y >= yLimit) { + break; + } } } }
