Gargi-jais11 commented on PR #9710:
URL: https://github.com/apache/ozone/pull/9710#issuecomment-3858222952
> Thanks @Gargi-jais11 for the review. Applying this change in the outer
catch caused TestS3GatewayMetrics.testListPartsFailure to fail due to
double-counting the failure metric, so I kept the update in listParts() only.
Thanks for this information. I checked the code. What I see is that when
**listParts()** throws an `OMException`, it updates metrics and converts it to
`OS3Exception`, which then propagates to the outer catch block.
To avoid double-counting while still covering `non-OMException cases`, we
can check if the exception is already an OS3Exception before updating metrics
in this way non OM-Exceptions can also we caught :
```
catch (IOException | RuntimeException ex) {
if (uploadId != null) {
// If it's OS3Exception, metrics were already updated in listParts()
// Only update metrics for other exceptions (IOException,
RuntimeException)
if (!(ex instanceof OS3Exception)) {
getMetrics().updateListPartsFailureStats(startNanos);
}
} else {
getMetrics().updateGetKeyFailureStats(startNanos);
}
throw ex;
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]