Skip to content
Interview rounds

Concurrency & payments · Bug Squash (Java)

The redirect that dropped the payment

A hand-written Java HTTP helper follows redirects, and a POST arrives at the new address with nothing in it. Where is the bug?

BackendSenior12 min
Interview-style scenarioLast reviewed: Checked against official documentation

Bug Squash · Java 21 · GatewayClient.javaIllustrative scenario, not a real incident

Every payment-creation call fails with 400 "empty request" since 09:40

The checkout service creates payments by sending a POST with a JSON document to a payment gateway, through a small helper written in-house two years ago.

At 09:40 the gateway began answering the old host name with a 307 that points to a new host. Since then the new host has rejected every call, 1,240 in 20 minutes. A test that reproduces it is below. No code runs in your browser: read it as you would in a review.

What the dashboards and logs show

Expected at the new host
POST with the 32-byte JSON document
Actual at the new host
GET with no content
Answer from the old host
307 with a Location header naming the new host
Calls sent straight to the new host
succeed

Find the bug · scored under "Hypothesis before change"

Tap the faulty lines

The test below fails. Mark up to 3 lines you would change, then check them. There are 2. A wrong mark costs half a line.

Failing test · postSurvivesA307ToTheNewHost
GatewayClientTest > postSurvivesA307ToTheNewHost() FAILED
    org.opentest4j.AssertionFailedError:
    request received by the new host after a 307
    method expected: <POST> but was: <GET>
    body   expected: <{"amount":4000,"currency":"EUR"}> but was: <>

1 test completed, 1 failed
GatewayClient.java

No line marked yet

Your rubric score, the model answer, the follow-up questions and the related lessons appear once you have answered the last step.