maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From schu...@apache.org
Subject maven git commit: Updated to ensure collections are immutable consistently.
Date Mon, 14 Dec 2015 04:53:25 GMT
Repository: maven
Updated Branches:
  refs/heads/master ab130cf9f -> c7e9e4489


Updated to ensure collections are immutable consistently.


Project: http://git-wip-us.apache.org/repos/asf/maven/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven/commit/c7e9e448
Tree: http://git-wip-us.apache.org/repos/asf/maven/tree/c7e9e448
Diff: http://git-wip-us.apache.org/repos/asf/maven/diff/c7e9e448

Branch: refs/heads/master
Commit: c7e9e44893c2938cbb8026d01fbeff51d7f825f7
Parents: ab130cf
Author: Christian Schulte <schulte@apache.org>
Authored: Mon Dec 14 05:51:40 2015 +0100
Committer: Christian Schulte <schulte@apache.org>
Committed: Mon Dec 14 05:51:40 2015 +0100

----------------------------------------------------------------------
 .../apache/maven/artifact/DefaultArtifact.java  |  2 +-
 .../maven/artifact/versioning/VersionRange.java |  2 +-
 .../repository/DefaultArtifactRepository.java   |  2 +-
 .../repository/MetadataResolutionResult.java    | 27 ++++++++++++++------
 .../repository/MavenArtifactRepository.java     |  2 +-
 .../resolver/ArtifactResolutionResult.java      | 27 ++++++++++++++------
 .../maven/artifact/resolver/ResolutionNode.java |  1 +
 .../maven/exception/ExceptionSummary.java       |  5 +++-
 .../execution/DefaultMavenExecutionResult.java  |  6 +++--
 .../maven/lifecycle/internal/MojoExecutor.java  | 18 +++++++------
 .../internal/DefaultMavenPluginManager.java     |  2 +-
 .../prefix/DefaultPluginPrefixRequest.java      |  4 +--
 .../version/DefaultPluginVersionRequest.java    |  2 +-
 .../DefaultDependencyResolutionResult.java      |  5 +++-
 .../maven/project/DefaultProjectRealmCache.java |  4 ++-
 .../org/apache/maven/project/MavenProject.java  | 19 +++++++-------
 .../maven/project/artifact/ProjectArtifact.java |  5 +++-
 .../java/org/apache/maven/cli/MavenCli.java     |  4 ++-
 .../model/building/ModelBuildingException.java  |  2 +-
 19 files changed, 89 insertions(+), 50 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven/blob/c7e9e448/maven-artifact/src/main/java/org/apache/maven/artifact/DefaultArtifact.java
----------------------------------------------------------------------
diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/DefaultArtifact.java b/maven-artifact/src/main/java/org/apache/maven/artifact/DefaultArtifact.java
index 147e88e..675f1d9 100644
--- a/maven-artifact/src/main/java/org/apache/maven/artifact/DefaultArtifact.java
+++ b/maven-artifact/src/main/java/org/apache/maven/artifact/DefaultArtifact.java
@@ -272,7 +272,7 @@ public class DefaultArtifact
             return Collections.emptyList();
         }
 
-        return metadataMap.values();
+        return Collections.unmodifiableCollection( metadataMap.values() );
     }
 
     // ----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/maven/blob/c7e9e448/maven-artifact/src/main/java/org/apache/maven/artifact/versioning/VersionRange.java
----------------------------------------------------------------------
diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/versioning/VersionRange.java
b/maven-artifact/src/main/java/org/apache/maven/artifact/versioning/VersionRange.java
index 0d094ef..7ee854f 100644
--- a/maven-artifact/src/main/java/org/apache/maven/artifact/versioning/VersionRange.java
+++ b/maven-artifact/src/main/java/org/apache/maven/artifact/versioning/VersionRange.java
@@ -261,7 +261,7 @@ public class VersionRange
         }
         else
         {
-            restrictions = intersection( r1, r2 );
+            restrictions = Collections.unmodifiableList( intersection( r1, r2 ) );
         }
 
         ArtifactVersion version = null;

