Hi, There is something strange in your question: you state that you run agent in "*tcpclient*" mode and use http://www.jacoco.org/jacoco/trunk/doc/examples/java/ExecutionDataClient.java , while description of last clearly states: "This example connects to a coverage agent that run in output mode *tcpserver*"
Should be simply impossible to connect to agent that is in "tcpclient" mode, which is not surprising as it is named "client". The only guess that first dump is actually incorrectly succeeds resulting in empty data, while should fail - see https://github.com/jacoco/jacoco/pull/538 , which is resolved for the next version of JaCoCo and already available in current snapshot build. Regards, Evgeny On Tuesday, August 29, 2017 at 8:27:44 AM UTC+2, [email protected] wrote: > > > Hi, > > Here is my situation: > we have a mico-service architect design product, and now we want to > perform the code coverage for all services and don't expected frequency > service restart. so we don't use TCPServer and local file mode. > > Now we try with TCPClient mode and create a tcp server to collect the dump > file, after the agent connect to the tcp server, we can use > RemoteControlWriter.visitDumpCommand to collect dump file from each agent. > > we use the sample executiondataclient code to collect dump file as follow. > for the first time to trigger dump, the exec file can successful dump out. > final FileOutputStream localFile = new FileOutputStream(DESTFILE); > final ExecutionDataWriter localWriter = new ExecutionDataWriter( > localFile); > > // Open a socket to the coverage agent: > final Socket socket = new Socket(InetAddress.getByName(ADDRESS), PORT); > final RemoteControlWriter writer = new RemoteControlWriter( > socket.getOutputStream()); > final RemoteControlReader reader = new RemoteControlReader( > socket.getInputStream()); > reader.setSessionInfoVisitor(localWriter); > reader.setExecutionDataVisitor(localWriter); > > // Send a dump command and read the response: > writer.visitDumpCommand(true, false); > if (!reader.read()) { > throw new IOException("Socket closed unexpectedly."); > } > > but if i trigger the dump again, there is a "Invalid execution data file" > exception throw from here. the type is not 1 but 16, i don't know why the > second time to trigger file dump, there is no Block_Header return? how to > resolve? > public boolean read() throws IOException, > IncompatibleExecDataVersionException { > try { > byte type; > do { > type = in.readByte(); > if (firstBlock && type != ExecutionDataWriter.BLOCK_HEADER) { > throw new IOException("Invalid execution data file."); > } > firstBlock = false; > } while (readBlock(type)); > return true; > } catch (final EOFException e) { > return false; > } > } > > > Thanks very much. > -- You received this message because you are subscribed to the Google Groups "JaCoCo and EclEmma Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/aac1a556-4797-4f2c-95ab-85314817b148%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
