apache / arrow

Apache Arrow is a multi-language toolbox for accelerated data interchange and in-memory processing
https://arrow.apache.org/
Apache License 2.0
13.7k stars 3.35k forks source link

[Java] arrow-vector 16.1.0 has a change that breaks Java 8 support #41717

Closed pjfanning closed 1 week ago

pjfanning commented 2 weeks ago

Describe the bug, including details regarding any error messages, version, and platform.

arrow-vector 16.0.0 works fine for us but upgrading to 16.1.0 causes compile issues for us when we build with Java 8.

We found this in the Apache Pekko CI build.

[info] org.apache.pekko.stream.connectors.googlecloud.bigquery.storage.scaladsl.BigQueryArrowStorageSpec *** ABORTED *** (0 milliseconds)
[info]   java.lang.NoSuchMethodError: java.nio.ByteBuffer.rewind()Ljava/nio/ByteBuffer;
[info]   at org.apache.arrow.vector.ipc.message.MessageSerializer.readMessage(MessageSerializer.java:704)
[info]   at org.apache.arrow.vector.ipc.message.MessageSerializer.deserializeSchema(MessageSerializer.java:213)
[info]   at org.apache.pekko.stream.connectors.googlecloud.bigquery.storage.impl.SimpleRowReader.<init>(ArrowSource.scala:66)
[info]   at org.apache.pekko.stream.connectors.googlecloud.bigquery.storage.scaladsl.BigQueryArrowStorageSpec.$anonfun$new$1(BigQueryArrowStorageSpec.scala:35)

Component(s)

Java

pjfanning commented 2 weeks ago

ByteBuffer inherits rewind from Buffer and Java 8 has this method.

https://docs.oracle.com/javase/8/docs/api/java/nio/Buffer.html#rewind--

I have seem issues in Java 8 where you need to cast to java.nio.Buffer for this to work reliably.

In https://issues.apache.org/jira/browse/HADOOP-18197, there were issues where we got on some Java8 installations.

java.lang.NoSuchMethodError: java.nio.ByteBuffer.position(I)Ljava/nio/ByteBuffer;

We had to upgrade protobuf-java (which had the ByteBuffer code that was causing us issues) to get this fix: https://github.com/protocolbuffers/protobuf/commit/d40aadf823cf7e1e62b65561656f689da8969463

See https://www.morling.dev/blog/bytebuffer-and-the-dreaded-nosuchmethoderror/

pjfanning commented 2 weeks ago

Arrow has this cast in a different part of the code.

https://github.com/apache/arrow/blob/dcdf4e6953b7fdab6078c444c8d07a606750fec1/java/c/src/main/java/org/apache/arrow/c/NativeUtil.java#L57

Could we add a similar cast in the method that is causing issues? https://github.com/apache/arrow/blob/dcdf4e6953b7fdab6078c444c8d07a606750fec1/java/vector/src/main/java/org/apache/arrow/vector/ipc/message/MessageSerializer.java#L704

assignUser commented 1 week ago

fyi: https://github.com/apache/arrow/issues/38051

lidavidm commented 1 week ago

Issue resolved by pull request 41718 https://github.com/apache/arrow/pull/41718

pjfanning commented 1 week ago

@lidavidm @assignUser This was also reported (@pan3793)

https://github.com/apache/arrow/pull/41718#issuecomment-2119816144

lidavidm commented 1 week ago

@vibhatha ^