Messages bigger than 65535 utf code points crash the server
See original GitHub issuecommon/Message
uses DataOutputStream#writeUTF
which throws an expiation if the string to write is longer than 65535 utf code points
I stumbled upon this while trying mvnd
with Neo4j-OGM. It happens while our build triggers the Maven Java doc plugin.
I was able to reproduce it with the following test:
package com.example.mvndtest;
import java.io.IOException;
import org.junit.jupiter.api.Test;
class MvndTestApplicationTests {
@Test
void contextLoads() throws IOException {
var stringToWrite = new StringBuilder();
for (int i = 0; i < 65535 /* 65509 works on my machine */; ++i) {
stringToWrite.append("a");
}
System.out.println(stringToWrite.toString());
}
}
Having such an output somewhere in the build - doesn’t matter via plugin or code - will crash the server.
I wasn’t able to reproduce it with exec maven or ant run plugins and the reason is simple: Those plugins redirect sys out line by line. The java doc plugin however collects all the log from the javadoc
binary and passes it directly to the maven log.
That’s basically the same like I do in the example above.
I have attached a reproducer.
mvn clean package
works nicely with a lot of useless output, mvnd clean package
will end with:
[INFO] Running com.example.mvndtest.MvndTestApplicationTests
Exception in thread "main" org.jboss.fuse.mvnd.common.DaemonException$StaleAddressException: Could not receive a message from the daemon.
at org.jboss.fuse.mvnd.client.DaemonClientConnection.receive(DaemonClientConnection.java:107)
at org.jboss.fuse.mvnd.client.DefaultClient.execute(DefaultClient.java:198)
at org.jboss.fuse.mvnd.client.DefaultClient.main(DefaultClient.java:72)
Caused by: java.io.IOException: No message received within 3000ms, daemon may have crashed
at org.jboss.fuse.mvnd.client.DaemonClientConnection.receive(DaemonClientConnection.java:100)
... 2 more
and attached logs.
Reproducer: mvnd-test.zip
Logs: logs.zip
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (4 by maintainers)
Interesting! Thanks for the report, @michael-simons!
No, I was talking about the length of the string. The DataOutputStream uses an unsigned short (2 bytes) so is limited to 64k. The DataOutputStream code code has the following https://github.com/openjdk-mirror/jdk7u-jdk/blob/master/src/share/classes/java/io/DataOutputStream.java#L363-L365: