diff --git a/src/java/org/apache/poi/POIDocument.java b/src/java/org/apache/poi/POIDocument.java index bd70940185..4d86f13927 100644 --- a/src/java/org/apache/poi/POIDocument.java +++ b/src/java/org/apache/poi/POIDocument.java @@ -231,13 +231,10 @@ public abstract class POIDocument implements Closeable { // Find the entry, and get an input stream for it step = "getting"; - DocumentInputStream dis = dirNode.createDocumentInputStream( dirNode.getEntry(setName) ); - try { + try (DocumentInputStream dis = dirNode.createDocumentInputStream(dirNode.getEntry(setName))) { // Create the Property Set step = "creating"; return PropertySetFactory.create(dis); - } finally { - dis.close(); } } catch (IOException e) { throw e; @@ -424,7 +421,7 @@ public abstract class POIDocument implements Closeable { * Closes the underlying {@link NPOIFSFileSystem} from which * the document was read, if any. Has no effect on documents * opened from an InputStream, or newly created ones. - *
Once {@link #close()} has been called, no further operations + *
Once close() has been called, no further operations
* should be called on the document.
*/
@Override
diff --git a/src/java/org/apache/poi/sl/usermodel/SlideShow.java b/src/java/org/apache/poi/sl/usermodel/SlideShow.java
index 9fdf060d69..175ad2b00e 100644
--- a/src/java/org/apache/poi/sl/usermodel/SlideShow.java
+++ b/src/java/org/apache/poi/sl/usermodel/SlideShow.java
@@ -130,7 +130,7 @@ public interface SlideShow<
/**
* @return the instance which handles the persisting of the slideshow,
* which is either a subclass of {@link org.apache.poi.POIDocument}
- * or {@link org.apache.poi.POIXMLDocument}
+ * or {@link org.apache.poi.ooxml.POIXMLDocument}
*
* @since POI 4.0.0
*/
diff --git a/src/ooxml/testcases/org/apache/poi/ss/format/TestCellFormatPart.java b/src/ooxml/testcases/org/apache/poi/ss/format/TestCellFormatPart.java
index baef082015..bc66fc4463 100644
--- a/src/ooxml/testcases/org/apache/poi/ss/format/TestCellFormatPart.java
+++ b/src/ooxml/testcases/org/apache/poi/ss/format/TestCellFormatPart.java
@@ -55,7 +55,7 @@ public class TestCellFormatPart extends CellFormatTestBase {
}
@Test
- public void testGeneralFormat() throws Exception {
+ public void testGeneralFormat() {
runFormatTests("GeneralFormatTests.xlsx", new CellValue() {
@Override
public Object getValue(Cell cell) {
@@ -71,7 +71,8 @@ public class TestCellFormatPart extends CellFormatTestBase {
});
}
- public void testNumberFormat() throws Exception {
+ @Test
+ public void testNumberFormat() {
runFormatTests("NumberFormatTests.xlsx", new CellValue() {
@Override
public Object getValue(Cell cell) {
@@ -81,7 +82,7 @@ public class TestCellFormatPart extends CellFormatTestBase {
}
@Test
- public void testNumberApproxFormat() throws Exception {
+ public void testNumberApproxFormat() {
runFormatTests("NumberFormatApproxTests.xlsx", new CellValue() {
@Override
public Object getValue(Cell cell) {
@@ -102,7 +103,7 @@ public class TestCellFormatPart extends CellFormatTestBase {
}
@Test
- public void testDateFormat() throws Exception {
+ public void testDateFormat() {
TimeZone tz = LocaleUtil.getUserTimeZone();
LocaleUtil.setUserTimeZone(TimeZone.getTimeZone("CET"));
try {
@@ -118,7 +119,7 @@ public class TestCellFormatPart extends CellFormatTestBase {
}
@Test
- public void testElapsedFormat() throws Exception {
+ public void testElapsedFormat() {
runFormatTests("ElapsedFormatTests.xlsx", new CellValue() {
@Override
public Object getValue(Cell cell) {
@@ -128,7 +129,7 @@ public class TestCellFormatPart extends CellFormatTestBase {
}
@Test
- public void testTextFormat() throws Exception {
+ public void testTextFormat() {
runFormatTests("TextFormatTests.xlsx", new CellValue() {
@Override
public Object getValue(Cell cell) {
@@ -143,7 +144,7 @@ public class TestCellFormatPart extends CellFormatTestBase {
}
@Test
- public void testConditions() throws Exception {
+ public void testConditions() {
runFormatTests("FormatConditionTests.xlsx", new CellValue() {
@Override
Object getValue(Cell cell) {
diff --git a/src/testcases/org/apache/poi/ss/format/CellFormatTestBase.java b/src/testcases/org/apache/poi/ss/format/CellFormatTestBase.java
index df20a3c8e7..1b659d4f26 100644
--- a/src/testcases/org/apache/poi/ss/format/CellFormatTestBase.java
+++ b/src/testcases/org/apache/poi/ss/format/CellFormatTestBase.java
@@ -96,8 +96,7 @@ public class CellFormatTestBase {
}
}
- protected void runFormatTests(String workbookName, CellValue valueGetter)
- throws IOException {
+ protected void runFormatTests(String workbookName, CellValue valueGetter) {
openWorkbook(workbookName);
@@ -136,11 +135,8 @@ public class CellFormatTestBase {
* @param workbookName The workbook name. This is presumed to live in the
* "spreadsheets" directory under the directory named in
* the Java property "POI.testdata.path".
- *
- * @throws IOException
*/
- protected void openWorkbook(String workbookName)
- throws IOException {
+ protected void openWorkbook(String workbookName) {
workbook = _testDataProvider.openSampleWorkbook(workbookName);
workbook.setMissingCellPolicy(MissingCellPolicy.CREATE_NULL_AS_BLANK);
testFile = workbookName;
diff --git a/src/testcases/org/apache/poi/ss/usermodel/TestExcelStyleDateFormatter.java b/src/testcases/org/apache/poi/ss/usermodel/TestExcelStyleDateFormatter.java
index a522f6b6cc..ef23f36ae4 100644
--- a/src/testcases/org/apache/poi/ss/usermodel/TestExcelStyleDateFormatter.java
+++ b/src/testcases/org/apache/poi/ss/usermodel/TestExcelStyleDateFormatter.java
@@ -18,7 +18,6 @@
package org.apache.poi.ss.usermodel;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
import java.text.DateFormatSymbols;
import java.text.FieldPosition;
@@ -42,6 +41,41 @@ public class TestExcelStyleDateFormatter {
*/
@Test
public void test60369() throws ParseException {
+ Map