Repository: camel Updated Branches: refs/heads/master 83139cffe -> d1b2dc3ed
Polished Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/d1b2dc3e Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/d1b2dc3e Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/d1b2dc3e Branch: refs/heads/master Commit: d1b2dc3ed250cec0847440db17a99eefe1ba5f97 Parents: 83139cf Author: Claus Ibsen <davscl...@apache.org> Authored: Sun Sep 4 12:28:52 2016 +0200 Committer: Claus Ibsen <davscl...@apache.org> Committed: Sun Sep 4 12:28:52 2016 +0200 ---------------------------------------------------------------------- .../atmosphere/websocket/WebsocketProducer.java | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/d1b2dc3e/components/camel-atmosphere-websocket/src/main/java/org/apache/camel/component/atmosphere/websocket/WebsocketProducer.java ---------------------------------------------------------------------- diff --git a/components/camel-atmosphere-websocket/src/main/java/org/apache/camel/component/atmosphere/websocket/WebsocketProducer.java b/components/camel-atmosphere-websocket/src/main/java/org/apache/camel/component/atmosphere/websocket/WebsocketProducer.java index 0a62446..14b4875 100644 --- a/components/camel-atmosphere-websocket/src/main/java/org/apache/camel/component/atmosphere/websocket/WebsocketProducer.java +++ b/components/camel-atmosphere-websocket/src/main/java/org/apache/camel/component/atmosphere/websocket/WebsocketProducer.java @@ -39,8 +39,6 @@ public class WebsocketProducer extends DefaultProducer { private static ExecutorService executor = Executors.newSingleThreadExecutor(); - private List<String> notValidConnectionKeys = new ArrayList<>(); - public WebsocketProducer(WebsocketEndpoint endpoint) { super(endpoint); } @@ -98,11 +96,11 @@ public class WebsocketProducer extends DefaultProducer { throw new IllegalArgumentException("Failed to send message to multiple connections; connetion key list is not set."); } - notValidConnectionKeys = new ArrayList<>(); + List<String> notValidConnectionKeys = new ArrayList<>(); for (final String connectionKey : connectionKeyList) { log.debug("Sending to connection key {} -> {}", connectionKey, message); - sendMessage(getWebSocket(connectionKey), message); + sendMessage(getWebSocket(connectionKey, notValidConnectionKeys), message); } if (!notValidConnectionKeys.isEmpty()) { @@ -123,7 +121,7 @@ public class WebsocketProducer extends DefaultProducer { websocket.write((byte[]) message, 0, ((byte[]) message).length); } else { // this should not happen unless one of the supported types is missing above. - LOG.error("unexpected message type {}", message == null ? null : message.getClass()); + LOG.warn("unexpected message type {}", message.getClass()); } } catch (Exception e) { LOG.error("Error when writing to websocket", e); @@ -133,10 +131,10 @@ public class WebsocketProducer extends DefaultProducer { } } - private WebSocket getWebSocket(final String connectionKey) { + private WebSocket getWebSocket(final String connectionKey, final List<String> notValidConnectionKeys) { WebSocket websocket; if (connectionKey == null) { - throw new IllegalArgumentException("Failed to send message to single connection; connetion key is not set."); + throw new IllegalArgumentException("Failed to send message to single connection; connection key is not set."); } else { websocket = getEndpoint().getWebSocketStore().getWebSocket(connectionKey); if (websocket == null) {