You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by gn...@apache.org on 2022/05/30 11:08:16 UTC

[maven-integration-testing] branch master updated: [MNG-7487] Fix deadlock during forked lifecycle executions

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

gnodet pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-integration-testing.git


The following commit(s) were added to refs/heads/master by this push:
     new 88bb1d5bd [MNG-7487] Fix deadlock during forked lifecycle executions
88bb1d5bd is described below

commit 88bb1d5bd87b7043e08c040644ea69891ac75d4d
Author: Guillaume Nodet <gn...@gmail.com>
AuthorDate: Tue May 17 14:09:52 2022 +0200

    [MNG-7487] Fix deadlock during forked lifecycle executions
    
    This closes #162
---
 .../org/apache/maven/it/IntegrationTestSuite.java  |  1 +
 .../maven/it/MavenITmng7487DeadlockTest.java       | 52 +++++++++++++++++++
 .../src/test/resources/bootstrap/group-13/pom.xml  |  2 +-
 .../resources/mng-7487-deadlock/consumer/pom.xml   | 59 ++++++++++++++++++++++
 .../java/com/example/demo/DemoApplication.java     |  9 ++++
 .../group-13 => mng-7487-deadlock/plugin}/pom.xml  | 52 +++++++++----------
 .../src/main/java/testmojo/AggregatorMojo.java     | 37 ++++++++++++++
 .../java/testmojo/RequiresCompilePhaseMojo.java    | 38 ++++++++++++++
 8 files changed, 222 insertions(+), 28 deletions(-)

diff --git a/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java b/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java
index 2e6462554..dc5298b20 100644
--- a/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java
+++ b/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java
@@ -106,6 +106,7 @@ public class IntegrationTestSuite
         // Tests that don't run stable and need to be fixed
         // -------------------------------------------------------------------------------------------------------------
         // suite.addTestSuite( MavenIT0108SnapshotUpdateTest.class ); -- MNG-3137
+        suite.addTestSuite( MavenITmng7487DeadlockTest.class );
         suite.addTestSuite( MavenITmng7470ResolverTransportTest.class );
         suite.addTestSuite( MavenITmng7464ReadOnlyMojoParametersWarningTest.class );
         suite.addTestSuite( MavenITmng7404IgnorePrefixlessExpressionsTest.class );
diff --git a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng7487DeadlockTest.java b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng7487DeadlockTest.java
new file mode 100644
index 000000000..59b8c861a
--- /dev/null
+++ b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng7487DeadlockTest.java
@@ -0,0 +1,52 @@
+/*
+ * 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.
+ */
+package org.apache.maven.it;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.apache.maven.it.util.ResourceExtractor;
+
+public class MavenITmng7487DeadlockTest extends AbstractMavenIntegrationTestCase
+{
+    private static final String PROJECT_PATH = "/mng-7487-deadlock";
+
+    public MavenITmng7487DeadlockTest()
+    {
+        super( "(,3.8.4],[3.8.6,)" );
+    }
+
+    public void testDeadlock() throws IOException, VerificationException
+    {
+        final File rootDir = ResourceExtractor.simpleExtractResources( getClass(), PROJECT_PATH );
+
+        final File pluginDir = new File( rootDir, "plugin" );
+        final Verifier pluginVerifier = newVerifier( pluginDir.getAbsolutePath() );
+        pluginVerifier.executeGoal( "install" );
+
+        final File consumerDir = new File( rootDir, "consumer" );
+        final Verifier consumerVerifier = newVerifier( consumerDir.getAbsolutePath() );
+        consumerVerifier.setForkJvm( true );;
+        consumerVerifier.addCliOption( "-T2" );
+        consumerVerifier.executeGoal( "package" );
+        consumerVerifier.verifyErrorFreeLog();
+        consumerVerifier.verifyTextInLog( "BUILD SUCCESS" );
+    }
+
+}
diff --git a/core-it-suite/src/test/resources/bootstrap/group-13/pom.xml b/core-it-suite/src/test/resources/bootstrap/group-13/pom.xml
index 2c3a7322b..8fa4b91f8 100644
--- a/core-it-suite/src/test/resources/bootstrap/group-13/pom.xml
+++ b/core-it-suite/src/test/resources/bootstrap/group-13/pom.xml
@@ -51,7 +51,7 @@ under the License.
     </dependency>
     <dependency>
       <groupId>org.apache.maven</groupId>
-	  <artifactId>maven-core</artifactId>
+      <artifactId>maven-core</artifactId>
       <version>3.1.0</version>
     </dependency>
     <dependency>
