diff --git a/src/ooxml/java/org/apache/poi/poifs/crypt/agile/AgileDecryptor.java b/src/ooxml/java/org/apache/poi/poifs/crypt/agile/AgileDecryptor.java index f8c9bb551..9ce0a2b74 100644 --- a/src/ooxml/java/org/apache/poi/poifs/crypt/agile/AgileDecryptor.java +++ b/src/ooxml/java/org/apache/poi/poifs/crypt/agile/AgileDecryptor.java @@ -278,7 +278,6 @@ public class AgileDecryptor extends Decryptor { } } - @SuppressWarnings("resource") public InputStream getDataStream(DirectoryNode dir) throws IOException, GeneralSecurityException { DocumentInputStream dis = dir.createDocumentInputStream(DEFAULT_POIFS_ENTRY); _length = dis.readLong(); diff --git a/src/testcases/org/apache/poi/TestPOIDocumentMain.java b/src/testcases/org/apache/poi/TestPOIDocumentMain.java index bac0c125c..7483d5996 100644 --- a/src/testcases/org/apache/poi/TestPOIDocumentMain.java +++ b/src/testcases/org/apache/poi/TestPOIDocumentMain.java @@ -131,10 +131,14 @@ public final class TestPOIDocumentMain { doc.write(baos); ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); + ((HSSFWorkbook)doc).close(); + doc = new HSSFWorkbook(bais); assertNotNull(doc.getSummaryInformation()); assertNotNull(doc.getDocumentSummaryInformation()); + + ((HSSFWorkbook)doc).close(); } @Test @@ -148,6 +152,9 @@ public final class TestPOIDocumentMain { // Write out and back in again, no change ByteArrayOutputStream baos = new ByteArrayOutputStream(); doc.write(baos); + + ((HSSFWorkbook)doc).close(); + ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); doc = new HSSFWorkbook(bais); @@ -162,6 +169,9 @@ public final class TestPOIDocumentMain { // Save and re-load baos = new ByteArrayOutputStream(); doc.write(baos); + + ((HSSFWorkbook)doc).close(); + bais = new ByteArrayInputStream(baos.toByteArray()); doc = new HSSFWorkbook(bais); @@ -177,5 +187,7 @@ public final class TestPOIDocumentMain { assertNotNull(doc.getDocumentSummaryInformation()); assertEquals("POI Testing", doc.getSummaryInformation().getAuthor()); assertEquals("ASF", doc.getDocumentSummaryInformation().getCompany()); + + ((HSSFWorkbook)doc).close(); } } diff --git a/src/testcases/org/apache/poi/ss/util/NumberRenderingSpreadsheetGenerator.java b/src/testcases/org/apache/poi/ss/util/NumberRenderingSpreadsheetGenerator.java index c9146ab78..7eda47279 100644 --- a/src/testcases/org/apache/poi/ss/util/NumberRenderingSpreadsheetGenerator.java +++ b/src/testcases/org/apache/poi/ss/util/NumberRenderingSpreadsheetGenerator.java @@ -206,7 +206,7 @@ public class NumberRenderingSpreadsheetGenerator { } private static void writeLong(byte[] bb, int i, long val) { - String oldVal = interpretLong(bb, i); + /*String oldVal =*/ interpretLong(bb, i); bb[i+7] = (byte) (val >> 56); bb[i+6] = (byte) (val >> 48); bb[i+5] = (byte) (val >> 40); diff --git a/src/testcases/org/apache/poi/ss/util/TestCellRangeAddress.java b/src/testcases/org/apache/poi/ss/util/TestCellRangeAddress.java index cf9e6019e..431c80c78 100644 --- a/src/testcases/org/apache/poi/ss/util/TestCellRangeAddress.java +++ b/src/testcases/org/apache/poi/ss/util/TestCellRangeAddress.java @@ -17,18 +17,17 @@ limitations under the License. package org.apache.poi.ss.util; -import static org.junit.Assert.fail; +import static org.junit.Assert.assertNotEquals; import java.io.ByteArrayOutputStream; import java.io.IOException; -//TODO: replace junit3 with junit4 code -import junit.framework.TestCase; //junit3 -import static org.junit.Assert.assertNotEquals; //junit4 - import org.apache.poi.hssf.record.TestcaseRecordInputStream; import org.apache.poi.util.LittleEndianOutputStream; +//TODO: replace junit3 with junit4 code +import junit.framework.TestCase; //junit3 + public final class TestCellRangeAddress extends TestCase { byte[] data = new byte[] { (byte) 0x02, (byte) 0x00, (byte) 0x04, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x03, (byte) 0x00, }; diff --git a/src/testcases/org/apache/poi/util/TestHexDump.java b/src/testcases/org/apache/poi/util/TestHexDump.java index 30cd8256a..a4bba3725 100644 --- a/src/testcases/org/apache/poi/util/TestHexDump.java +++ b/src/testcases/org/apache/poi/util/TestHexDump.java @@ -19,7 +19,6 @@ package org.apache.poi.util; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; @@ -29,7 +28,6 @@ import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.PrintStream; -import java.lang.reflect.Constructor; import org.junit.Test; diff --git a/src/testcases/org/apache/poi/util/TestLittleEndianStreams.java b/src/testcases/org/apache/poi/util/TestLittleEndianStreams.java index 6e7b30f74..c05e365a9 100644 --- a/src/testcases/org/apache/poi/util/TestLittleEndianStreams.java +++ b/src/testcases/org/apache/poi/util/TestLittleEndianStreams.java @@ -21,6 +21,7 @@ import static org.junit.Assert.assertArrayEquals; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; +import java.io.IOException; import junit.framework.AssertionFailedError; import junit.framework.TestCase; @@ -32,7 +33,7 @@ import junit.framework.TestCase; */ public final class TestLittleEndianStreams extends TestCase { - public void testRead() { + public void testRead() throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); LittleEndianOutput leo = new LittleEndianOutputStream(baos); leo.writeInt(12345678); @@ -42,6 +43,7 @@ public final class TestLittleEndianStreams extends TestCase { leo.writeByte(200); leo.writeLong(1234567890123456789L); leo.writeDouble(123.456); + ((LittleEndianOutputStream)leo).close(); LittleEndianInput lei = new LittleEndianInputStream(new ByteArrayInputStream(baos.toByteArray())); @@ -52,6 +54,7 @@ public final class TestLittleEndianStreams extends TestCase { assertEquals(200, lei.readUByte()); assertEquals(1234567890123456789L, lei.readLong()); assertEquals(123.456, lei.readDouble(), 0.0); + ((LittleEndianInputStream)lei).close(); } /**