eventmesh icon indicating copy to clipboard operation
eventmesh copied to clipboard

[ISSUE #3009] Method manually handles closing an auto-closeable resource [MetricsHandler]

Open sanskar-thakur opened this issue 2 years ago • 4 comments
trafficstars

Fixes #3009 .

Modifications

Replaced finally block with try-with-resources.

  1. Used try-with-resources along with nested try-catch to manage resources, fixing out of scope variable.
  2. Added similar fix for issue#3007 and issue#3008 to fix compilation error due to out of scope variable in catch block.

Please include this fix to solve compilation issue occurred due to #3007 and #3008

Documentation

  • Does this pull request introduce a new feature? (no)
  • If yes, how is the feature documented? (not applicable)
  • If a feature is not applicable for documentation, explain why? (bug fix)
  • If a feature is not documented yet in this PR, please create a followup issue for adding the documentation (not applicable)

sanskar-thakur avatar Mar 28 '23 16:03 sanskar-thakur

Here you may still have to use try-with-finally, using try-with-resources will be due to the scope of the variable, here in the catch there is out.write(result.getBytes()); this line of code is reported as an error. Do you have a better suggestion?

Alonexc avatar Mar 29 '23 08:03 Alonexc

Linked to #3544, PR overlapped. @sanskar-thakur

mytang0 avatar Mar 30 '23 07:03 mytang0

@Pil0tXia this pr seems to be merged after the second reviewer reviews

scwlkq avatar Jan 20 '24 15:01 scwlkq

Please resolve conflicts.

Pil0tXia avatar Jan 20 '24 15:01 Pil0tXia

completed in #4800

pandaapo avatar Mar 22 '24 09:03 pandaapo