http://git-wip-us.apache.org/repos/asf/maven/blob/c7e9e448/maven-compat/src/main/java/org/apache/maven/artifact/repository/DefaultArtifactRepository.java
----------------------------------------------------------------------
diff --git a/maven-compat/src/main/java/org/apache/maven/artifact/repository/DefaultArtifactRepository.java
b/maven-compat/src/main/java/org/apache/maven/artifact/repository/DefaultArtifactRepository.java
index e0a5587..34d4222 100644
--- a/maven-compat/src/main/java/org/apache/maven/artifact/repository/DefaultArtifactRepository.java
+++ b/maven-compat/src/main/java/org/apache/maven/artifact/repository/DefaultArtifactRepository.java
@@ -256,7 +256,7 @@ public class DefaultArtifactRepository
     {
         if ( mirroredRepositories != null )
         {
-            this.mirroredRepositories = mirroredRepositories;
+            this.mirroredRepositories = Collections.unmodifiableList( mirroredRepositories
);
         }
         else
         {

http://git-wip-us.apache.org/repos/asf/maven/blob/c7e9e448/maven-compat/src/main/java/org/apache/maven/repository/MetadataResolutionResult.java
----------------------------------------------------------------------
diff --git a/maven-compat/src/main/java/org/apache/maven/repository/MetadataResolutionResult.java
b/maven-compat/src/main/java/org/apache/maven/repository/MetadataResolutionResult.java
index cfdd7f9..bc42637 100644
--- a/maven-compat/src/main/java/org/apache/maven/repository/MetadataResolutionResult.java
+++ b/maven-compat/src/main/java/org/apache/maven/repository/MetadataResolutionResult.java
@@ -118,7 +118,10 @@ public class MetadataResolutionResult
 
     public List<Artifact> getMissingArtifacts()
     {
-        return missingArtifacts == null ? Collections.<Artifact> emptyList() : missingArtifacts;
+        return missingArtifacts == null
+                   ? Collections.<Artifact>emptyList()
+                   : Collections.unmodifiableList( missingArtifacts );
+
     }
 
     public MetadataResolutionResult addMissingArtifact( Artifact artifact )
@@ -148,7 +151,10 @@ public class MetadataResolutionResult
 
     public List<Exception> getExceptions()
     {
-        return exceptions == null ? Collections.<Exception> emptyList() : exceptions;
+        return exceptions == null
+                   ? Collections.<Exception>emptyList()
+                   : Collections.unmodifiableList( exceptions );
+
     }
 
     // ------------------------------------------------------------------------
@@ -185,7 +191,10 @@ public class MetadataResolutionResult
 
     public List<Exception> getVersionRangeViolations()
     {
-        return versionRangeViolations == null ? Collections.<Exception> emptyList()
: versionRangeViolations;
+        return versionRangeViolations == null
+                   ? Collections.<Exception>emptyList()
+                   : Collections.unmodifiableList( versionRangeViolations );
+
     }
 
     // ------------------------------------------------------------------------
@@ -217,8 +226,10 @@ public class MetadataResolutionResult
 
     public List<ArtifactResolutionException> getMetadataResolutionExceptions()
     {
-        return metadataResolutionExceptions == null ? Collections.<ArtifactResolutionException>
emptyList()
-                        : metadataResolutionExceptions;
+        return metadataResolutionExceptions == null
+                   ? Collections.<ArtifactResolutionException>emptyList()
+                   : Collections.unmodifiableList( metadataResolutionExceptions );
+
     }
 
     // ------------------------------------------------------------------------
@@ -246,7 +257,7 @@ public class MetadataResolutionResult
             return Collections.emptyList();
         }
 
-        return errorArtifactExceptions;
+        return Collections.unmodifiableList( errorArtifactExceptions );
     }
 
     // ------------------------------------------------------------------------
@@ -283,7 +294,7 @@ public class MetadataResolutionResult
             return Collections.emptyList();
         }
 
-        return circularDependencyExceptions;
+        return Collections.unmodifiableList( circularDependencyExceptions );
     }
 
     // ------------------------------------------------------------------------
@@ -297,7 +308,7 @@ public class MetadataResolutionResult
             return Collections.emptyList();
         }
 
-        return repositories;
+        return Collections.unmodifiableList( repositories );
     }
 
     public MetadataResolutionResult setRepositories( final List<ArtifactRepository>
repositories )

http://git-wip-us.apache.org/repos/asf/maven/blob/c7e9e448/maven-core/src/main/java/org/apache/maven/artifact/repository/MavenArtifactRepository.java
----------------------------------------------------------------------
diff --git a/maven-core/src/main/java/org/apache/maven/artifact/repository/MavenArtifactRepository.java
b/maven-core/src/main/java/org/apache/maven/artifact/repository/MavenArtifactRepository.java
index 8e45b20..59a9ba5 100644
--- a/maven-core/src/main/java/org/apache/maven/artifact/repository/MavenArtifactRepository.java
+++ b/maven-core/src/main/java/org/apache/maven/artifact/repository/MavenArtifactRepository.java
@@ -401,7 +401,7 @@ public class MavenArtifactRepository
     {
         if ( mirroredRepositories != null )
         {
-            this.mirroredRepositories = mirroredRepositories;
+            this.mirroredRepositories = Collections.unmodifiableList( mirroredRepositories
);
         }
         else
         {

http://git-wip-us.apache.org/repos/asf/maven/blob/c7e9e448/maven-core/src/main/java/org/apache/maven/artifact/resolver/ArtifactResolutionResult.java
----------------------------------------------------------------------
diff --git a/maven-core/src/main/java/org/apache/maven/artifact/resolver/ArtifactResolutionResult.java
b/maven-core/src/main/java/org/apache/maven/artifact/resolver/ArtifactResolutionResult.java
index 7795dec..8ce418a 100644
--- a/maven-core/src/main/java/org/apache/maven/artifact/resolver/ArtifactResolutionResult.java
+++ b/maven-core/src/main/java/org/apache/maven/artifact/resolver/ArtifactResolutionResult.java
@@ -125,7 +125,10 @@ public class ArtifactResolutionResult
 
     public List<Artifact> getMissingArtifacts()
     {
-        return missingArtifacts == null ? Collections.<Artifact>emptyList() : missingArtifacts;
+        return missingArtifacts == null
+                   ? Collections.<Artifact>emptyList()
+                   : Collections.unmodifiableList( missingArtifacts );
+
     }
 
     public ArtifactResolutionResult addMissingArtifact( Artifact artifact )
@@ -160,7 +163,10 @@ public class ArtifactResolutionResult
 
     public List<Exception> getExceptions()
     {
-        return exceptions == null ? Collections.<Exception>emptyList() : exceptions;
+        return exceptions == null
+                   ? Collections.<Exception>emptyList()
+                   : Collections.unmodifiableList( exceptions );
+
     }
 
     // ------------------------------------------------------------------------
@@ -197,7 +203,10 @@ public class ArtifactResolutionResult
 
     public List<Exception> getVersionRangeViolations()
     {
-        return versionRangeViolations == null ? Collections.<Exception>emptyList()
: versionRangeViolations;
+        return versionRangeViolations == null
+                   ? Collections.<Exception>emptyList()
+                   : Collections.unmodifiableList( versionRangeViolations );
+
     }
 
     // ------------------------------------------------------------------------
@@ -229,8 +238,10 @@ public class ArtifactResolutionResult
 
     public List<ArtifactResolutionException> getMetadataResolutionExceptions()
     {
-        return metadataResolutionExceptions == null ? Collections.<ArtifactResolutionException>emptyList()
-                        : metadataResolutionExceptions;
+        return metadataResolutionExceptions == null
+                   ? Collections.<ArtifactResolutionException>emptyList()
+                   : Collections.unmodifiableList( metadataResolutionExceptions );
+
     }
 
     // ------------------------------------------------------------------------
@@ -262,7 +273,7 @@ public class ArtifactResolutionResult
             return Collections.emptyList();
         }
 
-        return errorArtifactExceptions;
+        return Collections.unmodifiableList( errorArtifactExceptions );
     }
 
     // ------------------------------------------------------------------------
@@ -299,7 +310,7 @@ public class ArtifactResolutionResult
             return Collections.emptyList();
         }
 
-        return circularDependencyExceptions;
+        return Collections.unmodifiableList( circularDependencyExceptions );
     }
 
     // ------------------------------------------------------------------------
@@ -313,7 +324,7 @@ public class ArtifactResolutionResult
             return Collections.emptyList();
         }
 
-        return repositories;
+        return Collections.unmodifiableList( repositories );
     }
 
     public ArtifactResolutionResult setRepositories( final List<ArtifactRepository>
repositories )

http://git-wip-us.apache.org/repos/asf/maven/blob/c7e9e448/maven-core/src/main/java/org/apache/maven/artifact/resolver/ResolutionNode.java
----------------------------------------------------------------------
diff --git a/maven-core/src/main/java/org/apache/maven/artifact/resolver/ResolutionNode.java
b/maven-core/src/main/java/org/apache/maven/artifact/resolver/ResolutionNode.java
index 5651641..cb7e9cf 100644
--- a/maven-core/src/main/java/org/apache/maven/artifact/resolver/ResolutionNode.java
+++ b/maven-core/src/main/java/org/apache/maven/artifact/resolver/ResolutionNode.java
@@ -99,6 +99,7 @@ public class ResolutionNode
 
                 children.add( new ResolutionNode( a, remoteRepositories, this ) );
             }
+            children = Collections.unmodifiableList( children );
         }
         else
         {

http://git-wip-us.apache.org/repos/asf/maven/blob/c7e9e448/maven-core/src/main/java/org/apache/maven/exception/ExceptionSummary.java
----------------------------------------------------------------------
diff --git a/maven-core/src/main/java/org/apache/maven/exception/ExceptionSummary.java b/maven-core/src/main/java/org/apache/maven/exception/ExceptionSummary.java
index dcc376a..6615af6 100644
--- a/maven-core/src/main/java/org/apache/maven/exception/ExceptionSummary.java
+++ b/maven-core/src/main/java/org/apache/maven/exception/ExceptionSummary.java
@@ -53,7 +53,10 @@ public class ExceptionSummary
         this.exception = exception;
         this.message = ( message != null ) ? message : "";
         this.reference = ( reference != null ) ? reference : "";
-        this.children = ( children != null ) ? children : Collections.<ExceptionSummary>emptyList();
+        this.children = ( children != null )
+                            ? Collections.unmodifiableList( children )
+                            : Collections.<ExceptionSummary>emptyList();
+
     }
 
     public Throwable getException()

http://git-wip-us.apache.org/repos/asf/maven/blob/c7e9e448/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionResult.java
----------------------------------------------------------------------
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 87d8676..112a064 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
@@ -64,8 +64,10 @@ public class DefaultMavenExecutionResult
 
     public List<MavenProject> getTopologicallySortedProjects()
     {
-        return null == topologicallySortedProjects ? Collections.<MavenProject>emptyList()
-                        : topologicallySortedProjects;
+        return null == topologicallySortedProjects
+                   ? Collections.<MavenProject>emptyList()
+                   : Collections.unmodifiableList( topologicallySortedProjects );
+
     }
 
     public DependencyResolutionResult getDependencyResolutionResult()

http://git-wip-us.apache.org/repos/asf/maven/blob/c7e9e448/maven-core/src/main/java/org/apache/maven/lifecycle/internal/MojoExecutor.java
----------------------------------------------------------------------
diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/MojoExecutor.java
b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/MojoExecutor.java
index 2e4c117..8524c5e 100644
--- a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/MojoExecutor.java
+++ b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/MojoExecutor.java
@@ -104,32 +104,34 @@ public class MojoExecutor
 
     private Collection<String> toScopes( String classpath )
     {
+        Collection<String> scopes = Collections.emptyList();
+
         if ( StringUtils.isNotEmpty( classpath ) )
         {
             if ( Artifact.SCOPE_COMPILE.equals( classpath ) )
             {
-                return Arrays.asList( Artifact.SCOPE_COMPILE, Artifact.SCOPE_SYSTEM, Artifact.SCOPE_PROVIDED
);
+                scopes = Arrays.asList( Artifact.SCOPE_COMPILE, Artifact.SCOPE_SYSTEM, Artifact.SCOPE_PROVIDED
);
             }
             else if ( Artifact.SCOPE_RUNTIME.equals( classpath ) )
             {
-                return Arrays.asList( Artifact.SCOPE_COMPILE, Artifact.SCOPE_RUNTIME );
+                scopes = Arrays.asList( Artifact.SCOPE_COMPILE, Artifact.SCOPE_RUNTIME );
             }
             else if ( Artifact.SCOPE_COMPILE_PLUS_RUNTIME.equals( classpath ) )
             {
-                return Arrays.asList( Artifact.SCOPE_COMPILE, Artifact.SCOPE_SYSTEM, Artifact.SCOPE_PROVIDED,
-                                      Artifact.SCOPE_RUNTIME );
+                scopes = Arrays.asList( Artifact.SCOPE_COMPILE, Artifact.SCOPE_SYSTEM, Artifact.SCOPE_PROVIDED,
+                                        Artifact.SCOPE_RUNTIME );
             }
             else if ( Artifact.SCOPE_RUNTIME_PLUS_SYSTEM.equals( classpath ) )
             {
-                return Arrays.asList( Artifact.SCOPE_COMPILE, Artifact.SCOPE_SYSTEM, Artifact.SCOPE_RUNTIME
);
+                scopes = Arrays.asList( Artifact.SCOPE_COMPILE, Artifact.SCOPE_SYSTEM, Artifact.SCOPE_RUNTIME
);
             }
             else if ( Artifact.SCOPE_TEST.equals( classpath ) )
             {
-                return Arrays.asList( Artifact.SCOPE_COMPILE, Artifact.SCOPE_SYSTEM, Artifact.SCOPE_PROVIDED,
-                                      Artifact.SCOPE_RUNTIME, Artifact.SCOPE_TEST );
+                scopes = Arrays.asList( Artifact.SCOPE_COMPILE, Artifact.SCOPE_SYSTEM, Artifact.SCOPE_PROVIDED,
+                                        Artifact.SCOPE_RUNTIME, Artifact.SCOPE_TEST );
             }
         }
-        return Collections.emptyList();
+        return Collections.unmodifiableCollection( scopes );
     }
 
     public void execute( MavenSession session, List<MojoExecution> mojoExecutions,
ProjectIndex projectIndex )

http://git-wip-us.apache.org/repos/asf/maven/blob/c7e9e448/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultMavenPluginManager.java
----------------------------------------------------------------------
diff --git a/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultMavenPluginManager.java
b/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultMavenPluginManager.java
index b87994e..bad1454 100644
--- a/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultMavenPluginManager.java
+++ b/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultMavenPluginManager.java
@@ -458,7 +458,7 @@ public class DefaultMavenPluginManager
                 it.remove();
             }
         }
-        return artifacts;
+        return Collections.unmodifiableList( artifacts );
     }
 
     private Map<String, ClassLoader> calcImports( MavenProject project, ClassLoader
parent, List<String> imports )

