JoseHdez_2
JoseHdez_2

Reputation: 4171

javax.ws.rs.core.Response.readEntity() stuck in infinite loop

I'm using Foo f = response.readEntity(Foo.class) to get an entity from a javax.ws.rs.core.Response object.

The problem is that the statement is seemingly stuck in a loop (using 100% of the CPU according to htop) until the JVM finally terminates from lack of memory.

I've tried looking into it with the debugger, but the function is time-sensitive and the service throws a TimeoutException when I try to execute a step-by-step trace.

Upvotes: 0

Views: 1201

Answers (2)

Anand Ganesh
Anand Ganesh

Reputation: 341

I don't think 1K of data can be deemed inordinate :) I opened this https://github.com/eclipse-ee4j/jersey/issues/4081 with a reproducer (mentioned in the issue) about a week ago. In my case the client isn't using 100% of the CPU; it is blocked on readEntity()

Upvotes: 0

JoseHdez_2
JoseHdez_2

Reputation: 4171

The problem was not directly related to the readEntity() function: the query parameters weren't being sent correctly to the API, so the search arguments ended up being null in the SQL query. This, coupled with the default behavior of the database being to return the complete dataset if no arguments were passed, resulted in the readEntity() method being passed too many entries to process (neither infinite nor a loop).

If anyone else ever has a readEntity() freeze up, consider the possibility that you are inadvertently passing an inordinate amount of data in the Response object.

Upvotes: 1

Related Questions