GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [4.0.x] Use try-with-resources for AuthenticationContext by slachiewicz · Pull Request #12844 · apache/maven

Conversation

@slachiewicz

@slachiewicz slachiewicz commented Aug 26, 2026

Copy link
Copy Markdown
Member

Make sure AuthenticationContext instances are properly closed even when exceptions are thrown during property retrieval, using try-with-resources.

Backport / rebase of #12843 for maven-4.0.x:

  • The AuthenticationContext try-with-resources conversions in LegacyRepositorySystem and MavenRepositorySystem are applied for current paths (compat/maven-compat and impl/maven-core).
  • Added try-with-resources conversion for LegacyRepositorySystemSessionExtender.

Related: #669, #12843

  • I hereby declare this contribution to be licenced under the Apache License Version 2.0, January 2004

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@slachiewicz
Use try-with-resources for AuthenticationContext
104c0c8
Closes #669
This was referenced Aug 26, 2026
[3.9.x] Use try-with-resources #12846
Merged
Use try-with-resources #669
Closed
gnodet
gnodet approved these changes Aug 26, 2026
View reviewed changes

@gnodet gnodet left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Clean backport of #12843 — the diff is byte-for-byte identical to the master PR. All six AuthenticationContext call sites across three files are correctly converted from manual close() to try-with-resources, ensuring proper resource cleanup on exception paths.

The return-inside-try-with-resources pattern is safe: the Authentication result object is fully constructed before close() runs, and AuthenticationContext.close() does not invalidate already-retrieved String values.

📋 PR Metadata

Aspect Current Suggested
Labels (none) bug (matching original #12843)
Milestone (none) 4.0.0-rc-7

🔀 Backport Status

✅ All branches covered:

  • master — #12843 (open)
  • maven-4.0.x — this PR
  • maven-3.10.x — #12845 (open)
  • maven-3.9.x — #12846 (open)

This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.

Claude Code on behalf of Guillaume Nodet

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@slachiewicz
slachiewicz merged commit b273836 into maven-4.0.x Aug 26, 2026
21 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@slachiewicz
slachiewicz deleted the feature/maven-4.0.x-try-with-resources branch August 26, 2026 16:22
@github-actions github-actions Bot added this to the 4.0.0-rc-7 milestone Aug 26, 2026
@github-actions github-actions Bot assigned slachiewicz Aug 26, 2026
@slachiewicz slachiewicz added the maintenance label Aug 26, 2026
@apache apache deleted a comment from github-actions Bot Aug 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@gnodet gnodet gnodet approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@slachiewicz slachiewicz

Labels

maintenance

Projects

None yet

Milestone

4.0.0-rc-7

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@slachiewicz @gnodet
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.