Author: ggregory
Date: Fri Dec 23 21:26:48 2016
New Revision: 1775900

URL: http://svn.apache.org/viewvc?rev=1775900&view=rev
Log:
Use try with resources.

Modified:
    
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderStrips.java

Modified: 
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderStrips.java
URL: 
http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderStrips.java?rev=1775900&r1=1775899&r2=1775900&view=diff
==============================================================================
--- 
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderStrips.java
 (original)
+++ 
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderStrips.java
 Fri Dec 23 21:26:48 2016
@@ -166,28 +166,28 @@ public final class DataReaderStrips exte
         // 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;
+                    }
                 }
             }
         }


Reply via email to