← Back to Pull requests

Defer reading the OpenAPI spec until it is first requested #569

Open
unknown opened this pull request with 259 lines diff across 3 files
View on GitHub
unknown unknown commented on Nov 10, 2026 03:01 UTC
Author

What

SwaggerServlet.init no longer calls .read() on the OpenAPI context it builds. It still registers the configuration (title, description, and the resource classes to document).

Why

SwaggerServlet doesn't serve anything; its only job is to register the OpenAPI configuration. The spec is served by swagger's OpenApiResource inside Jersey. On its first request, OpenApiResource looks up a context under its own servlet's id. It doesn't find one, so it creates a child context whose parent is the default context SwaggerServlet registered, and reads the spec again. The spec read at startup was never used.

Evidence: with the current code, the first /api/openapi.json request already takes ~460 ms (and the first /api/4.7.0/openapi.json ~230 ms), even though SwaggerServlet had just read the spec during startup.

Results

Apple M4, JDK 25, default Derby config, no channels; warm medians of 5 runs:

| | Before | After |
|---|---|---|
| SwaggerServlet.init | ~660 ms | ~120 ms |
| Jetty start() | ~1170 ms | ~620 ms |
| Launch → "Web server running at" | ~4.46 s | ~3.64 s |
| First /api/openapi.json request | ~460 ms | ~700 ms |
| Later /api/openapi.json requests | ~15 ms | ~15 ms |

The cost of the first spec request moves from startup to whoever requests it first (normally someone opening the Swagger UI).

Verification

  • /api/openapi.json, /api/4.7.0/openapi.json and /api/openapi.yaml all return 200 with the "Open Integration Engine Client API" title.

  • The served JSON and YAML have identical content before and after once keys are sorted (jq -S). The raw bytes differ, but key order already varies between two runs of unmodified code.

  • ./gradlew :server:test: 834 of 836 pass. The two failures (TcpDispatcherTest.testMLLPMessageSent, testMessageSentWhenOneOfMultipleClientsClosed) are a BindException on the test's ports, which count up from 9000. On my machine IntelliJ listens on 9000/9003, so these fail on unmodified main as well.
  • 🤖 Generated with Claude Code

    Diff: 259 lines (+194 / -65) across 3 files Reviewer: tonygermano Review duration: 31273m
    All Vouch review confidence checks passed
    Residual risk 0.22 = Change Risk (0.39) × (1 − Review Confidence (0.43)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.39 · 259 lines diff across 3 files
    0.39
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    42%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Shallow Review Depth shallow_review_depth
    0.344
    Diff Size diff_size
    0.333
    Real PR Conversation Timeline
    1 comments
    "Review active on #569"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 43.0% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 39.2% (MEDIUM) · Higher = larger blast radius
    39.2%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 43.0% · Lower = rushed or shallow review
    43.0%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 22.4% · Safe to merge
    22.4%