http://git-wip-us.apache.org/repos/asf/maven/blob/c7e9e448/maven-core/src/main/java/org/apache/maven/plugin/prefix/DefaultPluginPrefixRequest.java
----------------------------------------------------------------------
diff --git a/maven-core/src/main/java/org/apache/maven/plugin/prefix/DefaultPluginPrefixRequest.java
b/maven-core/src/main/java/org/apache/maven/plugin/prefix/DefaultPluginPrefixRequest.java
index 7ab86cf..01194c8 100644
--- a/maven-core/src/main/java/org/apache/maven/plugin/prefix/DefaultPluginPrefixRequest.java
+++ b/maven-core/src/main/java/org/apache/maven/plugin/prefix/DefaultPluginPrefixRequest.java
@@ -100,7 +100,7 @@ public class DefaultPluginPrefixRequest
     {
         if ( pluginGroups != null )
         {
-            this.pluginGroups = pluginGroups;
+            this.pluginGroups = Collections.unmodifiableList( pluginGroups );
         }
         else
         {
@@ -131,7 +131,7 @@ public class DefaultPluginPrefixRequest
     {
         if ( repositories != null )
         {
-            this.repositories = repositories;
+            this.repositories = Collections.unmodifiableList( repositories );
         }
         else
         {

http://git-wip-us.apache.org/repos/asf/maven/blob/c7e9e448/maven-core/src/main/java/org/apache/maven/plugin/version/DefaultPluginVersionRequest.java
----------------------------------------------------------------------
diff --git a/maven-core/src/main/java/org/apache/maven/plugin/version/DefaultPluginVersionRequest.java
b/maven-core/src/main/java/org/apache/maven/plugin/version/DefaultPluginVersionRequest.java
index 9907066..57f4250 100644
--- a/maven-core/src/main/java/org/apache/maven/plugin/version/DefaultPluginVersionRequest.java
+++ b/maven-core/src/main/java/org/apache/maven/plugin/version/DefaultPluginVersionRequest.java
@@ -140,7 +140,7 @@ public class DefaultPluginVersionRequest
     {
         if ( repositories != null )
         {
-            this.repositories = repositories;
+            this.repositories = Collections.unmodifiableList( repositories );
         }
         else
         {

http://git-wip-us.apache.org/repos/asf/maven/blob/c7e9e448/maven-core/src/main/java/org/apache/maven/project/DefaultDependencyResolutionResult.java
----------------------------------------------------------------------
diff --git a/maven-core/src/main/java/org/apache/maven/project/DefaultDependencyResolutionResult.java
b/maven-core/src/main/java/org/apache/maven/project/DefaultDependencyResolutionResult.java
index dbdf252..509e8b4 100644
--- a/maven-core/src/main/java/org/apache/maven/project/DefaultDependencyResolutionResult.java
+++ b/maven-core/src/main/java/org/apache/maven/project/DefaultDependencyResolutionResult.java
@@ -98,7 +98,10 @@ class DefaultDependencyResolutionResult
     public List<Exception> getResolutionErrors( Dependency dependency )
     {
         List<Exception> errors = resolutionErrors.get( dependency );
-        return ( errors != null ) ? errors : Collections.<Exception>emptyList();
+        return ( errors != null )
+                   ? Collections.unmodifiableList( errors )
+                   : Collections.<Exception>emptyList();
+
     }
 
     public void setResolutionErrors( Dependency dependency, List<Exception> errors
)

http://git-wip-us.apache.org/repos/asf/maven/blob/c7e9e448/maven-core/src/main/java/org/apache/maven/project/DefaultProjectRealmCache.java
----------------------------------------------------------------------
diff --git a/maven-core/src/main/java/org/apache/maven/project/DefaultProjectRealmCache.java
b/maven-core/src/main/java/org/apache/maven/project/DefaultProjectRealmCache.java
index 9d66eb0..85bd001 100644
--- a/maven-core/src/main/java/org/apache/maven/project/DefaultProjectRealmCache.java
+++ b/maven-core/src/main/java/org/apache/maven/project/DefaultProjectRealmCache.java
@@ -49,7 +49,9 @@ public class DefaultProjectRealmCache
 
         public CacheKey( List<? extends ClassRealm> extensionRealms )
         {
-            this.extensionRealms = ( extensionRealms != null ) ? extensionRealms : Collections.<ClassRealm>emptyList();
+            this.extensionRealms = ( extensionRealms != null )
+                                       ? Collections.unmodifiableList( extensionRealms )
+                                       : Collections.<ClassRealm>emptyList();
 
             this.hashCode = this.extensionRealms.hashCode();
         }

http://git-wip-us.apache.org/repos/asf/maven/blob/c7e9e448/maven-core/src/main/java/org/apache/maven/project/MavenProject.java
----------------------------------------------------------------------
diff --git a/maven-core/src/main/java/org/apache/maven/project/MavenProject.java b/maven-core/src/main/java/org/apache/maven/project/MavenProject.java
index 952622f..9c936e1 100644
--- a/maven-core/src/main/java/org/apache/maven/project/MavenProject.java
+++ b/maven-core/src/main/java/org/apache/maven/project/MavenProject.java
@@ -778,7 +778,7 @@ public class MavenProject
         {
             return Collections.emptyList();
         }
-        return getModel().getBuild().getPlugins();
+        return Collections.unmodifiableList( getModel().getBuild().getPlugins() );
     }
 
     public List<String> getModules()
@@ -1079,7 +1079,7 @@ public class MavenProject
         }
         else
         {
-            return build.getExtensions();
+            return Collections.unmodifiableList( build.getExtensions() );
         }
     }
 
@@ -1605,7 +1605,7 @@ public class MavenProject
         {
             // TODO: let the scope handler deal with this
             if ( Artifact.SCOPE_COMPILE.equals( a.getScope() ) || Artifact.SCOPE_PROVIDED.equals(
a.getScope() )
-                || Artifact.SCOPE_SYSTEM.equals( a.getScope() ) )
+                     || Artifact.SCOPE_SYSTEM.equals( a.getScope() ) )
             {
                 Dependency dependency = new Dependency();
 
@@ -1619,7 +1619,7 @@ public class MavenProject
                 list.add( dependency );
             }
         }
-        return list;
+        return Collections.unmodifiableList( list );
     }
 
     @Deprecated
@@ -1663,7 +1663,7 @@ public class MavenProject
 
             list.add( dependency );
         }
