You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by fa...@apache.org on 2020/09/09 07:05:09 UTC
svn commit: r1881582 - in /poi/trunk: build.gradle
src/java/org/apache/poi/hssf/record/common/ExtRst.java
src/testcases/org/apache/poi/hssf/record/common/TestUnicodeString.java
Author: fanningpj
Date: Wed Sep 9 07:05:09 2020
New Revision: 1881582
URL: http://svn.apache.org/viewvc?rev=1881582&view=rev
Log:
[bug-64721] NullPointerException occurs when calling getDataSize() of an object created with ExtRst.copy(). Thanks to Kwon Ohyoung
Modified:
poi/trunk/build.gradle
poi/trunk/src/java/org/apache/poi/hssf/record/common/ExtRst.java
poi/trunk/src/testcases/org/apache/poi/hssf/record/common/TestUnicodeString.java
Modified: poi/trunk/build.gradle
URL: http://svn.apache.org/viewvc/poi/trunk/build.gradle?rev=1881582&r1=1881581&r2=1881582&view=diff
==============================================================================
--- poi/trunk/build.gradle (original)
+++ poi/trunk/build.gradle Wed Sep 9 07:05:09 2020
@@ -127,7 +127,7 @@ subprojects {
exclude '**/BaseTestCellUtil.class'
exclude '**/TestUnfixedBugs.class'
exclude '**/TestOneFile.class'
-
+include '**/TestUnicodeString.class'
// Exclude Test Suites
exclude '**/All*Tests.class'
exclude '**/HSSFTests.class'
@@ -381,4 +381,4 @@ project('scratchpad') {
}
japicmp.baseline = "org.apache.poi:poi:${japicmpversion}@jar"
-}
\ No newline at end of file
+}
Modified: poi/trunk/src/java/org/apache/poi/hssf/record/common/ExtRst.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/common/ExtRst.java?rev=1881582&r1=1881581&r2=1881582&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/common/ExtRst.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/common/ExtRst.java Wed Sep 9 07:05:09 2020
@@ -58,6 +58,7 @@ public class ExtRst implements Comparabl
}
protected ExtRst(ExtRst other) {
+ this();
reserved = other.reserved;
formattingFontIndex = other.formattingFontIndex;
formattingOptions = other.formattingOptions;
Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/common/TestUnicodeString.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/common/TestUnicodeString.java?rev=1881582&r1=1881581&r2=1881582&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/common/TestUnicodeString.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/common/TestUnicodeString.java Wed Sep 9 07:05:09 2020
@@ -367,6 +367,60 @@ public final class TestUnicodeString {
wb.close();
}
+ @Test
+ public void copyExtRst() {
+ ExtRst ext = new ExtRst();
+
+ assertEquals(0, ext.getNumberOfRuns());
+ assertEquals(0, ext.getFormattingFontIndex());
+ assertEquals(0, ext.getFormattingOptions());
+ assertEquals("", ext.getPhoneticText());
+ assertEquals(0, ext.getPhRuns().length);
+ assertEquals(10, ext.getDataSize()); // Excludes 4 byte header
+
+ ExtRst copied = ext.copy();
+
+ assertEquals(0, copied.getNumberOfRuns());
+ assertEquals(0, copied.getFormattingFontIndex());
+ assertEquals(0, copied.getFormattingOptions());
+ assertEquals("", copied.getPhoneticText());
+ assertEquals(0, copied.getPhRuns().length);
+ assertEquals(10, copied.getDataSize());
+ }
+
+ @Test
+ public void copyExtRstFromData() {
+ byte[] data = new byte[]{
+ 1, 0, 0x0C, 0,
+ 0, 0, 0x37, 0,
+ 0, 0,
+ 0, 0, 0, 0,
+ 0, 0 // Cruft at the end, as found from real files
+ };
+ assertEquals(16, data.length);
+
+ LittleEndianInputStream inp = new LittleEndianInputStream(
+ new ByteArrayInputStream(data)
+ );
+ ExtRst ext = new ExtRst(inp, data.length);
+ assertEquals(0x0c, ext.getDataSize()); // Excludes 4 byte header
+
+ assertEquals(0, ext.getNumberOfRuns());
+ assertEquals(0x37, ext.getFormattingOptions());
+ assertEquals(0, ext.getFormattingFontIndex());
+ assertEquals("", ext.getPhoneticText());
+ assertEquals(0, ext.getPhRuns().length);
+
+ ExtRst copied = ext.copy();
+ assertEquals(10, copied.getDataSize()); // Excludes 4 byte header
+
+ assertEquals(0, copied.getNumberOfRuns());
+ assertEquals(0x37, copied.getFormattingOptions());
+ assertEquals(0, copied.getFormattingFontIndex());
+ assertEquals("", copied.getPhoneticText());
+ assertEquals(0, copied.getPhRuns().length);
+ }
+
private static UnicodeString makeUnicodeString(String s) {
UnicodeString st = new UnicodeString(s);
st.setOptionFlags((byte)0);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org