quarkusio/quarkus · error · IllegalStateException

No order set

Error message

No order set

What it means

RouteBuildItem.getOrder returns the build item's ordering priority, but only if one was explicitly set via the builder's order(); otherwise the OptionalInt is empty and this IllegalStateException is thrown. Consumers (e.g. route conversion) require an order to sort routes deterministically.

Source

Thrown at extensions/vertx-http/deployment-spi/src/main/java/io/quarkus/vertx/http/deployment/spi/RouteBuildItem.java:137

        this.notFoundPageTitle = builder.notFoundPageTitle;
        this.routeConfigKey = builder.routeConfigKey;
        this.customizer = builder.customizer;
        this.isManagement = builder.isManagement;
    }

    public RouteType getTypeOfRoute() {
        return typeOfRoute;
    }

    public boolean hasOrder() {
        return order.isPresent();
    }

    public int getOrder() {
        if (order.isPresent()) {
            return order.getAsInt();
        } else {
            throw new IllegalStateException("No order set");
        }
    }

    public boolean hasRouteConfigKey() {
        return routeConfigKey != null;
    }

    public String getRouteConfigKey() {
        return routeConfigKey;
    }

    public Handler<RoutingContext> getHandler() {
        return handler;
    }

    public HandlerType getHandlerType() {
        return typeOfHandler;
    }

View on GitHub (pinned to e1c734241f)

Solutions

  1. Set an explicit order when building the route: RouteBuildItem.builder().route(...).order(DEFAULT_ROUTE_ORDER)
  2. Check order().isPresent() before calling getOrder
  3. Pick a sensible constant such as RouteBuildItem.DEFAULT_ROUTE_ORDER or a named ordinal constant

Example fix

// before
RouteBuildItem item = RouteBuildItem.builder().route(route).build();
// after
RouteBuildItem item = RouteBuildItem.builder().route(route).order(RouteBuildItem.DEFAULT_ROUTE_ORDER).build();
Defensive patterns

Strategy: type-guard

Validate before calling

if (routeBuildItem.order().isPresent()) {
    int order = routeBuildItem.getOrder();
}

Type guard

static boolean hasOrder(RouteBuildItem item) {
    return item.order().isPresent();
}

Prevention

When it happens

Trigger: Calling getOrder() (directly or via convert) on a RouteBuildItem built without RouteBuildItem.Builder.order(int).

Common situations: Custom extension build step creating a route item and forgetting to set an order; downstream build step consuming routes assuming an order was always assigned; refactors replacing a default order with an OptionalInt.

Related errors


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/ef2b4be92514b407. Report an issue: GitHub.