You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Tibor Digana (JIRA)" <ji...@apache.org> on 2019/03/24 23:03:00 UTC

[jira] [Comment Edited] (SUREFIRE-1587) Forked execution prevents correct ServerSocket closing

    [ https://issues.apache.org/jira/browse/SUREFIRE-1587?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16800194#comment-16800194 ] 

Tibor Digana edited comment on SUREFIRE-1587 at 3/24/19 11:02 PM:
------------------------------------------------------------------

[~languitar]
How did you resolve this issue after 5 months?
If the issue still exists, pls send an email with a question to Apache Maven Users <us...@maven.apache.org>.
Thx


was (Author: tibor17):
[~languitar]
How did you resolve this issue after 5 months?
If the issue still exists, pls send an email to with a question to Apache Maven Users <us...@maven.apache.org>.
Thx

> 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)