From commits-return-11746-archive-asf-public=cust-asf.ponee.io@poi.apache.org Fri Oct 26 21:06:21 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 926C7180647 for ; Fri, 26 Oct 2018 21:06:20 +0200 (CEST) Received: (qmail 49353 invoked by uid 500); 26 Oct 2018 19:06:19 -0000 Mailing-List: contact commits-help@poi.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@poi.apache.org Delivered-To: mailing list commits@poi.apache.org Received: (qmail 49344 invoked by uid 99); 26 Oct 2018 19:06:19 -0000 Received: from Unknown (HELO svn01-us-west.apache.org) (209.188.14.144) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 26 Oct 2018 19:06:19 +0000 Received: from svn01-us-west.apache.org (localhost [127.0.0.1]) by svn01-us-west.apache.org (ASF Mail Server at svn01-us-west.apache.org) with ESMTP id EA6573A0057 for ; Fri, 26 Oct 2018 19:06:18 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1844920 - in /poi: site/src/documentation/content/xdocs/ trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/ trunk/src/ooxml/testcases/org/apache/poi/sl/ trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/ trunk/test-data/document/ Date: Fri, 26 Oct 2018 19:06:18 -0000 To: commits@poi.apache.org From: tallison@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20181026190618.EA6573A0057@svn01-us-west.apache.org> Author: tallison Date: Fri Oct 26 19:06:18 2018 New Revision: 1844920 URL: http://svn.apache.org/viewvc?rev=1844920&view=rev Log: bug 62859 -- fix two potential NPEs when initializing XWPFSDTContent Added: poi/trunk/test-data/document/Bug62859.docx (with props) Modified: poi/site/src/documentation/content/xdocs/changes.xml poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFSDTContent.java poi/trunk/src/ooxml/testcases/org/apache/poi/sl/TestFonts.java poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFSDT.java Modified: poi/site/src/documentation/content/xdocs/changes.xml URL: http://svn.apache.org/viewvc/poi/site/src/documentation/content/xdocs/changes.xml?rev=1844920&r1=1844919&r2=1844920&view=diff ============================================================================== --- poi/site/src/documentation/content/xdocs/changes.xml (original) +++ poi/site/src/documentation/content/xdocs/changes.xml Fri Oct 26 19:06:18 2018 @@ -94,6 +94,7 @@ Improvements for XDDF charts and text manipulation + Rare NPE while creating XWPFSDTContent Support for FREQUENCY function WorkbookFactory.create support for subclass of File, eg from JFileChooser XLSB number extraction improvements Modified: poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFSDTContent.java URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFSDTContent.java?rev=1844920&r1=1844919&r2=1844920&view=diff ============================================================================== --- poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFSDTContent.java (original) +++ poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFSDTContent.java Fri Oct 26 19:06:18 2018 @@ -47,6 +47,9 @@ public class XWPFSDTContent implements I private List bodyElements = new ArrayList<>(); public XWPFSDTContent(CTSdtContentRun sdtRun, IBody part, IRunBody parent) { + if (sdtRun == null) { + return; + } for (CTR ctr : sdtRun.getRArray()) { XWPFRun run = new XWPFRun(ctr, parent); // runs.add(run); @@ -55,6 +58,9 @@ public class XWPFSDTContent implements I } public XWPFSDTContent(CTSdtContentBlock block, IBody part, IRunBody parent) { + if (block == null) { + return; + } XmlCursor cursor = block.newCursor(); cursor.selectPath("./*"); while (cursor.toNextSelection()) { Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/sl/TestFonts.java URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/sl/TestFonts.java?rev=1844920&r1=1844919&r2=1844920&view=diff ============================================================================== --- poi/trunk/src/ooxml/testcases/org/apache/poi/sl/TestFonts.java (original) +++ poi/trunk/src/ooxml/testcases/org/apache/poi/sl/TestFonts.java Fri Oct 26 19:06:18 2018 @@ -74,7 +74,7 @@ public class TestFonts { // currently linux and mac return quite different values private static final int[] expected_sizes = { 304, // windows 10, 1080p, MS Office 2016, system text scaling 100% instead of default 125% - 306, // Windows 10, 15.6" 3840x2160 + 306, 308,// Windows 10, 15.6" 3840x2160 311, 312, 313, 318, 348, // Windows 10, 15.6" 3840x2160 362, // Windows 10, 13.3" 1080p high-dpi Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFSDT.java URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFSDT.java?rev=1844920&r1=1844919&r2=1844920&view=diff ============================================================================== --- poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFSDT.java (original) +++ poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFSDT.java Fri Oct 26 19:06:18 2018 @@ -148,6 +148,19 @@ public final class TestXWPFSDT { assertEquals("", sdts.get(0).getTitle()); } + @Test + public void test62859() throws IOException { + //this doesn't test the exact code path for this issue, but + //it does test for a related issue, and the fix fixes both. + //We should try to add the actual triggering document + //to our test suite. + XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("Bug62859.docx"); + List sdts = extractAllSDTs(doc); + assertEquals(1, sdts.size()); + assertEquals("", sdts.get(0).getTag()); + assertEquals("", sdts.get(0).getTitle()); + } + private List extractAllSDTs(XWPFDocument doc) { List sdts = new ArrayList<>(); Added: poi/trunk/test-data/document/Bug62859.docx URL: http://svn.apache.org/viewvc/poi/trunk/test-data/document/Bug62859.docx?rev=1844920&view=auto ============================================================================== Binary file - no diff available. Propchange: poi/trunk/test-data/document/Bug62859.docx ------------------------------------------------------------------------------ --- svn:mime-type (added) +++ svn:mime-type Fri Oct 26 19:06:18 2018 @@ -0,0 +1 @@ +application/vnd.openxmlformats-officedocument.wordprocessingml.document --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org For additional commands, e-mail: commits-help@poi.apache.org