From ade2e359214c4094876b0100c97b9a55aecc4c2e Mon Sep 17 00:00:00 2001 From: Tamas Cservenak Date: Tue, 28 May 2024 14:24:55 +0200 Subject: [PATCH] [MSHADE-428] Prevent null value in array of transformers (#229) As Plexus will silently add it as explain it in issue. This fix merely improves user experience, but not throwing cryptic or totally misleading errors. --- https://issues.apache.org/jira/browse/MSHADE-428 --- .../org/apache/maven/plugins/shade/mojo/ShadeMojo.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java b/src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java index 5d171b38..cabc861c 100644 --- a/src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java +++ b/src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java @@ -915,11 +915,16 @@ private List getRelocators() { return relocators; } - private List getResourceTransformers() { + private List getResourceTransformers() throws MojoExecutionException { if (transformers == null) { return Collections.emptyList(); } - + for (ResourceTransformer transformer : transformers) { + if (transformer == null) { + throw new MojoExecutionException( + "Failed to create shaded artifact: parameter transformers contains null (double-check XML attribute)"); + } + } return Arrays.asList(transformers); }