You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by el...@apache.org on 2020/11/14 13:25:35 UTC
[maven-dependency-plugin] 01/01: split these out one dereference
per statement to narrow down a null pointer exception
This is an automated email from the ASF dual-hosted git repository.
elharo pushed a commit to branch npe2
in repository https://gitbox.apache.org/repos/asf/maven-dependency-plugin.git
commit d3141e44772eecfcf781a95480eda989173ad222
Author: Elliotte Harold <el...@ibiblio.org>
AuthorDate: Sat Nov 14 08:25:12 2020 -0500
split these out one dereference per statement to narrow down a null pointer exception
---
.../dependency/tree/VerboseDependencyGraphBuilder.java | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/src/main/java/org/apache/maven/plugins/dependency/tree/VerboseDependencyGraphBuilder.java b/src/main/java/org/apache/maven/plugins/dependency/tree/VerboseDependencyGraphBuilder.java
index 44881cc..610fb0f 100644
--- a/src/main/java/org/apache/maven/plugins/dependency/tree/VerboseDependencyGraphBuilder.java
+++ b/src/main/java/org/apache/maven/plugins/dependency/tree/VerboseDependencyGraphBuilder.java
@@ -160,14 +160,18 @@ class VerboseDependencyGraphBuilder
node.setArtifact( node.getArtifact().setVersion( manager.getVersion() ) );
}
- if ( !manager.getScope().equals( node.getDependency().getScope() ) )
+ // split these out one dereference per statement to narrow down a null pointer exception
+ String managerScope = manager.getScope();
+ Dependency dependency = node.getDependency();
+ String dependencyScope = dependency.getScope();
+ if ( !managerScope.equals( dependencyScope ) )
{
- artifactProperties.put( PRE_MANAGED_SCOPE, node.getDependency().getScope() );
+ artifactProperties.put( PRE_MANAGED_SCOPE, dependencyScope );
// be aware this does not actually change the node's scope, it may need to be fixed in the future
- artifactProperties.put( MANAGED_SCOPE, manager.getScope() );
+ artifactProperties.put( MANAGED_SCOPE, managerScope );
}
node.setArtifact( node.getArtifact().setProperties( artifactProperties ) );
- node.getDependency().setArtifact( node.getDependency().getArtifact().setProperties( artifactProperties ) );
+ dependency.setArtifact( dependency.getArtifact().setProperties( artifactProperties ) );
}
for ( DependencyNode child : node.getChildren() )
{