Remove Jackson dependency from TransportHandler hierarchy
Prior to this change, AbstractHttpReceivingTransportHandler had a direct dependency on a Jacckson Exception (checking that exception in a catch clause). This can cause issues for applications that don't have that dependency. This commit removes that direct dependency, still logging the appropriate log messages using a parent exception (IOException) and reflection. Issue: SPR-11963
This commit is contained in:
parent
55c351523d
commit
e549103ca0
|
|
@ -19,8 +19,6 @@ package org.springframework.web.socket.sockjs.transport.handler;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.JsonMappingException;
|
|
||||||
|
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.http.server.ServerHttpRequest;
|
import org.springframework.http.server.ServerHttpRequest;
|
||||||
|
|
@ -56,14 +54,15 @@ public abstract class AbstractHttpReceivingTransportHandler extends AbstractTran
|
||||||
try {
|
try {
|
||||||
messages = readMessages(request);
|
messages = readMessages(request);
|
||||||
}
|
}
|
||||||
catch (JsonMappingException ex) {
|
|
||||||
logger.error("Failed to read message", ex);
|
|
||||||
handleReadError(response, "Payload expected.", sockJsSession.getId());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
catch (IOException ex) {
|
catch (IOException ex) {
|
||||||
logger.error("Failed to read message", ex);
|
if(ex.getClass().getName().contains("Mapping")) {
|
||||||
handleReadError(response, "Broken JSON encoding.", sockJsSession.getId());
|
logger.error("Failed to read message", ex);
|
||||||
|
handleReadError(response, "Payload expected.", sockJsSession.getId());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
logger.error("Failed to read message", ex);
|
||||||
|
handleReadError(response, "Broken JSON encoding.", sockJsSession.getId());
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
catch (Throwable ex) {
|
catch (Throwable ex) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue