Skip to content

Conversation

@Pankraz76
Copy link

@Pankraz76 Pankraz76 commented Jun 13, 2025

Java 7 introduced the try-with-resources statement. This statement ensures that each resource is closed at the end of the statement. It avoids the need of explicitly closing the resources in a finally block. Additionally exceptions are better handled: If an exception occurred both in the try block and finally block, then the exception from the try block was suppressed. With the try-with-resources statement, the exception thrown from the try-block is preserved.

need to be cautions with this:

image

@quarkus-bot
Copy link

quarkus-bot bot commented Jun 13, 2025

/cc @brunobat (opentelemetry), @radcortez (opentelemetry)

@quarkus-bot
Copy link

quarkus-bot bot commented Jun 13, 2025

Thanks for your pull request!

Your pull request does not follow our editorial rules. Could you have a look?

  • title should preferably start with an uppercase character (if it makes sense!)

This message is automatically generated by a bot.

@Pankraz76
Copy link
Author

assuming 90 LOC less boilerplate is an simple decision to make. @geoand

happy travelling.

@quarkus-bot

This comment has been minimized.

@Pankraz76
Copy link
Author

will SOC.

@Pankraz76 Pankraz76 closed this Jun 15, 2025
@quarkus-bot quarkus-bot bot added the triage/invalid This doesn't seem right label Jun 15, 2025
if (serverSocket != null) {
try {
serverSocket.close();
} catch (IOException e) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this catch is missing.

throw t;
} finally {
if (currentScope != null) {
currentScope.close();
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is save, as equal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant