55 lines
2.8 KiB
Diff
55 lines
2.8 KiB
Diff
From 3b214255464d5baca5ee26a897cd9afca53e52c3 Mon Sep 17 00:00:00 2001
|
|
From: Mikolaj Izdebski <mizdebsk@redhat.com>
|
|
Date: Thu, 26 Nov 2015 14:18:48 +0100
|
|
Subject: [PATCH 2/2] Try to procect builddep MOJO against patological cases
|
|
|
|
- Clone model before processing it to avoid
|
|
UnsupportedOperationException (rhbz#1276729).
|
|
- Guard against NullPointerException.
|
|
- Inject a deep copy of resolutions to avoid
|
|
ConcurrentModificationException.
|
|
---
|
|
.../xmvn/connector/aether/XMvnMojoExecutionListener.java | 2 +-
|
|
.../src/main/java/org/fedoraproject/xmvn/mojo/BuilddepMojo.java | 5 ++++-
|
|
2 files changed, 5 insertions(+), 2 deletions(-)
|
|
|
|
diff --git a/xmvn-connector-aether/src/main/java/org/fedoraproject/xmvn/connector/aether/XMvnMojoExecutionListener.java b/xmvn-connector-aether/src/main/java/org/fedoraproject/xmvn/connector/aether/XMvnMojoExecutionListener.java
|
|
index 16f30db..7adfe44 100644
|
|
--- a/xmvn-connector-aether/src/main/java/org/fedoraproject/xmvn/connector/aether/XMvnMojoExecutionListener.java
|
|
+++ b/xmvn-connector-aether/src/main/java/org/fedoraproject/xmvn/connector/aether/XMvnMojoExecutionListener.java
|
|
@@ -222,7 +222,7 @@ public class XMvnMojoExecutionListener
|
|
for ( BeanProperty<Object> property : new BeanProperties( mojo.getClass() ) )
|
|
{
|
|
if ( property.getName().equals( "resolutions" ) )
|
|
- property.set( mojo, Collections.unmodifiableList( resolutions ) );
|
|
+ property.set( mojo, Collections.unmodifiableList( new ArrayList<>( resolutions ) ) );
|
|
}
|
|
}
|
|
}
|
|
diff --git a/xmvn-mojo/src/main/java/org/fedoraproject/xmvn/mojo/BuilddepMojo.java b/xmvn-mojo/src/main/java/org/fedoraproject/xmvn/mojo/BuilddepMojo.java
|
|
index 8bbdf5f..dd6a8f5 100644
|
|
--- a/xmvn-mojo/src/main/java/org/fedoraproject/xmvn/mojo/BuilddepMojo.java
|
|
+++ b/xmvn-mojo/src/main/java/org/fedoraproject/xmvn/mojo/BuilddepMojo.java
|
|
@@ -139,7 +139,7 @@ public class BuilddepMojo
|
|
Set<Artifact> artifacts = new LinkedHashSet<>();
|
|
for ( MavenProject project : reactorProjects )
|
|
{
|
|
- Model model = project.getModel();
|
|
+ Model model = project.getModel().clone();
|
|
String modelId = model.getLocation( "" ).getSource().getModelId();
|
|
BuildDependencyVisitor visitor = new BuildDependencyVisitor( modelId );
|
|
modelProcessor.processModel( model, visitor );
|
|
@@ -149,6 +149,9 @@ public class BuilddepMojo
|
|
Set<NamespacedArtifact> deps = new LinkedHashSet<>();
|
|
for ( String[] resolution : resolutions )
|
|
{
|
|
+ if ( resolution == null )
|
|
+ continue;
|
|
+
|
|
Artifact artifact = new DefaultArtifact( resolution[0] );
|
|
String compatVersion = resolution[1];
|
|
String namespace = resolution[2];
|
|
--
|
|
2.5.0
|
|
|