Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.10.1
Description
I was working on some changes in Flink and on my workstation I have also JDK 14 installed.
When Flink is built using JDK > 8 and then run using JDK 8 the problem surfaces that the code crashes with the exception like this:
java.lang.NoSuchMethodError: java.nio.ByteBuffer.position(I)Ljava/nio/ByteBuffer; at org.apache.flink.core.memory.DataOutputSerializer.wrapAsByteBuffer(DataOutputSerializer.java:65) ~[classes/:?] at org.apache.flink.runtime.io.network.api.serialization.SpanningRecordSerializer.<init>(SpanningRecordSerializer.java:50) ~[classes/:?] at org.apache.flink.runtime.io.network.api.writer.RecordWriter.<init>(RecordWriter.java:98) ~[classes/:?] at org.apache.flink.runtime.io.network.api.writer.ChannelSelectorRecordWriter.<init>(ChannelSelectorRecordWriter.java:50) ~[classes/:?] at org.apache.flink.runtime.io.network.api.writer.RecordWriterBuilder.build(RecordWriterBuilder.java:53) ~[classes/:?]
This is a problem in the way JDK 9+ generates the code that is incompatible with using the JDK 8 runtime, even if during the build it was indicated that JRE 8 would be the target.
I have found several projects have ran into the exact same problem:
- https://issues.apache.org/jira/browse/MRESOLVER-67
- https://github.com/eclipse/jetty.project/issues/3244
- https://github.com/netty/netty/issues/9880
- https://github.com/apache/felix/pull/114
- https://stackoverflow.com/questions/61267495/exception-in-thread-main-java-lang-nosuchmethoderror-java-nio-bytebuffer-flip
As indicated in the mentioned Jetty ticket the solution is quite simple:
The solution is to cast the ByteBuffer to Buffer when calling those methods:((Buffer)byteBuffer).position(0);--
Attachments
Issue Links
- links to