eclipse-vertx/vert.x · error · NullPointerException

Null delegate not allowed

Error message

Null delegate not allowed

What it means

VertxWrapper is an abstract base for decorators around VertxInternal; its constructor rejects a null delegate immediately. Wrapping a null Vertx instance is a programming error, so it throws NullPointerException at construction time rather than failing later on first delegate use.

Source

Thrown at vertx-core/src/main/java/io/vertx/core/internal/VertxWrapper.java:69

import java.util.concurrent.TimeUnit;
import java.util.function.Supplier;

/**
 * A wrapper class that delegates all method calls to the {@link #delegate} instance.
 *
 * Implementing the {@link Vertx} interface is not encouraged however if that is necessary, implementations
 * should favor extending this class to ensure minimum breakage when new methods are added to the interace.
 *
 * The delegate instance can be accessed using protected final {@link #delegate} field, any method of the {@code Vertx}
 * interface can be overridden.
 */
public abstract class VertxWrapper implements VertxInternal {

  protected final VertxInternal delegate;

  protected VertxWrapper(VertxInternal delegate) {
    if (delegate == null) {
      throw new NullPointerException("Null delegate not allowed");
    }
    this.delegate = delegate;
  }

  @Override
  public <C> CloseableResource<C> registerResource(CloseableResource<C> resource) {
    return delegate.registerResource(resource);
  }

  @Override
  public <C extends io.vertx.core.internal.Closeable> CloseableResource<C> createSharedResource(String resourceKey, String resourceName, Supplier<C> factory) {
    return delegate.createSharedResource(resourceKey, resourceName, factory);
  }

  @Override
  public NetServer createNetServer(TcpServerConfig config, ServerSSLOptions sslOptions) {
    return delegate.createNetServer(config, sslOptions);
  }

View on GitHub (pinned to fb308bd8c3)

Solutions

  1. Pass a non-null VertxInternal, e.g. (VertxInternal) vertx or Vertx.builder().build()
  2. Check the value for null before constructing the wrapper and fail with a clear message at the wiring site
  3. Fix the DI/factory configuration so the Vertx instance is actually produced

Example fix

// before
new MyVertxWrapper(lookupVertx()); // may return null
// after
VertxInternal v = lookupVertx();
Objects.requireNonNull(v, "vertx instance missing");
new MyVertxWrapper(v);
Defensive patterns

Strategy: validation

Validate before calling

Objects.requireNonNull(vertxInternal, "Vertx instance must not be null before wrapping");

Try / catch

try { new MyWrapper(v); } catch (NullPointerException e) { failFast("Vertx not initialized"); }

Prevention

When it happens

Trigger: Calling a subclass constructor such as new VertxImplWrapper(null) or passing a null result from a factory/lookup (e.g. an unset Vertx holder) into any VertxWrapper subclass.

Common situations: Dependency injection wiring where the Vertx bean was not created; static holder field never initialized; refactoring that removed the Vertx.builder().build() call.

Related errors


AI-assisted analysis of eclipse-vertx/vert.x@fb308bd8c3 (2026-09-06). Data as JSON: /api/errors/1f393b44e811723f. Report an issue: GitHub.