From 0bfec136dbcc219aa8fef9d0501998eefa705ff5 Mon Sep 17 00:00:00 2001 From: Benjamin Bentmann Date: Thu, 18 Nov 2010 19:28:53 +0000 Subject: [PATCH] [MNG-4904] Make MavenExecutionResult.getTopologicallySortedProjects() return empty list instead of null Submitted by: Basil James Whitehouse III git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@1036585 13f79535-47bb-0310-9956-ffa450edef68 --- .../execution/DefaultMavenExecutionResult.java | 2 +- .../maven/execution/MavenExecutionResult.java | 4 ++++ .../maven/execution/DefaultMavenExecutionTest.java | 13 +++++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionResult.java b/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionResult.java index bdb4532a54..c00628319c 100644 --- a/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionResult.java +++ b/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionResult.java @@ -63,7 +63,7 @@ public class DefaultMavenExecutionResult public List getTopologicallySortedProjects() { - return topologicallySortedProjects; + return null == topologicallySortedProjects ? Collections. emptyList() : topologicallySortedProjects; } public DependencyResolutionResult getDependencyResolutionResult() diff --git a/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionResult.java b/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionResult.java index 15ce3e75d1..dd0466567a 100644 --- a/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionResult.java +++ b/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionResult.java @@ -33,6 +33,10 @@ public interface MavenExecutionResult MavenProject getProject(); MavenExecutionResult setTopologicallySortedProjects( List projects ); + + /** + * @return the sorted list, or an empty list if there are no projects. + */ List getTopologicallySortedProjects(); MavenExecutionResult setDependencyResolutionResult( DependencyResolutionResult result ); diff --git a/maven-core/src/test/java/org/apache/maven/execution/DefaultMavenExecutionTest.java b/maven-core/src/test/java/org/apache/maven/execution/DefaultMavenExecutionTest.java index 99d55eafba..698c6d1514 100644 --- a/maven-core/src/test/java/org/apache/maven/execution/DefaultMavenExecutionTest.java +++ b/maven-core/src/test/java/org/apache/maven/execution/DefaultMavenExecutionTest.java @@ -19,6 +19,10 @@ package org.apache.maven.execution; * under the License. */ +import org.apache.maven.project.MavenProject; + +import java.util.List; + import junit.framework.TestCase; /** @@ -35,5 +39,14 @@ public class DefaultMavenExecutionTest assertNotNull( copy ); assertNotSame( copy, original ); } + + public void testResultWithNullTopologicallySortedProjectsIsEmptyList() + { + MavenExecutionResult result = new DefaultMavenExecutionResult(); + result.setTopologicallySortedProjects( null ); + List projects = result.getTopologicallySortedProjects(); + assertNotNull( projects ); + assertTrue( projects.isEmpty() ); + } }