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

Tibor Digana commented on SUREFIRE-1881:
----------------------------------------

[~kriegaex]
[~reinhapa]
Hello guys,

Thank you for the excellent analysis!
This helps a lot.
We did not want to include the feature (TCP connection) immediately because we 
need to observe the feedback from the users in first place.
Hopefully the issue happens inĀ {{SurefireForkChannel}} which means the JVM of 
Maven and plugin.
I guess  the problem is in the forked JVM where the tests and Agent have to 
run. This JVM crashed, according to my local dump file 
{{2021-03-25T21-16-48_404-jvmRun1.dump}}, the JVM exited and the hanging method 
{{SurefireForkChannel#connectToClient()}} was not interrupted. So the method 
has to be interrupted, and the main problem with the following message must be 
resolved:
*java.io.IOException: The remote computer refused the network connection*

Can you guys explain to me why we have this message?
Why the [project from 
Alexander|https://github.com/kriegaex/Maven_Surefire_PrintToConsoleProblems] 
has this problem and the other project don't?
We will interrupt the above Java method but the users would not understand it 
if it would happen to others. Therefore we have to find the root cause and then 
we will understand who can do and what.
I need your help!
As an experiment I tried to isolate something in the plugin config and I 
started with this:
{{<argLine>-javaagent:${project.build.directory}/${project.build.finalName}.jar</argLine>}}
I am using JDK15 (not JDK11), and the test failed as follows. Should we fix 
this first and then continue?
{noformat}
[INFO] Running de.scrum_master.dummy.AgentIT
[Test OUT] Before manual JRE bootstrap class retransformation
[Test ERR] Before manual JRE bootstrap class retransformation
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.046 s 
<<< FAILURE! - in de.scrum_master.dummy.AgentIT
[ERROR] de.scrum_master.dummy.AgentIT.test  Time elapsed: 0.013 s  <<< ERROR!
java.lang.NullPointerException: Cannot invoke 
"java.lang.instrument.Instrumentation.retransformClasses(java.lang.Class[])" 
because "de.scrum_master.dummy.Agent.INSTRUMENTATION" is null
        at de.scrum_master.dummy.AgentIT.test(AgentIT.java:18)

[INFO]
[INFO] Results:
[INFO]
[ERROR] Errors:
[ERROR]   AgentIT.test:18 NullPointer Cannot invoke 
"java.lang.instrument.Instrumentatio...
[INFO]
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0
{noformat}



> Java agent printing to native console makes build block when using 
> SurefireForkNodeFactory
> ------------------------------------------------------------------------------------------
>
>                 Key: SUREFIRE-1881
>                 URL: https://issues.apache.org/jira/browse/SUREFIRE-1881
>             Project: Maven Surefire
>          Issue Type: Bug
>          Components: Maven Failsafe Plugin, Maven Surefire Plugin
>    Affects Versions: 3.0.0-M5
>            Reporter: Alexander Kriegisch
>            Assignee: Tibor Digana
>            Priority: Major
>         Attachments: image-2021-02-08-12-07-34-183.png, 
> maven-failsafe-debug-log.txt, screenshot-1.png
>
>
> This is a follow-up to SUREFIRE-1788 which was closed prematurely even though 
> there still were open issues which were discussed there initially. Basically 
> the situation is as follows:
>  * I use Java agents writing to stdOut and stdErr in my tests.
>  * I was annoyed that Surefire/Failsafe were writing lots of {{[WARNING] 
> Corrupted STDOUT by directly writing to native stream in forked JVM}} lines 
> into {{*-jvmRun1.dumpstream}} files. [~tibordigana] then told me to use 
> {{<forkNode 
> implementation="org.apache.maven.plugin.surefire.extensions.SurefireForkNodeFactory"/>}}
>  in my POM in order to fix the issue.
>  * I tried this in version 3.0.0-M5, but unfortunately, it makes 
> Surefire/Failsafe freeze if a Java agent prints something to stdOut or 
> stdErr. This happens both in M5 and in M6-SNAPSHOT after both SUREFIRE-1788 
> and SUREFIRE-1809 have been merged in already.
>  * My [sample 
> project|https://github.com/kriegaex/Maven_Surefire_PrintToConsoleProblems] 
> reproduces the issue as soon as you uncomment the option in the POM and run 
> {{mvn clean verify}}.
>  * The second issue is: *Not* using this option leads to garbled log output 
> when a Java agent writes to both stdOut and stdErr before/during tests. See 
> comments in class 
> [{{Agent.DummyTransformer}}|https://github.com/kriegaex/Maven_Surefire_PrintToConsoleProblems/blob/master/src/main/java/de/scrum_master/dummy/Agent.java]
>  for examples for garbled log lines and also comments in 
> [pom.xml|https://github.com/kriegaex/Maven_Surefire_PrintToConsoleProblems/blob/master/pom.xml#L36]
>  for further information.
>  * If the garbled output would also appear with this option activated, cannot 
> be tested at present due to the Surefire/Failsafe freeze. I will re-test that 
> after the freeze has been fixed and before this issue can be closed.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to