-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Indicate when errors represent timeouts #124936
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
5a5ae12
22ce589
7be87c9
a8fb873
7bdc917
50674a5
7eb388d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| pr: 124936 | ||
| summary: Indicate when errors represent timeouts | ||
| area: Infra/REST API | ||
| type: enhancement | ||
| issues: [] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1552,4 +1552,35 @@ private void testExceptionLoop(Exception rootException) throws IOException { | |
| assertThat(ser.getMessage(), equalTo(rootException.getMessage())); | ||
| assertArrayEquals(ser.getStackTrace(), rootException.getStackTrace()); | ||
| } | ||
|
|
||
| static class ExceptionSubclass extends ElasticsearchException { | ||
| @Override | ||
| public boolean isTimeout() { | ||
| return true; | ||
| } | ||
|
|
||
| ExceptionSubclass(String message) { | ||
| super(message); | ||
| } | ||
| } | ||
|
|
||
| public void testTimeout() throws IOException { | ||
| var e = new ExceptionSubclass("some timeout"); | ||
| assertThat(e.getHeaderKeys(), hasItem(ElasticsearchException.TIMED_OUT_HEADER)); | ||
|
|
||
| XContentBuilder builder = XContentFactory.jsonBuilder(); | ||
| builder.startObject(); | ||
| e.toXContent(builder, ToXContent.EMPTY_PARAMS); | ||
| builder.endObject(); | ||
| String expected = """ | ||
| { | ||
| "type": "exception_subclass", | ||
| "reason": "some timeout", | ||
| "timed_out": true, | ||
| "header": { | ||
| "X-Timed-Out": "true" | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we always render headers, do we need a separate
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was surprised to learn we have this header map. It's kind of odd we have it in the first place. Accessing it in this case would mean looking for
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep that's why I felt my two comments were mutually exclusive :) |
||
| }"""; | ||
| assertEquals(XContentHelper.stripWhitespace(expected), Strings.toString(builder)); | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RFC 8941 §4.1.9 specifies the string
?1for a true boolean value in a HTTP header field.