{"record":{"id":"0a6102d2d9d777cf","repo":"eclipse-vertx/vert.x","slug":"no-null-chunk-accepted","errorCode":null,"errorMessage":"no null chunk accepted","messagePattern":"no null chunk accepted","errorType":"validation","errorClass":"NullPointerException","httpStatus":null,"severity":"error","filePath":"vertx-core/src/main/java/io/vertx/core/http/impl/HttpClientRequestImpl.java","lineNumber":497,"sourceCode":"    }\n    promise.complete(resp);\n  }\n\n  @Override\n  public Future<Void> end(String chunk) {\n    return write(BufferInternal.buffer(chunk), true);\n  }\n\n  @Override\n  public Future<Void> end(String chunk, String enc) {\n    Objects.requireNonNull(enc, \"no null encoding accepted\");\n    return write(BufferInternal.buffer(chunk, enc), true);\n  }\n\n  @Override\n  public Future<Void> end(Buffer chunk) {\n    if (chunk == null) {\n      throw new NullPointerException(\"no null chunk accepted\");\n    }\n    return write(chunk, true);\n  }\n\n  @Override\n  public Future<Void> end() {\n    return write(null, true);\n  }\n\n  @Override\n  public Future<Void> write(Buffer chunk) {\n    if (chunk == null) {\n      throw new NullPointerException(\"no null chunk accepted\");\n    }\n    return write(chunk, false);\n  }\n\n  @Override","sourceCodeStart":479,"sourceCodeEnd":515,"githubUrl":"https://github.com/eclipse-vertx/vert.x/blob/fb308bd8c3f12c79f4ae89bef67fadf6c80d036e/vertx-core/src/main/java/io/vertx/core/http/impl/HttpClientRequestImpl.java#L479-L515","documentation":"end(Buffer) throws a NullPointerException when passed a null buffer, because ending a request with a null final chunk is not supported. The overload end() with no arguments must be used to end the request without a body chunk.","triggerScenarios":"Calling request.end(null) directly, or passing a variable that is null (e.g. an absent request body) to end(Buffer).","commonSituations":"Code that reads a body into a Buffer that may be null on some paths then calls end(buffer); generic wrappers that forward a nullable payload to end().","solutions":["Call request.end() with no arguments when there is no final chunk","Guard for null before calling end and fall back to the no-arg end()","Ensure the buffer-producing code never yields null (use Buffer.buffer() for empty)"],"exampleFix":"// before\nrequest.end(maybeNullBuffer);\n// after\nif (maybeNullBuffer != null) {\n  request.end(maybeNullBuffer);\n} else {\n  request.end();\n}","handlingStrategy":"type-guard","validationCode":"if (chunk == null) { request.end(); return; }","typeGuard":"void safeEnd(HttpClientRequest req, Buffer chunk) {\n  if (chunk != null) req.end(chunk); else req.end();\n}","tryCatchPattern":"try {\n  request.end(chunk);\n} catch (NullPointerException e) {\n  request.end();\n}","preventionTips":["Use end() (no-arg) when there is no final body chunk","Use Buffer.buffer() for an empty body instead of null","Add null checks where bodies come from nullable sources"],"tags":["null","buffer","http-client"],"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"}