{"record":{"id":"14bf5409062b356a","repo":"nathanmarz/storm","slug":"server-connection-should-not-send-any-messages","errorCode":null,"errorMessage":"Server connection should not send any messages","messagePattern":"Server connection should not send any messages","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"storm-netty/src/jvm/backtype/storm/messaging/netty/Server.java","lineNumber":135,"sourceCode":"     */\n    protected void closeChannel(Channel channel) {\n        channel.close().awaitUninterruptibly();\n        allChannels.remove(channel);\n    }\n\n    /**\n     * close all channels, and release resources\n     */\n    public synchronized void close() {\n        if (allChannels != null) {  \n            allChannels.close().awaitUninterruptibly();\n            factory.releaseExternalResources();\n            allChannels = null;\n        }\n    }\n\n    public void send(int task, byte[] message) {\n        throw new RuntimeException(\"Server connection should not send any messages\");\n    }\n}\n","sourceCodeStart":117,"sourceCodeEnd":138,"githubUrl":"https://github.com/nathanmarz/storm/blob/cdb116e942666973bc4eaa0df098d5bab82739e7/storm-netty/src/jvm/backtype/storm/messaging/netty/Server.java#L117-L138","documentation":"Like the Client, the messaging layer is unidirectional: a Server only receives from clients and never sends. Server.send is implemented as an unconditional throw at Server.java:135 to catch any attempt to push messages out on a server-side connection.","triggerScenarios":"Any call to server.send(task, message) on a backtype.storm.messaging.netty.Server instance — usually generic IConnection-handling code or tests treating a server like a client.","commonSituations":"Shared transport abstraction code that sends on every IConnection regardless of direction; worker code accidentally holding the server-side connection and emitting tuples through it; tests exercising send on a listening socket.","solutions":["Send only via Client connections; use Server solely for receiving.","In generic IConnection code, branch on instanceof Client before calling send.","Create a Client that connects to the target address if bidirectional communication is needed."],"exampleFix":"// before\nserver.send(task, bytes); // always throws\n// after\nclient.connect(remoteAddr);\nclient.send(task, bytes);","handlingStrategy":"type-guard","validationCode":"if (conn instanceof backtype.storm.messaging.netty.Server) { /* do not call send */ }","typeGuard":"boolean isSendingConnection(IConnection c) {\n    return c instanceof backtype.storm.messaging.netty.Client;\n}","tryCatchPattern":"// send on Server is guaranteed to throw; guard with instanceof instead of catching","preventionTips":["Route all outgoing traffic through Client connections.","In IConnection-generic code, assert direction before send/recv.","Keep server and client connection usage in separate code paths."],"tags":["netty","server","api-misuse","messaging"],"backgroundTag":"unsupported-operation","analyzedSha":"cdb116e942666973bc4eaa0df098d5bab82739e7","analyzedAt":"2026-09-12T14:30:00.714Z","contentChangedAt":"2026-09-12T14:30:00.714Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}