eclipse-vertx/vert.x · error · NullPointerException
no null chunk accepted
Error message
no null chunk accepted
What it means
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.
Source
Thrown at vertx-core/src/main/java/io/vertx/core/http/impl/HttpClientRequestImpl.java:497
}
promise.complete(resp);
}
@Override
public Future<Void> end(String chunk) {
return write(BufferInternal.buffer(chunk), true);
}
@Override
public Future<Void> end(String chunk, String enc) {
Objects.requireNonNull(enc, "no null encoding accepted");
return write(BufferInternal.buffer(chunk, enc), true);
}
@Override
public Future<Void> end(Buffer chunk) {
if (chunk == null) {
throw new NullPointerException("no null chunk accepted");
}
return write(chunk, true);
}
@Override
public Future<Void> end() {
return write(null, true);
}
@Override
public Future<Void> write(Buffer chunk) {
if (chunk == null) {
throw new NullPointerException("no null chunk accepted");
}
return write(chunk, false);
}
@OverrideView on GitHub (pinned to fb308bd8c3)
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)
Example fix
// before
request.end(maybeNullBuffer);
// after
if (maybeNullBuffer != null) {
request.end(maybeNullBuffer);
} else {
request.end();
} Defensive patterns
Strategy: type-guard
Validate before calling
if (chunk == null) { request.end(); return; } Type guard
void safeEnd(HttpClientRequest req, Buffer chunk) {
if (chunk != null) req.end(chunk); else req.end();
} Try / catch
try {
request.end(chunk);
} catch (NullPointerException e) {
request.end();
} Prevention
- 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
When it happens
Trigger: Calling request.end(null) directly, or passing a variable that is null (e.g. an absent request body) to end(Buffer).
Common situations: 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().
Related errors
- <index> + <size> > <length>
- Invalid url:
- Client is closed
- HTTP client must be configured for at least one HTTP version
- Only socket address are currently supported
AI-assisted analysis of eclipse-vertx/vert.x@fb308bd8c3 (2026-09-06).
Data as JSON: /api/errors/0a6102d2d9d777cf.
Report an issue: GitHub.