-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ExecDumpClient should report error when no execution data is retrieved #538
Conversation
@marchof one case is obvious - when remote is something that always closes connection; wondering under which conditions real JaCoCo agent can do this? |
@Godin No idea how the actual JaCoCo agent would behave like this. This PR is more about making the client bullet-proof especially about missconfiguration. |
@@ -41,6 +41,9 @@ | |||
(GitHub <a href="https://github.com/jacoco/jacoco/issues/529">#529</a>).</li> | |||
<li>Maven aggregated reports will now also include modules of runtime dependencies | |||
(GitHub <a href="https://github.com/jacoco/jacoco/issues/498">#498</a>).</li> | |||
<li><code>dump</code> commands now report errors when remote connections are | |||
closed unexpectedly |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@marchof I'd like to reword this to be more precise as this is about one particular situation described in ticket and not about all situations when connection is closed. Something like:
<code>dump</code> commands now report error when server unexpectedly closes
connection without sending response
Also you marked ticket as type: bug
, but then change should be in section "Fixed Bugs" instead of "New Features", isn't it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -126,6 +126,12 @@ public void testReset() throws IOException { | |||
assertTrue(resetRequested); | |||
} | |||
|
|||
@Test(expected = IOException.class) | |||
public void testNopServer() throws IOException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@marchof what about usage of a new naming convention, i.e. rename into should_throw_IOException_when_server_closes_connection_without_response
?
Also what about assertion for a message? And seems that there is race condition, because such assertion will fail from time to time, which explains why in #525 (comment) I stated that throw
was not covered:
java.net.SocketException: Broken pipe
at java.net.SocketOutputStream.socketWrite0(Native Method)
at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
at java.net.SocketOutputStream.write(SocketOutputStream.java:115)
at java.io.DataOutputStream.writeChar(DataOutputStream.java:166)
at org.jacoco.core.data.ExecutionDataWriter.writeHeader(ExecutionDataWriter.java:72)
at org.jacoco.core.data.ExecutionDataWriter.<init>(ExecutionDataWriter.java:61)
at org.jacoco.core.runtime.RemoteControlWriter.<init>(RemoteControlWriter.java:40)
at org.jacoco.core.tools.ExecDumpClient.dump(ExecDumpClient.java:118)
at org.jacoco.core.tools.ExecDumpClient.dump(ExecDumpClient.java:98)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Godin Good catch! Needed to insert a Thread.sleep() to reproduce this, but I was able to reproduce it. Fixed in 42b4f9f ✅
I didn't change the method name originally, as the code change was a 1:1 patch from #525. Now as we needed to adjust the code I also change the method name as suggested. To avoid merge conflicts I will revert the corresponding change in #525, correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@marchof well, IMO no big difference whether to explicitly revert or resolve conflict during merge, but I see that you already did a revert
@@ -123,7 +123,10 @@ public ExecFileLoader dump(final InetAddress address, final int port) | |||
.setExecutionDataVisitor(loader.getExecutionDataStore()); | |||
|
|||
remoteWriter.visitDumpCommand(dump, reset); | |||
remoteReader.read(); | |||
|
|||
if (!remoteReader.read()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@marchof we have similar code in org.jacoco.examples/src/org/jacoco/examples/ExecutionDataClient.java
. Later we can update it to use ExecDumpClient
, but IMO anyway will be better to apply same modification in it with this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in acfb4b0 ✅
@marchof 👍 |
Thanks for having that fixed, I just spend an hour tracking that down on 0.7.9. My use case: When I connect to a running docker instance that does not have jacoco enabled, ExecDumpClient.dump() returns an (empty) ExecFileLoader instead of failing as desired. |
@denisa could you please clarify just to be sure - do you mean that after this change in your use case you're getting |
Yes, this bug is fixed: 0.7.10-SNAPSHOT throws an IOException as designed when 0.7.9 simply returned an object. |
@denisa cool! thank you for information 👍 |
Ant and Maven
dump
commands use theExecDumpClient
class from theorg.jacoco.core
module. This utility does not evaluate the response status after sending adump
request. If the remote closes the connection without sending a response this is silently ignored.Expected behavior is that a
IOException
is thrown when adump
request is not answered.