-        return list;
+        return Collections.unmodifiableList( list );
     }
 
     @Deprecated // used by the Maven ITs
@@ -1678,7 +1678,7 @@ public class MavenProject
 
         List<Dependency> list = new ArrayList<>( artifacts.size() );
 
-        for ( Artifact a : getArtifacts()  )
+        for ( Artifact a : getArtifacts() )
         {
             // TODO: let the scope handler deal with this
             if ( Artifact.SCOPE_COMPILE.equals( a.getScope() ) || Artifact.SCOPE_RUNTIME.equals(
a.getScope() ) )
@@ -1695,7 +1695,7 @@ public class MavenProject
                 list.add( dependency );
             }
         }
-        return list;
+        return Collections.unmodifiableList( list );
     }
 
     @Deprecated
@@ -1791,7 +1791,7 @@ public class MavenProject
                 list.add( dependency );
             }
         }
-        return list;
+        return Collections.unmodifiableList( list );
     }
 
     @Deprecated
@@ -1863,8 +1863,7 @@ public class MavenProject
         {
             return Collections.emptyList();
         }
-        return getModel().getReporting().getPlugins();
-
+        return Collections.unmodifiableList( getModel().getReporting().getPlugins() );
     }
 
     @Deprecated

http://git-wip-us.apache.org/repos/asf/maven/blob/c7e9e448/maven-core/src/main/java/org/apache/maven/project/artifact/ProjectArtifact.java
----------------------------------------------------------------------
diff --git a/maven-core/src/main/java/org/apache/maven/project/artifact/ProjectArtifact.java
b/maven-core/src/main/java/org/apache/maven/project/artifact/ProjectArtifact.java
index 1d4a2a3..7113dd3 100644
--- a/maven-core/src/main/java/org/apache/maven/project/artifact/ProjectArtifact.java
+++ b/maven-core/src/main/java/org/apache/maven/project/artifact/ProjectArtifact.java
@@ -56,7 +56,10 @@ public class ProjectArtifact
     public List<Dependency> getManagedDependencies()
     {
         DependencyManagement depMngt = project.getDependencyManagement();
-        return ( depMngt != null ) ? depMngt.getDependencies() : Collections.<Dependency>emptyList();
+        return ( depMngt != null )
+                   ? Collections.unmodifiableList( depMngt.getDependencies() )
+                   : Collections.<Dependency>emptyList();
+
     }
 
     static class PomArtifactHandler

http://git-wip-us.apache.org/repos/asf/maven/blob/c7e9e448/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java
----------------------------------------------------------------------
diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java b/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java
index 176ce4d..bbbfa4a 100644
--- a/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java
+++ b/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java
@@ -659,7 +659,9 @@ public class MavenCli
 
                 BootstrapCoreExtensionManager resolver = container.lookup( BootstrapCoreExtensionManager.class
);
 
-                return resolver.loadCoreExtensions( request, providedArtifacts, extensions
);
+                return Collections.unmodifiableList( resolver.loadCoreExtensions( request,
providedArtifacts,
+                                                                                  extensions
) );
+
             }
             finally
             {

http://git-wip-us.apache.org/repos/asf/maven/blob/c7e9e448/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelBuildingException.java
----------------------------------------------------------------------
diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelBuildingException.java
b/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelBuildingException.java
index 434cb59..b527438 100644
--- a/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelBuildingException.java
+++ b/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelBuildingException.java
@@ -136,7 +136,7 @@ public class ModelBuildingException
         {
             return Collections.emptyList();
         }
-        return result.getProblems();
+        return Collections.unmodifiableList( result.getProblems() );
     }
 
     private static String toMessage( ModelBuildingResult result )


Mime
View raw message