You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by mi...@apache.org on 2023/04/02 21:17:52 UTC
[maven-site-plugin] branch master updated: Refactor bad smells: - ToArrayCallWithZeroLengthArrayArgument The performance of the empty array version is the same, and sometimes even better, compared to the pre-sized version. Also, passing a pre-sized array is dangerous for a concurrent or synchronized collection as a data race is possible between the size and toArray calls. This may result in extra nulls at the end of the array if the collection was concurrently shrunk during the operation. [...]
This is an automated email from the ASF dual-hosted git repository.
michaelo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-site-plugin.git
The following commit(s) were added to refs/heads/master by this push:
new 34550ec1 Refactor bad smells: - ToArrayCallWithZeroLengthArrayArgument The performance of the empty array version is the same, and sometimes even better, compared to the pre-sized version. Also, passing a pre-sized array is dangerous for a concurrent or synchronized collection as a data race is possible between the <code>size</code> and <code>toArray</code> calls. This may result in extra <code>null</code>s at the end of the array if the collection was concurrently shrunk during [...]
34550ec1 is described below
commit 34550ec1afc4f011c1a17d18858003f02ddbb800
Author: MartinWitt <wi...@gmail.com>
AuthorDate: Sun Mar 12 18:32:59 2023 +0000
Refactor bad smells:
- ToArrayCallWithZeroLengthArrayArgument
The performance of the empty array version is the same, and sometimes even better, compared
to the pre-sized version. Also, passing a pre-sized array is dangerous for a concurrent or
synchronized collection as a data race is possible between the <code>size</code> and <code>toArray</code>
calls. This may result in extra <code>null</code>s at the end of the array if the collection was concurrently
shrunk during the operation.</p>
See https://shipilev.net/blog/2016/arrays-wisdom-ancients/ for more details.
---
.../org/apache/maven/plugins/site/render/AbstractSiteRenderingMojo.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/main/java/org/apache/maven/plugins/site/render/AbstractSiteRenderingMojo.java b/src/main/java/org/apache/maven/plugins/site/render/AbstractSiteRenderingMojo.java
index b46f8492..2dc9bb13 100644
--- a/src/main/java/org/apache/maven/plugins/site/render/AbstractSiteRenderingMojo.java
+++ b/src/main/java/org/apache/maven/plugins/site/render/AbstractSiteRenderingMojo.java
@@ -232,7 +232,7 @@ public abstract class AbstractSiteRenderingMojo extends AbstractSiteDescriptorMo
mpir.setArtifactId("maven-project-info-reports-plugin");
reportingPlugins.add(mpir);
}
- return reportingPlugins.toArray(new ReportPlugin[reportingPlugins.size()]);
+ return reportingPlugins.toArray(new ReportPlugin[0]);
}
protected SiteRenderingContext createSiteRenderingContext(Locale locale)