Source:
public void closeEndpoint(int port) { if (sourceHandler != null) { WebsocketSubscriberPathManager pathManager = WebsocketSubscriberPathManager.getInstance(); String endpointName = WebsocketEndpointManager.getInstance().getEndpointName(sourceHandler.getPort(), sourceHandler.getTenantDomain()); Integer shutdownStatusCode; String shutdownStatusMessage; try { MessageContext synCtx = sourceHandler.getSynapseMessageContext(sourceHandler.getTenantDomain()); InboundEndpoint endpoint = synCtx.getConfiguration().getInboundEndpoint(endpointName); shutdownStatusMessage = endpoint.getParametersMap().get("ws.shutdown.status.message"); if (null != endpoint.getParametersMap().get("ws.shutdown.status.code")) { try { shutdownStatusCode = Integer .parseInt(endpoint.getParametersMap().get("ws.shutdown.status.code")); } catch (NumberFormatException ex) { log.warn("Please specify a valid Integer for \"ws.shutdown.status.code\" parameter. Assigning" + " the default value 1001"); shutdownStatusCode = 1001; } } else { shutdownStatusCode = 1001; } if (shutdownStatusMessage == null) { shutdownStatusMessage = "shutdown"; } } catch (AxisFault fault) { log.error("Error while getting synapse message context. "+ fault); throw new SynapseException(fault); } pathManager.broadcastOnSubscriberPath(new CloseWebSocketFrame(shutdownStatusCode, shutdownStatusMessage), endpointName, sourceHandler.getSubscriberPath()); } PrivilegedCarbonContext cc = PrivilegedCarbonContext.getThreadLocalCarbonContext(); String tenantDomain = cc.getTenantDomain(); dataStore.unregisterListeningEndpoint(port, tenantDomain); if (!WebsocketEventExecutorManager.getInstance().isRegisteredExecutor(port)) { log.info("Listener Endpoint is not started"); return; } else if (dataStore.isEndpointRegistryEmpty(port)) { WebsocketEventExecutorManager.getInstance().shutdownExecutor(port); } }

Target:
public void closeEndpoint(int port) { if (sourceHandler != null) { WebsocketSubscriberPathManager pathManager = WebsocketSubscriberPathManager.getInstance(); String endpointName = WebsocketEndpointManager.getInstance().getEndpointName(sourceHandler.getPort(), sourceHandler.getTenantDomain()); Integer shutdownStatusCode; String shutdownStatusMessage; try { MessageContext synCtx = sourceHandler.getSynapseMessageContext(sourceHandler.getTenantDomain()); InboundEndpoint endpoint = synCtx.getConfiguration().getInboundEndpoint(endpointName); shutdownStatusMessage = endpoint.getParametersMap().get("ws.shutdown.status.message"); String shutdownStatusCodeValue = endpoint.getParametersMap().get("ws.shutdown.status.code"); if (shutdownStatusCodeValue != null) { try { shutdownStatusCode = Integer.parseInt(shutdownStatusCodeValue); } catch (NumberFormatException ex) { log.warn("Please specify a valid Integer for \"ws.shutdown.status.code\" parameter. Assigning" + " the default value 1001"); shutdownStatusCode = 1001; } } else { shutdownStatusCode = 1001; } if (shutdownStatusMessage == null) { shutdownStatusMessage = "shutdown"; } } catch (AxisFault fault) { log.error("Error while getting synapse message context. "+ fault); throw new SynapseException(fault); } pathManager.broadcastOnSubscriberPath(new CloseWebSocketFrame(shutdownStatusCode, shutdownStatusMessage), endpointName, sourceHandler.getSubscriberPath()); } PrivilegedCarbonContext cc = PrivilegedCarbonContext.getThreadLocalCarbonContext(); String tenantDomain = cc.getTenantDomain(); dataStore.unregisterListeningEndpoint(port, tenantDomain); if (!WebsocketEventExecutorManager.getInstance().isRegisteredExecutor(port)) { log.info("Listener Endpoint is not started"); return; } else if (dataStore.isEndpointRegistryEmpty(port)) { WebsocketEventExecutorManager.getInstance().shutdownExecutor(port); } }