Skip to content
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

Updated AttributeMap to not close ExecutorService on Java 21 #4649

Merged
merged 4 commits into from
Nov 2, 2023

Conversation

michaeldimchuk
Copy link
Contributor

As of Java 21, ExecutorService extends AutoCloseable, so AttributeMap#close needs to be updated to avoid closing the executor and potentially cause a deadlock.

Motivation and Context

Starting with Java 21, ExecutorService extends the AutoCloseable interface, which causes AttributeMap#close to pick up executor instances and try and close them, which can create deadlocks and cause the application to hang.

Issue: #4395

Modifications

Updated the AttributeMap#close method to first check if the attribute is an ExecutorService, and shut it down if so, otherwise check if the object is closeable and close it if needed.

Testing

  • Added a test case to ensure that ExecutorService instances are explicitly shut down and not closed
  • Added a test case that running AttributeMap#close on a thread owned by an ExecutorService the AttributeMap instance manages does not result in a deadlock
  • Ran all the tests to verify that the changes don't break anything, tested on an M1 MacBook Air with Java 17
  • Validated that the new code does not introduce any new issues and maintains the same expected behavior as before

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Checklist

  • I have read the CONTRIBUTING document
  • Local run of mvn install succeeds
  • My code follows the code style of this project
  • My change requires a change to the Javadoc documentation
  • I have updated the Javadoc documentation accordingly
  • I have added tests to cover my changes
  • All new and existing tests passed
  • I have added a changelog entry. Adding a new entry must be accomplished by running the scripts/new-change script and following the instructions. Commit the new file created by the script in .changes/next-release with your changes.
  • My change is to implement 1.11 parity feature and I have updated LaunchChangelog

License

  • I confirm that this pull request can be released under the Apache 2 license

@michaeldimchuk michaeldimchuk requested a review from a team as a code owner October 31, 2023 16:54
@michaeldimchuk michaeldimchuk mentioned this pull request Oct 31, 2023
12 tasks
@dagnir
Copy link
Contributor

dagnir commented Oct 31, 2023

Thanks @michaeldimchuk, change looks good to me. Let me trigger our tests

@michaeldimchuk
Copy link
Contributor Author

Not totally sure why all the jobs failed on the Configure AWS Credentials stage, only difference I see is that the role-to-assume property is missing from the action inputs (comparing to other builds that passed this stage), but I don't see how this set of changes could've removed that

@dagnir
Copy link
Contributor

dagnir commented Nov 1, 2023

Not totally sure why all the jobs failed on the Configure AWS Credentials stage, only difference I see is that the role-to-assume property is missing from the action inputs (comparing to other builds that passed this stage), but I don't see how this set of changes could've removed that

You're fine, this is expected behavior. Our CI setup doesn't allow auto builds for forked PRs (we have to manually trigger them).

@dagnir
Copy link
Contributor

dagnir commented Nov 1, 2023

Integ test failure because of Maven connection reset. Retrying

@dagnir
Copy link
Contributor

dagnir commented Nov 2, 2023

LGTM, thanks!

@dagnir dagnir enabled auto-merge (squash) November 2, 2023 19:19
@dagnir dagnir merged commit e492916 into aws:master Nov 2, 2023
6 of 13 checks passed
Copy link

sonarcloud bot commented Nov 2, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

100.0% 100.0% Coverage
0.0% 0.0% Duplication

@dagnir
Copy link
Contributor

dagnir commented Nov 2, 2023

@all-contributors please add @michaeldimchuk for code

Copy link
Contributor

@dagnir

I've put up a pull request to add @michaeldimchuk! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants