This is an automated email from the ASF dual-hosted git repository.

vy pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/logging-log4j-tools.git

commit 10185227f8e3efe376ebdf5a95ba76c183cb6127
Author: Volkan Yazıcı <[email protected]>
AuthorDate: Fri Sep 29 10:57:37 2023 +0200

    Make `log4j-changelog-maven-plugin` thread-safe (#80)
---
 .../java/org/apache/logging/log4j/ExportMojo.java  |  4 +--
 .../java/org/apache/logging/log4j/ImportMojo.java  |  4 +--
 .../java/org/apache/logging/log4j/ReleaseMojo.java |  4 +--
 .../.0.x.x/make-maven-plugin-thread-safe.xml       | 41 ++++++++++++++++++++++
 src/site/_release-notes/_0.x.x.adoc                |  3 +-
 5 files changed, 49 insertions(+), 7 deletions(-)

diff --git 
a/log4j-changelog-maven-plugin/src/main/java/org/apache/logging/log4j/ExportMojo.java
 
b/log4j-changelog-maven-plugin/src/main/java/org/apache/logging/log4j/ExportMojo.java
index 96cb074..084f611 100644
--- 
a/log4j-changelog-maven-plugin/src/main/java/org/apache/logging/log4j/ExportMojo.java
+++ 
b/log4j-changelog-maven-plugin/src/main/java/org/apache/logging/log4j/ExportMojo.java
@@ -36,7 +36,7 @@ import org.apache.maven.plugins.annotations.Parameter;
  *
  * @see ChangelogExporter
  */
-@Mojo(name = "export", defaultPhase = LifecyclePhase.PRE_SITE)
+@Mojo(name = "export", defaultPhase = LifecyclePhase.PRE_SITE, threadSafe = 
true)
 public final class ExportMojo extends AbstractMojo {
 
     private static final String SOURCE_TARGET_TEMPLATE_PATTERN =
@@ -72,7 +72,7 @@ public final class ExportMojo extends AbstractMojo {
             required = true)
     private File outputDirectory;
 
-    public void execute() {
+    public synchronized void execute() {
         final Set<ChangelogExporterTemplate> translatedIndexTemplates = 
toExporterTemplates(indexTemplates);
         final Set<ChangelogExporterTemplate> 
translatedReleaseChangelogTemplates = toExporterTemplates(
                 changelogTemplates);
diff --git 
a/log4j-changelog-maven-plugin/src/main/java/org/apache/logging/log4j/ImportMojo.java
 
b/log4j-changelog-maven-plugin/src/main/java/org/apache/logging/log4j/ImportMojo.java
index f96adc9..64c8906 100644
--- 
a/log4j-changelog-maven-plugin/src/main/java/org/apache/logging/log4j/ImportMojo.java
+++ 
b/log4j-changelog-maven-plugin/src/main/java/org/apache/logging/log4j/ImportMojo.java
@@ -30,7 +30,7 @@ import org.apache.maven.plugins.annotations.Parameter;
  *
  * @see ChangelogReleaser
  */
-@Mojo(name = "import")
+@Mojo(name = "import", threadSafe = true)
 public final class ImportMojo extends AbstractMojo {
 
     /**
@@ -59,7 +59,7 @@ public final class ImportMojo extends AbstractMojo {
             required = true)
     private int releaseVersionMajor;
 
-    public void execute() {
+    public synchronized void execute() {
         final MavenChangesImporterArgs args = new MavenChangesImporterArgs(
                 changelogDirectory.toPath(),
                 changesXmlFile.toPath(),
diff --git 
a/log4j-changelog-maven-plugin/src/main/java/org/apache/logging/log4j/ReleaseMojo.java
 
b/log4j-changelog-maven-plugin/src/main/java/org/apache/logging/log4j/ReleaseMojo.java
index 2e46488..c460899 100644
--- 
a/log4j-changelog-maven-plugin/src/main/java/org/apache/logging/log4j/ReleaseMojo.java
+++ 
b/log4j-changelog-maven-plugin/src/main/java/org/apache/logging/log4j/ReleaseMojo.java
@@ -32,7 +32,7 @@ import org.apache.maven.plugins.annotations.Parameter;
  *
  * @see ChangelogReleaser
  */
-@Mojo(name = "release", defaultPhase = LifecyclePhase.VALIDATE)
+@Mojo(name = "release", defaultPhase = LifecyclePhase.VALIDATE, threadSafe = 
true)
 public final class ReleaseMojo extends AbstractMojo {
 
     /**
@@ -66,7 +66,7 @@ public final class ReleaseMojo extends AbstractMojo {
     @Parameter(property = "log4j.changelog.versionPattern")
     private String versionPattern;
 
-    public void execute() {
+    public synchronized void execute() {
         Pattern compiledVersionPattern = versionPattern != null ? 
Pattern.compile(versionPattern) : null;
         final ChangelogReleaserArgs args = new ChangelogReleaserArgs(
                 changelogDirectory.toPath(),
diff --git a/src/changelog/.0.x.x/make-maven-plugin-thread-safe.xml 
b/src/changelog/.0.x.x/make-maven-plugin-thread-safe.xml
new file mode 100644
index 0000000..7dfdfc0
--- /dev/null
+++ b/src/changelog/.0.x.x/make-maven-plugin-thread-safe.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one or more
+  ~ contributor license agreements.  See the NOTICE file distributed with
+  ~ this work for additional information regarding copyright ownership.
+  ~ The ASF licenses this file to you under the Apache License, Version 2.0
+  ~ (the "License"); you may not use this file except in compliance with
+  ~ the License.  You may obtain a copy of the License at
+  ~
+  ~      http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+<entry xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+       xmlns="http://logging.apache.org/log4j/changelog";
+       xsi:schemaLocation="http://logging.apache.org/log4j/changelog 
https://logging.apache.org/log4j/changelog-0.1.2.xsd";
+       type="changed">
+  <issue id="80" 
link="https://github.com/apache/logging-log4j-tools/issues/80"/>
+  <author id="github:vy"/>
+  <!-- The definition of what is "thread-safe" from a Maven point of view is 
really unclear.
+       The only relevant resource is the issue wiki regarding the parallel 
builds introduced in Maven 3: 
https://cwiki.apache.org/confluence/display/MAVEN/Parallel+builds+in+Maven+3#ParallelbuildsinMaven3-Mojothreadsafetyassertionchecklist
+       The guidance provided there is as follows:
+
+       - Check all static fields/variables in plugin code are not subject to 
threading problems.
+         You might want to pay special attention to static member variables of 
the subclasses of `java.text.Format` (`NumberFormat`, `DateFormat`, etc.), most 
of which are not thread-safe and cannot be shared as static variables.
+
+       - Check any plexus `components.xml`; if the components defined are 
singletons they need to be thread-safe.
+
+       - Check for presence of known tainted libraries.
+
+       - Check thread-safety of any other third party libraries.
+         This last item can be a bit hard, but inquiries on mailing lists can 
get you a long way.
+
+       I think we are not prone to any of the problems shared above.
+       To be certain, I have added `synchronized` modifier to each `execute()` 
method. -->
+  <description format="asciidoc">Make `log4j-changelog-maven-plugin` 
thread-safe</description>
+</entry>
diff --git a/src/site/_release-notes/_0.x.x.adoc 
b/src/site/_release-notes/_0.x.x.adoc
index 70beb61..49cc4cf 100644
--- a/src/site/_release-notes/_0.x.x.adoc
+++ b/src/site/_release-notes/_0.x.x.adoc
@@ -47,4 +47,5 @@ This minor release contains various bug fixes and 
improvements.
 
 ==== Changed
 
-* Made `author` element optional and bumped the XML schema version to `0.1.2`
+* Made `author` element optional and bumped the XML schema version to `0.1.2` 
(https://github.com/apache/logging-log4j-tools/issues/81[81])
+* Make `log4j-changelog-maven-plugin` thread-safe 
(https://github.com/apache/logging-log4j-tools/issues/80[80])

Reply via email to