Skip to content

Commit d5a8c1e

Browse files
authored
Merge pull request #36590 from vespa-engine/bjormel/return-Request-Timeout-on-UncheckedTimeoutException
Return `Request-Timeout` on `UncheckedTimeoutException`
2 parents 97352c4 + 5a7ccb0 commit d5a8c1e

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

configserver/src/main/java/com/yahoo/vespa/config/server/http/HttpHandler.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
22
package com.yahoo.vespa.config.server.http;
33

4+
import com.yahoo.concurrent.UncheckedTimeoutException;
45
import com.yahoo.config.provision.ApplicationLockException;
56
import com.yahoo.config.provision.CertificateNotReadyException;
67
import com.yahoo.config.provision.NodeAllocationException;
@@ -59,7 +60,7 @@ public HttpResponse handle(HttpRequest request) {
5960
return HttpErrorResponse.internalServerError(getMessage(e, request));
6061
} catch (UnknownVespaVersionException e) {
6162
return HttpErrorResponse.unknownVespaVersion(getMessage(e, request));
62-
} catch (RequestTimeoutException e) {
63+
} catch (RequestTimeoutException | UncheckedTimeoutException e) {
6364
return HttpErrorResponse.requestTimeout(getMessage(e, request));
6465
} catch (ApplicationLockException e) {
6566
return HttpErrorResponse.applicationLockFailure(getMessage(e, request));

configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionPrepareHandlerTest.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,21 @@ public void test_that_nullpointerexception_gives_internal_server_error() throws
262262
assertEquals(exceptionMessage, data.get().field("message").asString());
263263
}
264264

265+
@Test
266+
public void test_that_unchecked_timeout_exception_gives_request_timeout() throws IOException {
267+
long sessionId = createSession(applicationId());
268+
String exceptionMessage = "prepare timed out after build models step";
269+
FailingSessionPrepareHandler handler = new FailingSessionPrepareHandler(SessionPrepareHandler.testContext(),
270+
applicationRepository,
271+
configserverConfig,
272+
new UncheckedTimeoutException(exceptionMessage));
273+
HttpResponse response = handler.handle(createTestRequest(pathPrefix, HttpRequest.Method.PUT, Cmd.PREPARED, sessionId));
274+
assertEquals(408, response.getStatus());
275+
Slime data = getData(response);
276+
assertEquals(HttpErrorResponse.ErrorCode.REQUEST_TIMEOUT.name(), data.get().field("error-code").asString());
277+
assertEquals(exceptionMessage, data.get().field("message").asString());
278+
}
279+
265280
@Test
266281
public void test_application_lock_failure() throws IOException {
267282
String exceptionMessage = "Timed out after waiting PT1M to acquire lock '/provision/v1/locks/foo/bar/default'";

0 commit comments

Comments
 (0)