poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kiwiwi...@apache.org
Subject svn commit: r1749238 - in /poi/trunk/src: java/org/apache/poi/ss/usermodel/ ooxml/java/org/apache/poi/xssf/usermodel/ scratchpad/src/org/apache/poi/hwpf/
Date Mon, 20 Jun 2016 00:08:11 GMT
Author: kiwiwings
Date: Mon Jun 20 00:08:11 2016
New Revision: 1749238

URL: http://svn.apache.org/viewvc?rev=1749238&view=rev
Log:
findbugs fixes

Modified:
    poi/trunk/src/java/org/apache/poi/ss/usermodel/IconMultiStateFormatting.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvaluationSheet.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/HWPFDocument.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/HWPFDocumentCore.java

Modified: poi/trunk/src/java/org/apache/poi/ss/usermodel/IconMultiStateFormatting.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/usermodel/IconMultiStateFormatting.java?rev=1749238&r1=1749237&r2=1749238&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/usermodel/IconMultiStateFormatting.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/usermodel/IconMultiStateFormatting.java Mon Jun 20
00:08:11 2016
@@ -60,7 +60,7 @@ public interface IconMultiStateFormattin
         protected static final IconSet DEFAULT_ICONSET = IconSet.GYR_3_TRAFFIC_LIGHTS;
         
         /** Numeric ID of the icon set */
-        public int id;
+        public final int id;
         /** How many icons in the set */
         public final int num;
         /** Name (system) of the set */

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvaluationSheet.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvaluationSheet.java?rev=1749238&r1=1749237&r2=1749238&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvaluationSheet.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvaluationSheet.java Mon Jun
20 00:08:11 2016
@@ -79,7 +79,9 @@ final class XSSFEvaluationSheet implemen
         
         @Override
         public boolean equals(Object obj) {
-            if (obj == null) return false;
+            if (!(obj instanceof CellKey)) {
+                return false;
+            }
             // assumes other object is one of us, otherwise ClassCastException is thrown
             final CellKey oKey = (CellKey) obj;
             return _row == oKey._row && _col == oKey._col;

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/HWPFDocument.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/HWPFDocument.java?rev=1749238&r1=1749237&r2=1749238&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/HWPFDocument.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/HWPFDocument.java Mon Jun 20 00:08:11
2016
@@ -221,16 +221,17 @@ public final class HWPFDocument extends
     _fib.fillVariableFields(_mainStream, _tableStream);
 
     // read in the data stream.
-    try
-    {
-      DocumentEntry dataProps =
-          (DocumentEntry)directory.getEntry(STREAM_DATA);
-      _dataStream = new byte[dataProps.getSize()];
-      directory.createDocumentInputStream(STREAM_DATA).read(_dataStream);
-    }
-    catch(java.io.FileNotFoundException e)
-    {
+    InputStream dis = null;
+    try {
+      DocumentEntry dataProps = (DocumentEntry)directory.getEntry(STREAM_DATA);
+      dis = directory.createDocumentInputStream(STREAM_DATA);
+      _dataStream = IOUtils.toByteArray(dis, dataProps.getSize());
+    } catch(IOException e) {
         _dataStream = new byte[0];
+    } finally {
+        if (dis != null) {
+            dis.close();
+        }
     }
 
     // Get the cp of the start of text in the main stream

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/HWPFDocumentCore.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/HWPFDocumentCore.java?rev=1749238&r1=1749237&r2=1749238&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/HWPFDocumentCore.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/HWPFDocumentCore.java Mon Jun 20 00:08:11
2016
@@ -37,6 +37,7 @@ import org.apache.poi.hwpf.usermodel.Ran
 import org.apache.poi.poifs.filesystem.DirectoryEntry;
 import org.apache.poi.poifs.filesystem.DirectoryNode;
 import org.apache.poi.poifs.filesystem.DocumentEntry;
+import org.apache.poi.poifs.filesystem.DocumentInputStream;
 import org.apache.poi.poifs.filesystem.POIFSFileSystem;
 import org.apache.poi.util.IOUtils;
 import org.apache.poi.util.Internal;
@@ -147,11 +148,16 @@ public abstract class HWPFDocumentCore e
     super(directory);
 
     // read in the main stream.
-    DocumentEntry documentProps = (DocumentEntry)
-            directory.getEntry("WordDocument");
-    _mainStream = new byte[documentProps.getSize()];
-
-    directory.createDocumentInputStream(STREAM_WORD_DOCUMENT).read(_mainStream);
+    DocumentEntry documentProps = (DocumentEntry)directory.getEntry("WordDocument");
+    DocumentInputStream dis = null;
+    try {
+        dis = directory.createDocumentInputStream(STREAM_WORD_DOCUMENT);
+        _mainStream = IOUtils.toByteArray(dis, documentProps.getSize());
+    } finally {
+        if (dis != null) {
+            dis.close();
+        }
+    }
 
     // Create our FIB, and check for the doc being encrypted
     _fib = new FileInformationBlock(_mainStream);



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message