diff --git a/core-it-suite/src/test/resources/mng-7487-deadlock/consumer/pom.xml b/core-it-suite/src/test/resources/mng-7487-deadlock/consumer/pom.xml
new file mode 100644
index 000000000..016676166
--- /dev/null
+++ b/core-it-suite/src/test/resources/mng-7487-deadlock/consumer/pom.xml
@@ -0,0 +1,59 @@
+<?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.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.maven.its.mng7487</groupId>
+  <artifactId>consumer</artifactId>
+  <version>1.0-SNAPSHOT</version>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.its.mng7487</groupId>
+        <artifactId>plugin</artifactId>
+        <version>1.0-SNAPSHOT</version>
+        <executions>
+          <execution>
+            <id>fork</id>
+            <goals>
+              <goal>require-compile-phase</goal>
+            </goals>
+          </execution>
+          <execution>
+            <id>aggregate</id>
+            <goals>
+              <goal>aggregator</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    <maven.compiler.source>1.7</maven.compiler.source>
+    <maven.compiler.target>1.7</maven.compiler.target>
+  </properties>
+
+</project>
diff --git a/core-it-suite/src/test/resources/mng-7487-deadlock/consumer/src/main/java/com/example/demo/DemoApplication.java b/core-it-suite/src/test/resources/mng-7487-deadlock/consumer/src/main/java/com/example/demo/DemoApplication.java
new file mode 100644
index 000000000..1c209368b
--- /dev/null
+++ b/core-it-suite/src/test/resources/mng-7487-deadlock/consumer/src/main/java/com/example/demo/DemoApplication.java
@@ -0,0 +1,9 @@
+package com.example.demo;
+
+public class DemoApplication
+{
+    public static void main( String[] args )
+    {
+        System.out.println( "Hello world!" );
+    }
+}
diff --git a/core-it-suite/src/test/resources/bootstrap/group-13/pom.xml b/core-it-suite/src/test/resources/mng-7487-deadlock/plugin/pom.xml
similarity index 52%
copy from core-it-suite/src/test/resources/bootstrap/group-13/pom.xml
copy to core-it-suite/src/test/resources/mng-7487-deadlock/plugin/pom.xml
index 2c3a7322b..78054e626 100644
--- a/core-it-suite/src/test/resources/bootstrap/group-13/pom.xml
+++ b/core-it-suite/src/test/resources/mng-7487-deadlock/plugin/pom.xml
@@ -19,45 +19,43 @@ specific language governing permissions and limitations
 under the License.
 -->
 
-<project>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
   <modelVersion>4.0.0</modelVersion>
 
-  <parent>
-    <groupId>org.apache.maven.its.bootstrap</groupId>
-    <artifactId>maven-it-boostrap</artifactId>
-    <version>1.0</version>
-  </parent>
-
-  <groupId>org.apache.maven.its.bootstrap</groupId>
-  <artifactId>group-13</artifactId>
-  <version>1.0</version>
-  <packaging>jar</packaging>
-
-  <name>Maven Integration Test :: Boostrap :: Group-13</name>
+  <groupId>org.apache.maven.its.mng7487</groupId>
+  <artifactId>plugin</artifactId>
+  <version>1.0-SNAPSHOT</version>
+  <packaging>maven-plugin</packaging>
 
   <properties>
+    <maven.compiler.source>1.7</maven.compiler.source>
+    <maven.compiler.target>1.7</maven.compiler.target>
+    <maven-version>3.1.1</maven-version>
   </properties>
 
   <dependencies>
     <dependency>
-      <groupId>org.codehaus.plexus</groupId>
-      <artifactId>plexus-utils</artifactId>
-      <version>2.0.5</version>
+      <groupId>org.apache.maven.plugin-tools</groupId>
+      <artifactId>maven-plugin-annotations</artifactId>
+      <version>3.3</version>
+      <scope>provided</scope>
     </dependency>
     <dependency>
       <groupId>org.apache.maven</groupId>
       <artifactId>maven-plugin-api</artifactId>
-      <version>3.1.0</version>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.maven</groupId>
-	  <artifactId>maven-core</artifactId>
-      <version>3.1.0</version>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.maven.plugins</groupId>
-      <artifactId>maven-plugin-plugin</artifactId>
-      <version>3.6.0</version>
+      <version>${maven-version}</version>
+      <scope>provided</scope>
     </dependency>
   </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-plugin-plugin</artifactId>
+        <version>3.3</version>
+      </plugin>
+    </plugins>
+  </build>
 </project>
diff --git a/core-it-suite/src/test/resources/mng-7487-deadlock/plugin/src/main/java/testmojo/AggregatorMojo.java b/core-it-suite/src/test/resources/mng-7487-deadlock/plugin/src/main/java/testmojo/AggregatorMojo.java
new file mode 100644
index 000000000..63f509748
--- /dev/null
+++ b/core-it-suite/src/test/resources/mng-7487-deadlock/plugin/src/main/java/testmojo/AggregatorMojo.java
@@ -0,0 +1,37 @@
+package testmojo;
+
+/*
+ * 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.
+ */
+
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugins.annotations.Execute;
+import org.apache.maven.plugins.annotations.LifecyclePhase;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.ResolutionScope;
+
+@Mojo( name = "aggregator", requiresProject = true, defaultPhase = LifecyclePhase.COMPILE, aggregator = true )
+public class AggregatorMojo extends AbstractMojo
+{
+    public void execute() throws MojoExecutionException, MojoFailureException
+    {
+        getLog().info( "MNG-7487 plugin aggregator goal executed" );
+    }
+}
diff --git a/core-it-suite/src/test/resources/mng-7487-deadlock/plugin/src/main/java/testmojo/RequiresCompilePhaseMojo.java b/core-it-suite/src/test/resources/mng-7487-deadlock/plugin/src/main/java/testmojo/RequiresCompilePhaseMojo.java
new file mode 100644
index 000000000..291ef7a8a
--- /dev/null
+++ b/core-it-suite/src/test/resources/mng-7487-deadlock/plugin/src/main/java/testmojo/RequiresCompilePhaseMojo.java
@@ -0,0 +1,38 @@
+package testmojo;
+
+/*
+ * 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.
+ */
+
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugins.annotations.Execute;
+import org.apache.maven.plugins.annotations.LifecyclePhase;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.ResolutionScope;
+
+@Mojo( name = "require-compile-phase", requiresProject = true, defaultPhase = LifecyclePhase.VALIDATE )
+@Execute( phase = LifecyclePhase.TEST_COMPILE )
+public class RequiresCompilePhaseMojo extends AbstractMojo
+{
+    public void execute() throws MojoExecutionException, MojoFailureException
+    {
+        getLog().info( "MNG-7487 plugin require-compile-phase goal executed" );
+    }
+}