Skip to content

Journal templated and gzip responses as WireMock does - #3

Merged
jgaalen merged 3 commits into
mainfrom
claude/journal-java-parity
Oct 13, 2026
Merged

jgaalen merged 3 commits into
mainfrom
claude/journal-java-parity

Conversation

@jgaalen

@jgaalen jgaalen commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes the two request-journal differences from WireMock 4.0.0-beta.40 found in the Java comparison (previously queued as separate sessions). Served responses were already identical; only /__admin/requests differed.

Case WireMock journals BreakMock before Now
Templated response responseDefinition after templating: rendered headers, rendered body replacing body / jsonBody / bodyFileName the stub's template source as WireMock
Template execution error the error response as responseDefinition; no Connection header the stub; Connection: close logged as WireMock
Gzip response the uncompressed body, no Content-Encoding the compressed bytes and Content-Encoding: gzip as WireMock

For gzip, BreakMock keeps the compressed bytes in the journal and decompresses only when the journal is read, so the API output matches WireMock while journal memory stays small. The rendered definition is built only when the journal is enabled.

Rules were established by probing the pinned JAR: unrendered jsonBody, bodyFileName and base64Body stay as they are; statusMessage is not rendered; disableBodyFileTemplating keeps bodyFileName; key order follows WireMock's model.

Verification

  • scripts/dynamic_template_differential.py gains 16 journal-event comparisons against Java, field by field and in key order (inline, headers, jsonBody, body files, entity data, field order, statusMessage, execution error, not templated, four gzip variants). This branch passes 254/254; main fails exactly the 11 cases these fixes cover.
  • scripts/verify.py against the pinned JAR: all 20 suite runs pass.
  • json_benchmark.py --journal capped --journal-check strict against Java now passes for every large-JSON workload, templates and gzip included.
  • New unit test TestJournalLogsRenderedResponseDefinition pins the Java-captured definitions; TestJournalServesLoggedResponseBodies now asserts uncompressed gzip journaling. go test -race ./..., go vet ./... and the cgo-free tests pass.
  • Performance vs main (in-process, alternating builds): large JSON with journal within −2%…+1%; small templated response with journal +0.6 µs (≈+8% in-process, <1% of HTTP CPU per request) for building the rendered definition; no change with the journal disabled.

Also

journal_concurrency_differential.py also checks invariants on the Java reference, and Java's capped journal occasionally retains one entry too few under concurrency (63 of 64 in 1 of 7 local runs; reruns pass). That exact reference defect — only count checks failing, fewer entries than expected, over-cap phase, reference server — is now recorded as a warning. Every candidate check, and every other reference check, still fails the suite.

The remaining known template gap — Handlebars.java syntax-error handling — is separate.

🤖 Generated with Claude Code

jgaalen and others added 3 commits October 13, 2026 10:06
WireMock journals the response definition after templating and the body
before Jetty compresses it. BreakMock journaled the stub's template source
and the compressed bytes. Match WireMock:

- responseDefinition holds rendered headers, and a rendered body replaces
  body, jsonBody or bodyFileName; unrendered fields are kept. It is built
  only when the journal is enabled.
- A template execution error is journaled as its error response, without
  the Connection header that is written for the client.
- A gzip-encoded response is journaled uncompressed and without
  Content-Encoding. The compressed bytes stay in memory and are decoded only
  when the journal is read.

The dynamic template suite now compares 16 journal events with Java, field
by field and in key order; main fails 11 of them. Java's capped journal can
retain one entry too few under concurrency, so that exact reference defect
is recorded as a warning; all candidate checks still fail the suite.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The "websocket matched received and sent journal" step still failed on CI
intermittently. The CI report shows the reference, not BreakMock, was
incomplete: Java WireMock had journaled the "sent" reply but not yet the
"received" message when the client read the journal right after the reply
frame, while BreakMock returned both events.

Wait until each server's journal reaches the expected number of events
(2, 3 and 4 after the matched, unmatched and binary messages) before
comparing, instead of comparing immediately or after fixed sleeps. A server
that never reaches the count is compared as is after 3 seconds, so real
differences still fail.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A CI run failed before any comparison with "java startup timeout": verify.py
allowed about ten seconds (100 polls) for the JVM to start, which a busy
shared runner occasionally exceeds. Use a 60 second deadline instead.

streaming_differential.py similarly allowed about half a second for a
WebSocket channel to register before indexing it. Wait up to 5 seconds and
fail with a clear message if it never appears.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jgaalen
jgaalen merged commit 504c2a6 into main Oct 13, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant