diff options
author | Dominik Stadler <centic@apache.org> | 2016-03-22 07:51:39 +0000 |
---|---|---|
committer | Dominik Stadler <centic@apache.org> | 2016-03-22 07:51:39 +0000 |
commit | 15d70b0828aa33567c600ca511c91cb9503f2806 (patch) | |
tree | ebc4b5f2f39c24c56f95a0cd7b9f83355fe33635 /src/java/org/apache/poi/util/IOUtils.java | |
parent | fbee1bd860d73813931bdcfb64d8adb97774a8ef (diff) | |
download | poi-15d70b0828aa33567c600ca511c91cb9503f2806.tar.gz poi-15d70b0828aa33567c600ca511c91cb9503f2806.zip |
Check for null in IOUtils.closeQuietly() to not log this unnecessarily
Add coverage for some more methods in ExtractorFactory
Fix some IntelliJ warnings
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1736146 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/poi/util/IOUtils.java')
-rw-r--r-- | src/java/org/apache/poi/util/IOUtils.java | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/java/org/apache/poi/util/IOUtils.java b/src/java/org/apache/poi/util/IOUtils.java index eef58b30c4..befebf444c 100644 --- a/src/java/org/apache/poi/util/IOUtils.java +++ b/src/java/org/apache/poi/util/IOUtils.java @@ -79,9 +79,9 @@ public final class IOUtils { ByteArrayOutputStream baos = new ByteArrayOutputStream(length == Integer.MAX_VALUE ? 4096 : length); byte[] buffer = new byte[4096]; - int totalBytes = 0, readBytes = 0; + int totalBytes = 0, readBytes; do { - readBytes = stream.read(buffer, 0, Math.min(buffer.length, length-totalBytes)); + readBytes = stream.read(buffer, 0, Math.min(buffer.length, length-totalBytes)); totalBytes += Math.max(readBytes,0); if (readBytes > 0) { baos.write(buffer, 0, readBytes); @@ -218,6 +218,11 @@ public final class IOUtils { * resource to close */ public static void closeQuietly( final Closeable closeable ) { + // no need to log a NullPointerException here + if(closeable == null) { + return; + } + try { closeable.close(); } catch ( Exception exc ) { |