{"record":{"id":"75d0f4d3d10a3dd9","repo":"eclipse-vertx/vert.x","slug":"no-null-bind-local-address","errorCode":null,"errorMessage":"No null bind local address","messagePattern":"No null bind local address","errorType":"validation","errorClass":"NullPointerException","httpStatus":null,"severity":"error","filePath":"vertx-core/src/main/java/io/vertx/core/net/impl/tcp/NetServerImpl.java","lineNumber":166,"sourceCode":"  }\n\n  @Override\n  public Future<Void> shutdown(Duration timeout) {\n    ConnectionGroup group = channelGroup;\n    if (group == null) {\n      return vertx.getOrCreateContext().succeededFuture();\n    }\n    return group.shutdown(timeout);\n  }\n\n  @Override\n  public Future<NetServer> listen(SocketAddress localAddress) {\n    return listen(vertx.getOrCreateContext(), localAddress);\n  }\n\n  public Future<NetServer> listen(ContextInternal context, SocketAddress localAddress) {\n    if (localAddress == null) {\n      throw new NullPointerException(\"No null bind local address\");\n    }\n    if (handler == null) {\n      throw new IllegalStateException(\"Set connect handler first\");\n    }\n    return bind(context, localAddress).map(this);\n  }\n\n  @Override\n  public Future<NetServer> listen() {\n    return listen(config.getPort(), config.getHost());\n  }\n\n  public boolean isClosed() {\n    return !isListening();\n  }\n\n  private class NetSocketInitializer {\n","sourceCodeStart":148,"sourceCodeEnd":184,"githubUrl":"https://github.com/eclipse-vertx/vert.x/blob/fb308bd8c3f12c79f4ae89bef67fadf6c80d036e/vertx-core/src/main/java/io/vertx/core/net/impl/tcp/NetServerImpl.java#L148-L184","documentation":"listen(SocketAddress) requires an explicit bind address; passing null cannot be turned into a meaningful bind target inside the implementation. Vert.x throws NullPointerException with this message as a fail-fast precondition check rather than failing deep inside Netty at bind time.","triggerScenarios":"Passing a null SocketAddress to listen(SocketAddress) or listen(ContextInternal, SocketAddress), often from an uninitialized config field or a failed address-parsing step that returned null.","commonSituations":"Configuration where the host/port block is absent and the address is built as null; a resolver helper returning null on invalid input; forgetting the listen(port) convenience overload exists.","solutions":["Pass a real SocketAddress, e.g. SocketAddress.inetSocketAddress(port, host)","Default missing config to a concrete address such as new port with host \"0.0.0.0\"","Use the listen(int port) or listen() overloads when no explicit address object is needed"],"exampleFix":"// before\nSocketAddress addr = parseAddress(config); // may return null\nserver.listen(addr); // NPE\n// after\nSocketAddress addr = parseAddress(config);\nif (addr == null) addr = SocketAddress.inetSocketAddress(1234, \"0.0.0.0\");\nserver.listen(addr);","handlingStrategy":"validation","validationCode":"Objects.requireNonNull(addr, \"bind address must not be null\");\n// or before building:\nif (addr == null) addr = SocketAddress.inetSocketAddress(defaultPort, \"0.0.0.0\");","typeGuard":"// Java has no type system null narrowing; use Objects.requireNonNull(addr)","tryCatchPattern":"try {\n  server.listen(addr);\n} catch (NullPointerException e) {\n  // addr was null: fall back to default bind address\n}","preventionTips":["Never let address parsing return null — use Optional<SocketAddress>","Provide defaults for missing host/port config","Prefer listen(port)/listen(port, host) overloads to avoid managing address objects"],"tags":["vertx","null","listen","argument-check"],"backgroundTag":"null-argument","analyzedSha":"fb308bd8c3f12c79f4ae89bef67fadf6c80d036e","analyzedAt":"2026-09-06T11:37:12.241Z","contentChangedAt":"2026-09-06T11:37:12.241Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}