Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 9FFAF200BE9 for ; Sun, 11 Dec 2016 09:51:01 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 9D048160B07; Sun, 11 Dec 2016 08:51:01 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id ED5D0160B20 for ; Sun, 11 Dec 2016 09:51:00 +0100 (CET) Received: (qmail 34225 invoked by uid 500); 11 Dec 2016 08:51:00 -0000 Mailing-List: contact notifications-help@ant.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ant.apache.org Delivered-To: mailing list notifications@ant.apache.org Received: (qmail 34133 invoked by uid 99); 11 Dec 2016 08:51:00 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 11 Dec 2016 08:51:00 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id E69512C0087 for ; Sun, 11 Dec 2016 08:50:59 +0000 (UTC) Date: Sun, 11 Dec 2016 08:50:59 +0000 (UTC) From: "ASF GitHub Bot (JIRA)" To: notifications@ant.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (IVY-1482) NPE in XmlReportOutputter MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Sun, 11 Dec 2016 08:51:01 -0000 [ https://issues.apache.org/jira/browse/IVY-1482?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15739376#comment-15739376 ] ASF GitHub Bot commented on IVY-1482: ------------------------------------- GitHub user jaikiran opened a pull request: https://github.com/apache/ant-ivy/pull/12 IVY-1482 Fix potential NPE in XmlReportOutputter The commit here adds a null check to prevent potential NPE reported in JIRA https://issues.apache.org/jira/browse/IVY-1482 You can merge this pull request into a Git repository by running: $ git pull https://github.com/jaikiran/ant-ivy ivy-1482 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/ant-ivy/pull/12.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #12 ---- commit 0dc25d1d378861f2528b3de655afbced7c2f5a06 Author: Jaikiran Pai Date: 2016-12-11T08:48:37Z IVY-1482 Fix potential NPE in XmlReportOutputter ---- > NPE in XmlReportOutputter > ------------------------- > > Key: IVY-1482 > URL: https://issues.apache.org/jira/browse/IVY-1482 > Project: Ivy > Issue Type: Bug > Components: Core > Affects Versions: 2.4.0-RC1 > Reporter: M Kim > > {code} > public void output(ConfigurationResolveReport report, String resolveId, String[] confs, ResolutionCacheManager cacheMgr) throws IOException { > File reportFile = cacheMgr.getConfigurationResolveReportInCache(resolveId, > report.getConfiguration()); > File reportParentDir = reportFile.getParentFile(); > reportParentDir.mkdirs(); // NPE > OutputStream stream = new FileOutputStream(reportFile); > writer.output(report, confs, stream); > stream.close(); > //... > } > {code} > In XmlReportOutputter.output method, NPE occurs when reportFile.getParentFile() returns null. I think a proper error handling is needed for reportFile and reportParentDir before OutputStream is created. > > {code} > public void test1() { > Ivy14 ivy = new org.apache.ivy.Ivy14(); > ManifestHeaderElement header = new ManifestHeaderElement(); > ModuleRevisionId resolveId = ModuleRevisionId.newInstance("", "ISO-8859-1", "default", "default", header.getAttributes(), true); > Pack200Packing pack = new Pack200Packing(); > String[] strings = pack.getNames(); > ResolveReport report = ivy.resolve(resolveId, strings); > ResolveOptions options = new ResolveOptions(); > report.output(new ReportOutputter[]{new XmlReportOutputter()}, (ResolutionCacheManager)new DefaultResolutionCacheManager(), options.setResolveId("latest-revision").setOutputReport(true)); > } > {code} > > {code} > 1) test1(Test0)java.lang.NullPointerException > at org.apache.ivy.plugins.report.XmlReportOutputter.output(XmlReportOutputter.java:56) > at org.apache.ivy.plugins.report.XmlReportOutputter.output(XmlReportOutputter.java:47) > at org.apache.ivy.core.report.ResolveReport.output(ResolveReport.java:106) > at Test0.test1(Test0.java:48) > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)