Update JsonMappingExceptionMapper “Early EOF” logic
This commit is contained in:
parent
dcfca4d95e
commit
cf307db31d
|
@ -3,15 +3,15 @@ package org.whispersystems.textsecuregcm.mappers;
|
||||||
import com.fasterxml.jackson.databind.JsonMappingException;
|
import com.fasterxml.jackson.databind.JsonMappingException;
|
||||||
import javax.ws.rs.core.Response;
|
import javax.ws.rs.core.Response;
|
||||||
import javax.ws.rs.ext.ExceptionMapper;
|
import javax.ws.rs.ext.ExceptionMapper;
|
||||||
import java.util.concurrent.TimeoutException;
|
|
||||||
|
|
||||||
public class JsonMappingExceptionMapper implements ExceptionMapper<JsonMappingException> {
|
public class JsonMappingExceptionMapper implements ExceptionMapper<JsonMappingException> {
|
||||||
@Override
|
@Override
|
||||||
public Response toResponse(final JsonMappingException exception) {
|
public Response toResponse(final JsonMappingException exception) {
|
||||||
if (exception.getCause() instanceof TimeoutException) {
|
if (exception.getCause() instanceof java.util.concurrent.TimeoutException) {
|
||||||
return Response.status(Response.Status.REQUEST_TIMEOUT).build();
|
return Response.status(Response.Status.REQUEST_TIMEOUT).build();
|
||||||
}
|
}
|
||||||
if ("Early EOF".equals(exception.getMessage())) {
|
if (exception.getCause() instanceof org.eclipse.jetty.io.EofException
|
||||||
|
|| exception.getMessage() != null && exception.getMessage().startsWith("Early EOF")) {
|
||||||
// Some sort of timeout or broken connection
|
// Some sort of timeout or broken connection
|
||||||
return Response.status(Response.Status.BAD_REQUEST).build();
|
return Response.status(Response.Status.BAD_REQUEST).build();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue