Skip to content

Bug in Representation ClientResource.get(MediaType mediaType) #1137

Open
@dscoppelletti

Description

@dscoppelletti

If you run the following code:

Reference url = ...
ClientResource client = new ClientResource(url);
client.accept(Language.ENGLISH_US);
client.get(MediaType.APPLICATION_JSON);

The language header is ignored.
This is because of the following overload in the class ClientResource:

protected Representation handle(Method method, Representation entity, MediaType mediaType) {
    return handle(method, entity, new ClientInfo(mediaType));
}

As you can see, the handle method uses a new instance of the ClientInfo object, thus all the properties of the ClientInfo object you can set before are ignored!

Of course, now I am using the following code and it runs properly:

Reference url = ...
ClientResource client = new ClientResource(url);
client.accept(Language.ENGLISH_US);
client.accept(MediaType.APPLICATION_JSON);
client.get();

But I had to dig for discovering this.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions