{"record":{"id":"89c08d744d5ae0ed","repo":"apache/cassandra","slug":"missing-host","errorCode":null,"errorMessage":"Missing host","messagePattern":"Missing host","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/transport/Server.java","lineNumber":292,"sourceCode":"        }\n\n        public Server build()\n        {\n            return new Server(this);\n        }\n\n        private InetSocketAddress getSocket()\n        {\n            if (this.socket != null)\n                return this.socket;\n            else\n            {\n                if (this.port == -1)\n                    throw new IllegalStateException(\"Missing port number\");\n                if (this.hostAddr != null)\n                    this.socket = new InetSocketAddress(this.hostAddr, this.port);\n                else\n                    throw new IllegalStateException(\"Missing host\");\n                return this.socket;\n            }\n        }\n    }\n\n    public static class ConnectionTracker implements Connection.Tracker\n    {\n        private static final ChannelMatcher PRE_V5_CHANNEL = channel -> channel.attr(Connection.attributeKey)\n                                                                               .get()\n                                                                               .getVersion()\n                                                                               .isSmallerThan(ProtocolVersion.V5);\n\n        // TODO: should we be using the GlobalEventExecutor or defining our own?\n        public final ChannelGroup allChannels = new DefaultChannelGroup(GlobalEventExecutor.INSTANCE);\n        private final EnumMap<Event.Type, ChannelGroup> groups = new EnumMap<>(Event.Type.class);\n        private final ProtocolVersionTracker protocolVersionTracker = new ProtocolVersionTracker();\n        private final BooleanSupplier isRunning;\n","sourceCodeStart":274,"sourceCodeEnd":310,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/transport/Server.java#L274-L310","documentation":"Thrown by Server.getSocket() when a port was provided but no host address was set, so the builder cannot construct the bind InetSocketAddress. Like the missing-port case, it surfaces as an IllegalStateException at server start rather than at builder time, indicating incomplete server configuration.","triggerScenarios":"Server.Builder built with port(...) but no hostAddr and no explicit socket; getSocket() reaches the else branch because this.hostAddr is null while this.port != -1.","commonSituations":"Embedding the transport in tests/tools with only a port configured, refactoring away a host constant, or assuming the server will default to binding all interfaces (it will not here).","solutions":["Call Server.Builder.host(InetAddress) (or equivalent) with the address to bind, e.g. the local RPC address","Or supply a full InetSocketAddress via the socket(...) builder method","Use InetAddress.getLoopbackAddress() in test harnesses if binding to all interfaces is not intended","Validate builder fields before start() in embedding code"],"exampleFix":"// before\nServer.builder().withPort(9042).build();\n// after\nServer.builder().withPort(9042).withHost(InetAddress.getLocalHost()).build();","handlingStrategy":"validation","validationCode":"if (builderHost == null) throw new IllegalArgumentException(\"Server.Builder requires a host; call host(...) or socket(...)\");","typeGuard":"boolean readyToBuild(Server.Builder b) { return b.getHostAddr() != null && b.getPort() != -1; }","tryCatchPattern":"try { server.start(); } catch (IllegalStateException e) { if (e.getMessage().equals(\"Missing host\")) { fixBuilderConfig(); } else throw e; }","preventionTips":["Set host and port together in one helper to avoid partial configuration","Default to the RPC address from config rather than leaving host null","Cover server construction with a smoke test","Validate builder completeness before start()"],"tags":["configuration","builder","missing-host","native-transport"],"backgroundTag":"missing-required-argument","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}