[ 
https://issues.apache.org/jira/browse/HADOOP-20048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18139279#comment-18139279
 ] 

ASF GitHub Bot commented on HADOOP-20048:
-----------------------------------------

joseluisll opened a new pull request, #8951:
URL: https://github.com/apache/hadoop/pull/8951

   ### Description of PR
   
   Jetty's StatisticsHandler records a response when the request completes on 
the server side, which can happen after the client has already read the status 
line. Reading responses2xx() once right after getResponseCode() could observe 
the old value and fail with "Expecting <104> to be greater than <104>".
   
   Drain and close the response body so the exchange completes, then wait for 
the 2xx counter to increase with GenericTestUtils.waitFor instead of reading it 
once.
   
   ### How was this patch tested?
   
   The changed modules' tests, run by the Yetus precommit and the fork's CI on 
this branch.
   
   ### For code changes:
   
   - [x] Does the title of this PR start with the corresponding JIRA issue id?
   - [ ] Object storage: not applicable, no object store integration touched.
   - [ ] If adding new dependencies to the code: not applicable, no new 
dependency.
   - [ ] If applicable, have you updated the LICENSE files: not applicable.
   
   ### AI Tooling
   
   If an AI tool was used:
   
   - [x] The PR includes the phrase "Contains content generated by <tool>" 
where <tool> is the name of the AI tool used.
   - [x] My use of AI contributions follows the ASF legal policy 
https://www.apache.org/legal/generative-tooling.html
   
   Contains content generated by Claude Code.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   




> Fix race in TestHttpServer#testHttpServer2Metrics
> -------------------------------------------------
>
>                 Key: HADOOP-20048
>                 URL: https://issues.apache.org/jira/browse/HADOOP-20048
>             Project: Hadoop Common
>          Issue Type: Bug
>          Components: test
>            Reporter: Jose Luis López
>            Priority: Minor
>
> {{TestHttpServer#testHttpServer2Metrics}} is intermittently flaky. It was 
> observed failing once and passing on retry (surefire {{flakyFailure}}) with:
> {noformat}
> java.lang.AssertionError:
> Expecting:
>  <104>
> to be greater than:
>  <104>
> {noformat}
> The test reads {{HttpServer2Metrics#responses2xx()}} immediately after 
> {{conn.getResponseCode()}} returns 200. That counter comes from Jetty's 
> {{StatisticsHandler}}, which records a response when the request completes on 
> the server side. This can happen after the client has already read the status 
> line, so the second read can still return the old value.
> Proposed fix (test-only):
> * read and close the response body, then {{disconnect()}}, so the exchange 
> completes;
> * wait for the counter with {{GenericTestUtils.waitFor(() -> 
> metrics.responses2xx() > before, 10, 10000, ...)}} instead of reading it once.
> The test still checks the same thing: the 2xx counter increases after a 
> successful request. With the fix, the test passed 50/50 runs in separate JVMs 
> with {{-Dsurefire.rerunFailingTestsCount=0}}, and checkstyle reports no new 
> warnings.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to