maven-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tibor Digana (JIRA)" <j...@apache.org>
Subject [jira] [Assigned] (SUREFIRE-1587) Forked execution prevents correct ServerSocket closing
Date Fri, 02 Nov 2018 04:18:00 GMT

     [ https://issues.apache.org/jira/browse/SUREFIRE-1587?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Tibor Digana reassigned SUREFIRE-1587:
--------------------------------------

    Assignee: Tibor Digana

> Forked execution prevents correct ServerSocket closing
> ------------------------------------------------------
>
>                 Key: SUREFIRE-1587
>                 URL: https://issues.apache.org/jira/browse/SUREFIRE-1587
>             Project: Maven Surefire
>          Issue Type: Bug
>    Affects Versions: 2.22.1
>         Environment: Linux, problem becomes visible on archlinux and also on Travis CI
>            Reporter: Johannes Wienke
>            Assignee: Tibor Digana
>            Priority: Major
>
> The default mode of forked unit test execution (with JUnit) seems to interfere with socket
operations. In our case, we see that with a surefire execution in forked mode, ServerSocket
instances, despite returning from a close() call, are sometimes not correctly closed and a
subsequent try to acquire a server socket on the same port then fails. This does not happen
outside of surefire or when forkMode is set to none.
> Here is a simple test case to try this. First the maven project pom.xml:
> {code:title=pom.xml|borderStyle=solid}
> <?xml version="1.0" encoding="UTF-8"?>
> <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>testing</groupId>
>   <artifactId>testit</artifactId>
>   <version>1.0-SNAPSHOT</version>
>   <name>testit</name>
>   <description>A simple testit.</description>
>   <url>http://www.example.com</url>
>   <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>
>   <dependencies>
>     <dependency>
>       <groupId>junit</groupId>
>       <artifactId>junit</artifactId>
>       <version>4.11</version>
>       <scope>test</scope>
>     </dependency>
>   </dependencies>
>   <build>
>     <plugins>
>       <plugin>
>         <groupId>org.apache.maven.plugins</groupId>
>         <artifactId>maven-surefire-plugin</artifactId>
>         <version>2.22.1</version>
>       </plugin>
>     </plugins>
>   </build>
> </project>
> {code}
> And here a test file to be placed into the test source tree:
> {code:title=AppTest.java|borderStyle=solid}
> package testing;
> import org.junit.Test;
> import java.net.ServerSocket;
> public class AppTest {
>     @Test
>     public void testSocketStuff() throws Exception {
>         while (true) {
>             System.out.println("Iteration");
>             final ServerSocket socket = new ServerSocket(55444);
>             socket.close();
>         }
>     }
> }
> {code}
> Executing this with the default options (forking mode enabled) will pretty soon end up
in the following exception after some iterations:
> {code}
> [ERROR] testSocketStuff(testing.AppTest)  Time elapsed: 1.376 s  <<< ERROR!
> java.net.BindException: Address already in use (Bind failed)
>         at testing.AppTest.testSocketStuff(AppTest.java:17)
> {code}
> Executing the same test with -DforkMode=none does not result in this failure and the
loop runs endlessly.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message