Skip to content

'Any' type not supported as a type by protobuf #199

Open
@jfuehner

Description

@jfuehner

Hi! I have the below generic object that I use as a wrapper around other objects when sending a response.

public class Response<T> {
    private T data;

    public Response() {

    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}

When I try to generate a byte buffer from the Response object with the below code I receive the error, 'Any' type not supported as a type by protobuf

        ObjectMapper mapper = new ObjectMapper(new ProtobufFactory());
        ProtobufSchemaGenerator generator = new ProtobufSchemaGenerator();
        mapper.acceptJsonFormatVisitor(Response.class, generator);
        ProtobufSchema schema = generator.getGeneratedSchema();

        Response<DataFeedCollection> response = new Response<>();

        byte[] bytes = mapper.writer(schema).writeValueAsBytes(response);
        ByteBuffer buffer = ByteBuffer.wrap(bytes);

        session.sendMessage(new BinaryMessage(buffer));

Are generics not supported? Would there be an alternative to this generics approach?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions