commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject svn commit: r1775928 - /commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderTiled.java
Date Fri, 23 Dec 2016 23:23:07 GMT
Author: ggregory
Date: Fri Dec 23 23:23:07 2016
New Revision: 1775928

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

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

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderTiled.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderTiled.java?rev=1775928&r1=1775927&r2=1775928&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderTiled.java
(original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderTiled.java
Fri Dec 23 23:23:07 2016
@@ -115,40 +115,40 @@ public final class DataReaderTiled exten
 
         // End of May 2012 changes
 
-        final BitInputStream bis = new BitInputStream(new ByteArrayInputStream(bytes), byteOrder);
+        try (final BitInputStream bis = new BitInputStream(new ByteArrayInputStream(bytes),
byteOrder)) {
 
-        final int pixelsPerTile = tileWidth * tileLength;
+            final int pixelsPerTile = tileWidth * tileLength;
 
-        int tileX = 0;
-        int tileY = 0;
+            int tileX = 0;
+            int tileY = 0;
 
-        int[] samples = new int[bitsPerSampleLength];
-        resetPredictor();
-        for (int i = 0; i < pixelsPerTile; i++) {
+            int[] samples = new int[bitsPerSampleLength];
+            resetPredictor();
+            for (int i = 0; i < pixelsPerTile; i++) {
 
-            final int x = tileX + startX;
-            final int y = tileY + startY;
+                final int x = tileX + startX;
+                final int y = tileY + startY;
 
-            getSamplesAsBytes(bis, samples);
+                getSamplesAsBytes(bis, samples);
 
-            if ((x < xLimit) && (y < yLimit)) {
-                samples = applyPredictor(samples);
-                photometricInterpreter.interpretPixel(imageBuilder, samples, x,
-                        y);
-            }
+                if ((x < xLimit) && (y < yLimit)) {
+                    samples = applyPredictor(samples);
+                    photometricInterpreter.interpretPixel(imageBuilder, samples, x, y);
+                }
 
-            tileX++;
+                tileX++;
 
-            if (tileX >= tileWidth) {
-                tileX = 0;
-                resetPredictor();
-                tileY++;
-                bis.flushCache();
-                if (tileY >= tileLength) {
-                    break;
+                if (tileX >= tileWidth) {
+                    tileX = 0;
+                    resetPredictor();
+                    tileY++;
+                    bis.flushCache();
+                    if (tileY >= tileLength) {
+                        break;
+                    }
                 }
-            }
 
+            }
         }
     }
 



Mime
View raw message