Skip to content

[BUG] Byte arrays cannot (always) be decoded from the database #586

@lrasku

Description

@lrasku

Which JNoSQL project the issue refers to?

JNoSQL (Core)

Bug description

The Jakarta NoSQL specification says that every NoSQL provider should support byte[]. Serializing byte arrays into a database seems to work, but deserializing them fails with an error like java.lang.UnsupportedOperationException: The type class [B is not supported yet on some backends. A ValueReader implementation could be added to make the support universal?

JNoSQL Version

JNoSQL version 1.1.6

Steps To Reproduce

The following program fragment fails when run against CouchDB, for example:

package org.example;

import jakarta.enterprise.inject.se.SeContainer;
import jakarta.enterprise.inject.se.SeContainerInitializer;
import jakarta.nosql.Column;
import jakarta.nosql.Entity;
import jakarta.nosql.Id;
import jakarta.nosql.Template;

@Entity
public record Failure(
    @Id String id,
    @Column byte[] data
) {
    public static void main(String[] args) {
        try (SeContainer container = SeContainerInitializer.newInstance().initialize()) {
            var template = container.select(Template.class).get();
            
            var failure = new Failure("test", new byte[]{'a','b','c','d'});
            template.insert(failure);

            // Fails with:
            // Exception in thread "main" java.lang.UnsupportedOperationException: The type class java.time.Instant is not supported yet
            template.find(Failure.class, "test").get().data();
        }
    }
}

Expected Results

The program should quit silently & successfully.

Code example, screenshot, or link to a repository

See the attached .zip file for a Docker Compose project demonstrating the problem.

  1. Run the (unzipped) project with docker compose up --build -V.
  2. The app-1 container will exit with an exception after database initialization completes, which may take a few seconds. In the logs, this will look like:

app-1 | Mar 27, 2025 9:15:55 PM org.jboss.weld.environment.se.WeldContainer shutdown
app-1 | INFO: WELD-ENV-002001: Weld SE container fcc5f9cb-9638-422e-a22d-32e815e69ccf shut down
app-1 | Exception in thread "main" java.lang.UnsupportedOperationException: The type class [B is not supported yet
app-1 | at org.eclipse.jnosql.communication.ValueReaderDecorator.lambda$read$2(ValueReaderDecorator.java:56)
app-1 | at java.base/java.util.Optional.orElseThrow(Optional.java:403)
app-1 | at org.eclipse.jnosql.communication.ValueReaderDecorator.read(ValueReaderDecorator.java:55)
app-1 | at org.eclipse.jnosql.communication.DefaultValue.get(DefaultValue.java:48)
app-1 | at org.eclipse.jnosql.communication.semistructured.DefaultElement.get(DefaultElement.java:27)
app-1 | at org.eclipse.jnosql.mapping.semistructured.ParameterConverter$1.lambda$convert$1(ParameterConverter.java:44)
app-1 | at java.base/java.util.Optional.ifPresentOrElse(Optional.java:198)
app-1 | at org.eclipse.jnosql.mapping.semistructured.ParameterConverter$1.convert(ParameterConverter.java:41)
app-1 | at org.eclipse.jnosql.mapping.semistructured.EntityConverter.lambda$convertEntityByConstructor$9(EntityConverter.java:192)
app-1 | at java.base/java.util.Optional.ifPresentOrElse(Optional.java:196)
app-1 | at org.eclipse.jnosql.mapping.semistructured.EntityConverter.convertEntityByConstructor(EntityConverter.java:187)
app-1 | at org.eclipse.jnosql.mapping.semistructured.EntityConverter.toEntity(EntityConverter.java:141)
app-1 | at org.eclipse.jnosql.mapping.semistructured.DefaultEntityConverter$Proxy$_$$WeldClientProxy.toEntity(Unknown Source)
app-1 | at org.eclipse.jnosql.mapping.semistructured.AbstractSemiStructuredTemplate.lambda$executeQuery$6(AbstractSemiStructuredTemplate.java:290)
app-1 | at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
app-1 | at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
app-1 | at java.base/java.util.ArrayList$ArrayListSpliterator.tryAdvance(ArrayList.java:1685)
app-1 | at java.base/java.util.stream.StreamSpliterators$WrappingSpliterator.lambda$initPartialTraversalState$0(StreamSpliterators.java:292)
app-1 | at java.base/java.util.stream.StreamSpliterators$AbstractWrappingSpliterator.fillBuffer(StreamSpliterators.java:206)
app-1 | at java.base/java.util.stream.StreamSpliterators$AbstractWrappingSpliterator.doAdvance(StreamSpliterators.java:161)
app-1 | at java.base/java.util.stream.StreamSpliterators$WrappingSpliterator.tryAdvance(StreamSpliterators.java:298)
app-1 | at java.base/java.util.Spliterators$1Adapter.hasNext(Spliterators.java:681)
app-1 | at org.eclipse.jnosql.mapping.semistructured.AbstractSemiStructuredTemplate.singleResult(AbstractSemiStructuredTemplate.java:174)
app-1 | at org.eclipse.jnosql.mapping.semistructured.AbstractSemiStructuredTemplate.find(AbstractSemiStructuredTemplate.java:197)
app-1 | at org.eclipse.jnosql.mapping.document.DefaultDocumentTemplate$Proxy$
$$_WeldClientProxy.find(Unknown Source)
app-1 | at org.example.Failure.main(Failure.java:24)
app-1 exited with code 1

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions