From bb5441791c8d2da7ce9734b5ae980cdf2e7bbb03 Mon Sep 17 00:00:00 2001 From: Ladyslaw Wlodarski <69821285+ladwlo@users.noreply.github.com> Date: Tue, 22 Sep 2020 10:16:26 +0200 Subject: [PATCH] Synchronizing on a public object, for true thread-safety (issue #21) --- .../main/java/org/codehaus/gmaven/plugin/MojoSupport.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gmaven-plugin/src/main/java/org/codehaus/gmaven/plugin/MojoSupport.java b/gmaven-plugin/src/main/java/org/codehaus/gmaven/plugin/MojoSupport.java index 4276a44e..a9c4f811 100644 --- a/gmaven-plugin/src/main/java/org/codehaus/gmaven/plugin/MojoSupport.java +++ b/gmaven-plugin/src/main/java/org/codehaus/gmaven/plugin/MojoSupport.java @@ -63,12 +63,16 @@ public abstract class MojoSupport */ protected MavenProject project; + private static final Object lock = new Object(); + /** * Main Mojo execution hook. Sub-class should use {@link #doExecute} instead. */ - public synchronized void execute() throws MojoExecutionException, MojoFailureException { + public void execute() throws MojoExecutionException, MojoFailureException { try { - doExecute(); + synchronized(lock) { + doExecute(); + } } catch (Exception e) { //