GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — Use try-with-resources by garydgregory · Pull Request #669 · apache/maven Conversation
Member
Trivial: Make sure resources are closed even when an exception is thrown by using try-with-resources.
mvn clean package OK
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
slachiewicz
approved these changes
gnodet
approved these changes
olamy
approved these changes
Member
Author
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
Tibor17
self-requested a review
Tibor17
reviewed
|
| InputStream is = pluginJar.getInputStream( pluginDescriptorEntry ); | ||
|
|
||
| pluginDescriptor = parsePluginDescriptor( is, plugin, pluginFile.getAbsolutePath() ); | ||
| try ( InputStream is = pluginJar.getInputStream( pluginDescriptorEntry ) ) |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Agree here.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| InputStream is = pluginJar.getInputStream( pluginDescriptorEntry ); | ||
|
|
||
| pluginDescriptor = parsePluginDescriptor( is, plugin, pluginFile.getAbsolutePath() ); | ||
| try ( InputStream is = pluginJar.getInputStream( pluginDescriptorEntry ) ) |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
In line 232 is the bug @Tibor17 has described.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
The first commit should be fixed.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Resolve #8447 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
still in play or should this be closed? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This PR is over 4 years old and the codebase has evolved substantially. In its current form, it cannot merge — all file paths are stale and 2 of the 4 conversions target code that no longer exists.
| File | Status | Details |
|---|---|---|
ProjectBuildingException |
❌ Obsolete | createMessage() was rewritten to use StringBuilder — no more StringWriter/PrintWriter |
DefaultMavenPluginManager |
❌ Obsolete | parsePluginDescriptor now takes a StreamSupplier instead of InputStream — stream lifecycle managed internally |
LegacyRepositorySystem |
✅ Still valid | AuthenticationContext.close() pattern still exists at compat/maven-compat/... (new path) |
MavenRepositorySystem |
✅ Still valid | AuthenticationContext.close() pattern still exists at impl/maven-core/... (new path) |
All four files were moved during the MNG-8346 reorganization (#1837):
maven-compat/... → compat/maven-compat/...maven-core/... → impl/maven-core/...The PR merge state is CONFLICTING.
Given the extent of changes needed (rebase, remove 2 obsolete files, update paths for the remaining 2), it may be simpler to close this PR and open a fresh one with only the two still-applicable AuthenticationContext try-with-resources conversions. The two surviving conversions are genuinely beneficial — they ensure authCtx.close() is called even if an authCtx.get() call throws.
The prior review discussion about double-closing (Tibor17, michael-o) is now moot since the affected methods have been rewritten.
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.
There was an error while loading. Please reload this page.
Reviewed 3 PRs: apache#11185 (namespace validation, needs modello approach), apache#10906 (MSYS path fix, System.out.println + over-broad detection), apache#669 (stale try-with-resources, recommend close). 21 reviews total. Co-Authored-By: Claude Opus 4.6 <[email protected]>
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This 4.5-year-old PR has good intent (try-with-resources for resource safety), but cannot merge in its current state.
1. All 4 file paths have moved (high)
MNG-8346 reorganized subprojects: maven-compat/ → compat/maven-compat/ and maven-core/ → impl/maven-core/. The PR targets paths that no longer exist. Merge state is CONFLICTING.
2. ProjectBuildingException conversion is obsolete (high)
The createMessage() method was rewritten to use StringBuilder — no more StringWriter/PrintWriter to wrap.
3. DefaultMavenPluginManager conversion is obsolete (high)
parsePluginDescriptor now takes a StreamSupplier instead of InputStream — stream lifecycle is managed internally by the builder.
The 4 AuthenticationContext.close() patterns in LegacyRepositorySystem and MavenRepositorySystem are still valid at their new paths. AuthenticationContext implements Closeable, and the current code calls authCtx.close() manually without exception safety — if any authCtx.get() call throws, the context leaks.
Consider closing this PR and opening a fresh one targeting only the 4 AuthenticationContext patterns at the current file paths (compat/maven-compat/... and impl/maven-core/...).
This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.
Claude Code on behalf of gnodet
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Thank you @garydgregory! This PR has been superseded and adapted for all active branches:
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.