Return-Path: X-Original-To: apmail-poi-dev-archive@www.apache.org Delivered-To: apmail-poi-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 4713E18DAB for ; Fri, 3 Jul 2015 10:14:48 +0000 (UTC) Received: (qmail 22176 invoked by uid 500); 3 Jul 2015 10:14:48 -0000 Delivered-To: apmail-poi-dev-archive@poi.apache.org Received: (qmail 22136 invoked by uid 500); 3 Jul 2015 10:14:48 -0000 Mailing-List: contact dev-help@poi.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "POI Developers List" Delivered-To: mailing list dev@poi.apache.org Received: (qmail 22125 invoked by uid 99); 3 Jul 2015 10:14:48 -0000 Received: from mail-relay.apache.org (HELO mail-relay.apache.org) (140.211.11.15) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 03 Jul 2015 10:14:48 +0000 Received: from asf-bz1-us-mid.priv.apache.org (nat1-us-mid.apache.org [23.253.172.122]) by mail-relay.apache.org (ASF Mail Server at mail-relay.apache.org) with ESMTPS id E6B9E1A0596 for ; Fri, 3 Jul 2015 10:14:47 +0000 (UTC) Received: by asf-bz1-us-mid.priv.apache.org (ASF Mail Server at asf-bz1-us-mid.priv.apache.org, from userid 33) id E1D2E60550; Fri, 3 Jul 2015 10:14:46 +0000 (UTC) From: bugzilla@apache.org To: dev@poi.apache.org Subject: [Bug 58098] New: NPE at NPOIFSFileSystem. Date: Fri, 03 Jul 2015 10:14:46 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: POI X-Bugzilla-Component: POIFS X-Bugzilla-Version: 3.12-FINAL X-Bugzilla-Keywords: X-Bugzilla-Severity: minor X-Bugzilla-Who: tcavaleiro@gmail.com X-Bugzilla-Status: NEW X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: dev@poi.apache.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: https://bz.apache.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 https://bz.apache.org/bugzilla/show_bug.cgi?id=58098 Bug ID: 58098 Summary: NPE at NPOIFSFileSystem. Product: POI Version: 3.12-FINAL Hardware: PC Status: NEW Severity: minor Priority: P2 Component: POIFS Assignee: dev@poi.apache.org Reporter: tcavaleiro@gmail.com An NPE is being throw when opening a XLSX file that is currently opened by Excel (write mode). On my opinion it should throw the java.io.FileNotFoundException instead. Stacktrace: Exception in thread "main" java.lang.NullPointerException at org.apache.poi.poifs.filesystem.NPOIFSFileSystem.(NPOIFSFileSystem.java:235) at org.apache.poi.poifs.filesystem.NPOIFSFileSystem.(NPOIFSFileSystem.java:165) at xxxxxx.CloseableWorkbook.create(CloseableWorkbook.java:271) at xxxxxx.ReadExcel.main(ReadExcel.java:29) Issue story description: NPOIFSFileSystem first tries to open the file and then gets an java.io.FileNotFoundException: (....).xlsx (The process cannot access the file because it is being used by another process) however since there is no null check on the channel it gets an NPE. Class NPOIFSFileSystem should be modified to check for channel first... private NPOIFSFileSystem(FileChannel channel, File srcFile, boolean readOnly, boolean closeChannelOnError) throws IOException { (...) // try } catch(IOException e) { if(closeChannelOnError && channel != null) { channel.close(); } throw e; (...) PS: Actually the null check if being done when handling RuntimeException. -- You are receiving this mail because: You are the assignee for the bug. --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org For additional commands, e-mail: dev-help@poi.apache.org