summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/openxml4j/util/ZipArchiveFakeEntry.java4
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/poifs/crypt/temp/EncryptedTempData.java2
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/xdgf/usermodel/XmlVisioDocument.java11
-rw-r--r--poi-ooxml/src/test/java/org/apache/poi/xwpf/TestXWPFBugs.java11
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hpbf/model/qcbits/QCPLCBit.java2
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hwpf/HWPFDocument.java1
-rw-r--r--poi-scratchpad/src/test/java/org/apache/poi/hslf/usermodel/TestTextRun.java16
-rw-r--r--poi/src/main/java/org/apache/poi/hssf/record/SupBookRecord.java2
-rw-r--r--poi/src/main/java/org/apache/poi/hssf/record/chart/ChartFRTInfoRecord.java12
9 files changed, 34 insertions, 27 deletions
diff --git a/poi-ooxml/src/main/java/org/apache/poi/openxml4j/util/ZipArchiveFakeEntry.java b/poi-ooxml/src/main/java/org/apache/poi/openxml4j/util/ZipArchiveFakeEntry.java
index 5cfa893099..519323ec14 100644
--- a/poi-ooxml/src/main/java/org/apache/poi/openxml4j/util/ZipArchiveFakeEntry.java
+++ b/poi-ooxml/src/main/java/org/apache/poi/openxml4j/util/ZipArchiveFakeEntry.java
@@ -55,7 +55,7 @@ import org.apache.poi.util.TempFile;
} else {
tempFile = TempFile.createTempFile("poi-zip-entry", ".tmp");
LOG.atInfo().log("created for temp file {} for zip entry {} of size {} bytes",
- () -> tempFile.getAbsolutePath(), () -> entry.getName(), () -> entrySize);
+ () -> tempFile.getAbsolutePath(), entry::getName, () -> entrySize);
IOUtils.copy(inp, tempFile);
}
} else {
@@ -97,7 +97,7 @@ import org.apache.poi.util.TempFile;
/**
* Deletes any temp files and releases any byte arrays.
- * @throws IOException
+ * @throws IOException If closing the entry fails.
* @since POI 5.1.0
*/
@Override
diff --git a/poi-ooxml/src/main/java/org/apache/poi/poifs/crypt/temp/EncryptedTempData.java b/poi-ooxml/src/main/java/org/apache/poi/poifs/crypt/temp/EncryptedTempData.java
index bfc35c52d6..45b9947981 100644
--- a/poi-ooxml/src/main/java/org/apache/poi/poifs/crypt/temp/EncryptedTempData.java
+++ b/poi-ooxml/src/main/java/org/apache/poi/poifs/crypt/temp/EncryptedTempData.java
@@ -100,7 +100,7 @@ public class EncryptedTempData {
*/
public void dispose() {
if (!tempFile.delete()) {
- LOG.atWarn().log("{} can't be removed (or was already removed).", () -> tempFile.getAbsolutePath());
+ LOG.atWarn().log("{} can't be removed (or was already removed).", tempFile::getAbsolutePath);
}
}
}
diff --git a/poi-ooxml/src/main/java/org/apache/poi/xdgf/usermodel/XmlVisioDocument.java b/poi-ooxml/src/main/java/org/apache/poi/xdgf/usermodel/XmlVisioDocument.java
index 40de1aaf72..f0242f074d 100644
--- a/poi-ooxml/src/main/java/org/apache/poi/xdgf/usermodel/XmlVisioDocument.java
+++ b/poi-ooxml/src/main/java/org/apache/poi/xdgf/usermodel/XmlVisioDocument.java
@@ -82,7 +82,6 @@ public class XmlVisioDocument extends POIXMLDocument {
@Override
protected void onDocumentRead() {
-
// by the time this gets called, all other document parts should
// have been loaded, so it's safe to build the document structure
@@ -90,17 +89,17 @@ public class XmlVisioDocument extends POIXMLDocument {
// loaded yet, so it's not quite safe
for (POIXMLDocumentPart part : getRelations()) {
-
// organize the document pieces
- if (part instanceof XDGFPages)
+ if (part instanceof XDGFPages) {
_pages = (XDGFPages) part;
-
- else if (part instanceof XDGFMasters)
+ } else if (part instanceof XDGFMasters) {
_masters = (XDGFMasters) part;
+ }
}
- if (_masters != null)
+ if (_masters != null) {
_masters.onDocumentRead();
+ }
_pages.onDocumentRead();
}
diff --git a/poi-ooxml/src/test/java/org/apache/poi/xwpf/TestXWPFBugs.java b/poi-ooxml/src/test/java/org/apache/poi/xwpf/TestXWPFBugs.java
index 3ba2371d19..7048bc13fe 100644
--- a/poi-ooxml/src/test/java/org/apache/poi/xwpf/TestXWPFBugs.java
+++ b/poi-ooxml/src/test/java/org/apache/poi/xwpf/TestXWPFBugs.java
@@ -52,6 +52,7 @@ class TestXWPFBugs {
assertThrows(IOException.class, () -> {
try (InputStream fis = samples.openResourceAsStream("truncated62886.docx");
OPCPackage opc = OPCPackage.open(fis)) {
+ assertNotNull(opc);
//XWPFWordExtractor ext = new XWPFWordExtractor(opc)) {
//assertNotNull(ext.getText());
}
@@ -59,7 +60,7 @@ class TestXWPFBugs {
}
/**
- * A word document that's encrypted with non-standard
+ * A Word document that's encrypted with non-standard
* Encryption options, and no cspname section. See bug 53475
*/
@Test
@@ -77,7 +78,7 @@ class TestXWPFBugs {
Decryptor d = Decryptor.getInstance(info);
assertTrue(d.verifyPassword("solrcell"), "Unable to process: document is encrypted");
- // Check we can read the word document in that
+ // Check we can read the Word document in that
InputStream dataStream = d.getDataStream(filesystem);
OPCPackage opc = OPCPackage.open(dataStream);
XWPFDocument doc = new XWPFDocument(opc);
@@ -91,7 +92,7 @@ class TestXWPFBugs {
}
/**
- * A word document with aes-256, i.e. aes is always 128 bit (= 128 bit block size),
+ * A Word document with aes-256, i.e. aes is always 128 bit (= 128 bit block size),
* but the key can be 128/192/256 bits
*/
@Test
@@ -113,7 +114,7 @@ class TestXWPFBugs {
Decryptor d = Decryptor.getInstance(info);
assertTrue(d.verifyPassword("pass"), "Unable to process: document is encrypted");
- // Check we can read the word document in that
+ // Check we can read the Word document in that
InputStream dataStream = d.getDataStream(filesystem);
OPCPackage opc = OPCPackage.open(dataStream);
XWPFDocument doc = new XWPFDocument(opc);
@@ -158,4 +159,4 @@ class TestXWPFBugs {
assertEquals(731, document.getParagraphs().size());
}
}
-} \ No newline at end of file
+}
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hpbf/model/qcbits/QCPLCBit.java b/poi-scratchpad/src/main/java/org/apache/poi/hpbf/model/qcbits/QCPLCBit.java
index a8a12a9ea0..cd039cf36d 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hpbf/model/qcbits/QCPLCBit.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hpbf/model/qcbits/QCPLCBit.java
@@ -207,7 +207,7 @@ public abstract class QCPLCBit extends QCBit {
* of the text area that this applies to.
*/
public static class Type12 extends QCPLCBit {
- private String[] hyperlinks;
+ private final String[] hyperlinks;
private static final int oneStartsAt = 0x4c;
private static final int twoStartsAt = 0x68;
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/HWPFDocument.java b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/HWPFDocument.java
index 61ed4da168..f31df61f38 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/HWPFDocument.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/HWPFDocument.java
@@ -214,6 +214,7 @@ public final class HWPFDocument extends HWPFDocumentCore {
* @param istream The InputStream that contains the Word document.
* @throws IOException If there is an unexpected IOException from the passed
* in InputStream.
+ * @throws org.apache.poi.EmptyFileException If the given stream is empty
*/
public HWPFDocument(InputStream istream) throws IOException {
//do Ole stuff
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/usermodel/TestTextRun.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/usermodel/TestTextRun.java
index 3e51fb8f5d..46939beec4 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/usermodel/TestTextRun.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/usermodel/TestTextRun.java
@@ -46,6 +46,7 @@ import org.apache.poi.sl.usermodel.BaseTestSlideShow;
import org.apache.poi.sl.usermodel.PlaceholderDetails;
import org.apache.poi.util.LocaleUtil;
import org.junit.jupiter.api.Test;
+import org.opentest4j.AssertionFailedError;
/**
* Tests for TextRuns
@@ -603,16 +604,21 @@ public final class TestTextRun {
.mapToInt(r -> ((DateTimeMCAtom)r).getIndex()).toArray();
assertArrayEquals(expFormatId, actFormatId);
- List<HSLFShapePlaceholderDetails> phs = shapes.stream().map(HSLFSimpleShape::getPlaceholderDetails).collect(Collectors.toList());
+ List<HSLFShapePlaceholderDetails> phs =
+ shapes.stream().map(HSLFSimpleShape::getPlaceholderDetails).collect(Collectors.toList());
for (Map.Entry<Locale,String[]> me : formats.entrySet()) {
LocaleUtil.setUserLocale(me.getKey());
- // refresh internal members
- phs.forEach(PlaceholderDetails::getPlaceholder);
+ try {
+ // refresh internal members
+ phs.forEach(PlaceholderDetails::getPlaceholder);
- String[] actDate = phs.stream().map(PlaceholderDetails::getDateFormat).map(ldt::format).toArray(String[]::new);
- assertArrayEquals(me.getValue(), actDate);
+ String[] actDate = phs.stream().map(PlaceholderDetails::getDateFormat).map(ldt::format).toArray(String[]::new);
+ assertArrayEquals(me.getValue(), actDate);
+ } catch (AssertionFailedError e) {
+ throw new AssertionFailedError("While handling local " + me.getKey());
+ }
}
} finally {
LocaleUtil.resetUserLocale();
diff --git a/poi/src/main/java/org/apache/poi/hssf/record/SupBookRecord.java b/poi/src/main/java/org/apache/poi/hssf/record/SupBookRecord.java
index 0bb9814f35..240c7b4c35 100644
--- a/poi/src/main/java/org/apache/poi/hssf/record/SupBookRecord.java
+++ b/poi/src/main/java/org/apache/poi/hssf/record/SupBookRecord.java
@@ -242,7 +242,7 @@ public final class SupBookRecord extends StandardRecord {
public void setURL(String pUrl) {
//Keep the first marker character!
- field_2_encoded_url = field_2_encoded_url.substring(0, 1) + pUrl;
+ field_2_encoded_url = field_2_encoded_url.charAt(0) + pUrl;
}
@Override
diff --git a/poi/src/main/java/org/apache/poi/hssf/record/chart/ChartFRTInfoRecord.java b/poi/src/main/java/org/apache/poi/hssf/record/chart/ChartFRTInfoRecord.java
index 3685f06762..ed6e6c91d5 100644
--- a/poi/src/main/java/org/apache/poi/hssf/record/chart/ChartFRTInfoRecord.java
+++ b/poi/src/main/java/org/apache/poi/hssf/record/chart/ChartFRTInfoRecord.java
@@ -34,16 +34,16 @@ import org.apache.poi.util.LittleEndianOutput;
public final class ChartFRTInfoRecord extends StandardRecord {
public static final short sid = 0x850;
- private short rt;
- private short grbitFrt;
- private byte verOriginator;
- private byte verWriter;
+ private final short rt;
+ private final short grbitFrt;
+ private final byte verOriginator;
+ private final byte verWriter;
private CFRTID[] rgCFRTID;
private static final class CFRTID {
public static final int ENCODED_SIZE = 4;
- private int rtFirst;
- private int rtLast;
+ private final int rtFirst;
+ private final int rtLast;
public CFRTID(CFRTID other) {
rtFirst = other.rtFirst;