You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by mi...@apache.org on 2018/03/18 22:40:38 UTC

[maven-help-plugin] branch master updated: [MPH-135] help:effective-pom crashes with NPE in multi module builds with -Doutput set

This is an automated email from the ASF dual-hosted git repository.

michaelo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-help-plugin.git


The following commit(s) were added to refs/heads/master by this push:
     new 9f6e0e6  [MPH-135] help:effective-pom crashes with NPE in multi module builds with -Doutput set
9f6e0e6 is described below

commit 9f6e0e637cb4199ee9dab7291b8ff0fa6a8dccd7
Author: Michael Osipov <mi...@apache.org>
AuthorDate: Sun Mar 18 20:52:55 2018 +0100

    [MPH-135] help:effective-pom crashes with NPE in multi module builds with -Doutput set
    
    Explicitly check for null in encoding because JDOM's API design *does* permit
    nulls here, but expects the value never to be null.
---
 .../java/org/apache/maven/plugins/help/AbstractEffectiveMojo.java   | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/maven/plugins/help/AbstractEffectiveMojo.java b/src/main/java/org/apache/maven/plugins/help/AbstractEffectiveMojo.java
index 91301a0..2f38dfe 100644
--- a/src/main/java/org/apache/maven/plugins/help/AbstractEffectiveMojo.java
+++ b/src/main/java/org/apache/maven/plugins/help/AbstractEffectiveMojo.java
@@ -134,7 +134,11 @@ public abstract class AbstractEffectiveMojo
 
             StringWriter w = new StringWriter();
             Format format = Format.getPrettyFormat();
-            format.setEncoding( encoding );
+            if ( encoding != null )
+            {
+                // This is a design flaw in JDOM, no NPE on null arguments, but null is not prohibited
+                format.setEncoding( encoding );
+            }
             format.setLineSeparator( System.lineSeparator() );
             XMLOutputter out = new XMLOutputter( format );
             out.output( effectiveDocument, w );

-- 
To stop receiving notification emails like this one, please contact
michaelo@apache.org.