From d5e64851f69b76853abfa69d9d69a0904e603991 Mon Sep 17 00:00:00 2001 From: Yegor Kozlov Date: Fri, 20 Feb 2009 13:49:33 +0000 Subject: [PATCH] fixed a possible NPE in SimpleShape.getClientRecords() git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@746238 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/org/apache/poi/hslf/model/SimpleShape.java | 7 ++++++- .../org/apache/poi/hslf/extractor/TestExtractor.java | 9 +-------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/scratchpad/src/org/apache/poi/hslf/model/SimpleShape.java b/src/scratchpad/src/org/apache/poi/hslf/model/SimpleShape.java index 0d8992f36a..b0bdcadcca 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/model/SimpleShape.java +++ b/src/scratchpad/src/org/apache/poi/hslf/model/SimpleShape.java @@ -314,12 +314,17 @@ public class SimpleShape extends Shape { return null; } + /** + * Search for EscherClientDataRecord, if found, convert its contents into an array of HSLF records + * + * @return an array of HSLF records contained in the shape's EscherClientDataRecord or null + */ protected Record[] getClientRecords() { if(_clientData == null){ EscherRecord r = Shape.getEscherChild(getSpContainer(), EscherClientDataRecord.RECORD_ID); //ddf can return EscherContainerRecord with recordId=EscherClientDataRecord.RECORD_ID //convert in to EscherClientDataRecord on the fly - if(!(r instanceof EscherClientDataRecord)){ + if(r != null && !(r instanceof EscherClientDataRecord)){ byte[] data = r.serialize(); r = new EscherClientDataRecord(); r.fillFields(data, 0, new DefaultEscherRecordFactory()); diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/extractor/TestExtractor.java b/src/scratchpad/testcases/org/apache/poi/hslf/extractor/TestExtractor.java index f04fbbd5b2..9c213d4773 100644 --- a/src/scratchpad/testcases/org/apache/poi/hslf/extractor/TestExtractor.java +++ b/src/scratchpad/testcases/org/apache/poi/hslf/extractor/TestExtractor.java @@ -237,14 +237,7 @@ public final class TestExtractor extends TestCase { filename = dirname + "/45543.ppt"; ppe = new PowerPointExtractor(filename); - try { - text = ppe.getText(); - } catch (NullPointerException e) { - // TODO - fix this failing test - // This test was failing here with NPE as at svn r745972. - // At that time, the class name was 'TextExtractor' which caused the build script to skip it - return; // for the moment skip the rest of this test. - } + text = ppe.getText(); assertFalse("Comments not in by default", contains(text, "testdoc")); ppe.setCommentsByDefault(true); -- 2.39.5