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 2023/12/29 18:38:03 UTC
(maven-plugin-tools) 01/02: Prevent NPE
This is an automated email from the ASF dual-hosted git repository.
michaelo pushed a commit to branch MPLUGIN-495
in repository https://gitbox.apache.org/repos/asf/maven-plugin-tools.git
commit 0be04c0dd10886e223d50af32759b58c99d4e47c
Author: Michael Osipov <mi...@apache.org>
AuthorDate: Fri Dec 29 19:37:44 2023 +0100
Prevent NPE
---
.../plugin/descriptor/EnhancedPluginDescriptorBuilder.java | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/maven-plugin-report-plugin/src/main/java/org/apache/maven/plugins/plugin/descriptor/EnhancedPluginDescriptorBuilder.java b/maven-plugin-report-plugin/src/main/java/org/apache/maven/plugins/plugin/descriptor/EnhancedPluginDescriptorBuilder.java
index c9e30570..6d3d2108 100644
--- a/maven-plugin-report-plugin/src/main/java/org/apache/maven/plugins/plugin/descriptor/EnhancedPluginDescriptorBuilder.java
+++ b/maven-plugin-report-plugin/src/main/java/org/apache/maven/plugins/plugin/descriptor/EnhancedPluginDescriptorBuilder.java
@@ -21,9 +21,11 @@ package org.apache.maven.plugins.plugin.descriptor;
import java.io.Reader;
import java.net.URI;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
+import java.util.Optional;
import org.apache.maven.plugin.descriptor.MojoDescriptor;
import org.apache.maven.plugin.descriptor.Parameter;
@@ -87,7 +89,7 @@ public class EnhancedPluginDescriptorBuilder extends PluginDescriptorBuilder {
PlexusConfiguration[] parameterConfigurations = c.getChild("parameters").getChildren("parameter");
- List<Parameter> parameters = new ArrayList<>(mojoDescriptor.getParameters());
+ List<Parameter> parameters = new ArrayList<>(Optional.ofNullable(mojoDescriptor.getParameters()).orElseGet(Collections::emptyList));
Map<String, Parameter> parameterMap = new LinkedHashMap<>(mojoDescriptor.getParameterMap());
for (PlexusConfiguration d : parameterConfigurations) {
@@ -108,7 +110,9 @@ public class EnhancedPluginDescriptorBuilder extends PluginDescriptorBuilder {
}
// clear() is required for maven < 3.6.2
- mojoDescriptor.getParameters().clear();
+ if (mojoDescriptor.getParameters() != null) {
+ mojoDescriptor.getParameters().clear();
+ }
// set parameters
mojoDescriptor.setParameters(parameters);
// on maven < 3.6.2, getParameterMap is kept internally in a field