From e549103ca0c0d2b9956772e3889a12f168c954ff Mon Sep 17 00:00:00 2001 From: Brian Clozel Date: Mon, 7 Jul 2014 17:29:32 +0200 Subject: [PATCH] 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 --- .../AbstractHttpReceivingTransportHandler.java | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/AbstractHttpReceivingTransportHandler.java b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/AbstractHttpReceivingTransportHandler.java index da451f4a25..c20614e424 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/AbstractHttpReceivingTransportHandler.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/AbstractHttpReceivingTransportHandler.java @@ -19,8 +19,6 @@ package org.springframework.web.socket.sockjs.transport.handler; import java.io.IOException; import java.util.Arrays; -import com.fasterxml.jackson.databind.JsonMappingException; - import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.server.ServerHttpRequest; @@ -56,14 +54,15 @@ public abstract class AbstractHttpReceivingTransportHandler extends AbstractTran try { messages = readMessages(request); } - catch (JsonMappingException ex) { - logger.error("Failed to read message", ex); - handleReadError(response, "Payload expected.", sockJsSession.getId()); - return; - } catch (IOException ex) { - logger.error("Failed to read message", ex); - handleReadError(response, "Broken JSON encoding.", sockJsSession.getId()); + if(ex.getClass().getName().contains("Mapping")) { + 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; } catch (Throwable ex) {