Skip to content

NoSuchMethodError when querying sparse vectors on Java 8 #1779

@chocoboxxf

Description

@chocoboxxf

Environment

  • Runtime: Java 8 (observed from stack trace: java.lang.Thread.run(Thread.java:750))
  • Milvus Java SDK: io.milvus:milvus-sdk-java:2.6.15 (also reproducible with 2.6.14 depending on the classpath, see below)
  • API: Query (v2 client), requesting a sparse vector field in OutputFields

Problem
When performing a Query that returns sparse vector fields, the application crashes with a NoSuchMethodError:

java.lang.NoSuchMethodError: java.nio.ByteBuffer.rewind()Ljava/nio/ByteBuffer;
    at io.milvus.param.ParamUtils.decodeSparseFloatVector(ParamUtils.java:1332)
    at io.milvus.response.FieldDataWrapper.getVectorData(FieldDataWrapper.java:326)
    at io.milvus.response.FieldDataWrapper.getFieldDataInternal(FieldDataWrapper.java:244)
    at io.milvus.response.FieldDataWrapper.getFieldData(FieldDataWrapper.java:231)
    at io.milvus.response.FieldDataWrapper.valueByIdx(FieldDataWrapper.java:506)
    at io.milvus.response.basic.RowRecordWrapper.buildRowRecord(RowRecordWrapper.java:82)
    at io.milvus.response.QueryResultsWrapper.buildRowRecord(QueryResultsWrapper.java:94)
    at io.milvus.response.QueryResultsWrapper.getRowRecords(QueryResultsWrapper.java:78)
    at io.milvus.v2.utils.ConvertUtils.getEntities(ConvertUtils.java:86)
    at io.milvus.v2.service.vector.VectorService.query(VectorService.java:248)
    ...

How to reproduce

  1. Run an application on Java 8 that uses milvus-sdk-java 2.6.15.
  2. Query a collection and include a sparse vector field in OutputFields (or otherwise trigger decoding of sparse vectors).
  3. The query fails with NoSuchMethodError shown above.

Expected behavior
Query should succeed and return entities (including sparse vectors) on Java 8.

Observed behavior
Query fails at runtime with NoSuchMethodError in ParamUtils.decodeSparseFloatVector while decoding sparse vectors.

Suspected root cause
This looks like a Java 8 compatibility issue caused by an incompatible method descriptor used by the SDK at runtime:

  • On Java 8, java.nio.ByteBuffer.rewind() returns java.nio.Buffer (i.e., the method is rewind()Ljava/nio/Buffer;).
  • The runtime error indicates the SDK is trying to call ByteBuffer.rewind() with the descriptor ()Ljava/nio/ByteBuffer;, which corresponds to the covariant return type introduced in later JDKs (Java 9+).
  • Therefore, when running on Java 8, the JVM cannot resolve ByteBuffer.rewind(): ByteBuffer, causing NoSuchMethodError.

Workarounds

  • Build milvus-sdk-java-2.6.x.jar using Java 8

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions