Return-Path: X-Original-To: apmail-poi-commits-archive@minotaur.apache.org Delivered-To: apmail-poi-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 71E6618A03 for ; Sat, 19 Sep 2015 12:22:45 +0000 (UTC) Received: (qmail 99866 invoked by uid 500); 19 Sep 2015 12:22:45 -0000 Delivered-To: apmail-poi-commits-archive@poi.apache.org Received: (qmail 99828 invoked by uid 500); 19 Sep 2015 12:22:45 -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 99817 invoked by uid 99); 19 Sep 2015 12:22:45 -0000 Received: from Unknown (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 19 Sep 2015 12:22:45 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id A4A801801DE for ; Sat, 19 Sep 2015 12:22:44 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 4.3 X-Spam-Level: **** X-Spam-Status: No, score=4.3 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RDNS_NONE=2.5] autolearn=disabled Received: from mx1-us-east.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id bDOjDnVcXVcW for ; Sat, 19 Sep 2015 12:22:43 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (unknown [209.188.14.139]) by mx1-us-east.apache.org (ASF Mail Server at mx1-us-east.apache.org) with ESMTP id 7998342B0A for ; Sat, 19 Sep 2015 12:22:43 +0000 (UTC) Received: from svn01-us-west.apache.org (svn.apache.org [10.41.0.6]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id EDF6FE022D for ; Sat, 19 Sep 2015 12:22:42 +0000 (UTC) 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 EB0993A0182 for ; Sat, 19 Sep 2015 12:22:42 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1703999 - in /poi/trunk: src/java/org/apache/poi/ss/formula/OperationEvaluationContext.java src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java test-data/spreadsheet/57925.xls Date: Sat, 19 Sep 2015 12:22:42 -0000 To: commits@poi.apache.org From: centic@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20150919122242.EB0993A0182@svn01-us-west.apache.org> Author: centic Date: Sat Sep 19 12:22:42 2015 New Revision: 1703999 URL: http://svn.apache.org/viewvc?rev=1703999&view=rev Log: Bug 57925: Add unit test and a simple fix to at least avoid the NPE when Workbooks have invalid external references Added: poi/trunk/test-data/spreadsheet/57925.xls Modified: poi/trunk/src/java/org/apache/poi/ss/formula/OperationEvaluationContext.java poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java Modified: poi/trunk/src/java/org/apache/poi/ss/formula/OperationEvaluationContext.java URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/formula/OperationEvaluationContext.java?rev=1703999&r1=1703998&r2=1703999&view=diff ============================================================================== --- poi/trunk/src/java/org/apache/poi/ss/formula/OperationEvaluationContext.java (original) +++ poi/trunk/src/java/org/apache/poi/ss/formula/OperationEvaluationContext.java Sat Sep 19 12:22:42 2015 @@ -94,7 +94,11 @@ public final class OperationEvaluationCo if (externalSheet == null || externalSheet.getWorkbookName() == null) { // sheet is in same workbook targetEvaluator = _bookEvaluator; - otherFirstSheetIndex = _workbook.getSheetIndex(externalSheet.getSheetName()); + if(externalSheet == null) { + otherFirstSheetIndex = 0; + } else { + otherFirstSheetIndex = _workbook.getSheetIndex(externalSheet.getSheetName()); + } if (externalSheet instanceof ExternalSheetRange) { String lastSheetName = ((ExternalSheetRange)externalSheet).getLastSheetName(); Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java?rev=1703999&r1=1703998&r2=1703999&view=diff ============================================================================== --- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java (original) +++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java Sat Sep 19 12:22:42 2015 @@ -2846,4 +2846,22 @@ public final class TestBugs extends Base wb.close(); } + + @Test + public void test57925() throws IOException { + Workbook wb = HSSFTestDataSamples.openSampleWorkbook("57925.xls"); + + wb.getCreationHelper().createFormulaEvaluator().evaluateAll(); + + for(int i = 0;i < wb.getNumberOfSheets();i++) { + Sheet sheet = wb.getSheetAt(i); + for(Row row : sheet) { + for(Cell cell : row) { + new DataFormatter().formatCellValue(cell); + } + } + } + + wb.close(); + } } Added: poi/trunk/test-data/spreadsheet/57925.xls URL: http://svn.apache.org/viewvc/poi/trunk/test-data/spreadsheet/57925.xls?rev=1703999&view=auto ============================================================================== Binary files poi/trunk/test-data/spreadsheet/57925.xls (added) and poi/trunk/test-data/spreadsheet/57925.xls Sat Sep 19 12:22:42 2015 differ --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org For additional commands, e-mail: commits-help@poi.apache.org