Skip to content

[MRESOLVER-302] Introduce onSessionClose hooks#232

Closed
cstamas wants to merge 2 commits intoapache:masterfrom
cstamas:MRESOLVER-302-onSessionClose
Closed

[MRESOLVER-302] Introduce onSessionClose hooks#232
cstamas wants to merge 2 commits intoapache:masterfrom
cstamas:MRESOLVER-302-onSessionClose

Conversation

@cstamas
Copy link
Copy Markdown
Member

@cstamas cstamas commented Dec 27, 2022

That integrators must integrate, to provide onSessionClosed hooks functionality to any component requiring it.


https://issues.apache.org/jira/browse/MRESOLVER-302

That integrators must integrate, to provide onSessionClosed hooks
functionality to any component requiring it.

---

https://issues.apache.org/jira/browse/MRESOLVER-302
@cstamas cstamas self-assigned this Dec 27, 2022
cstamas added a commit to cstamas/maven that referenced this pull request Dec 27, 2022
@cstamas cstamas marked this pull request as ready for review December 27, 2022 18:38
@cstamas cstamas added this to the 1.9.3 milestone Dec 27, 2022
Comment thread maven-resolver-api/src/main/java/org/eclipse/aether/RepositorySystem.java Outdated
* @param session the session that just ended, never {@code null}.
* @since TBD
*/
void sessionEnded( RepositorySystemSession session );
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

From a consumer perspective a close() method on RSS would be a lot easier and in addition allows to use

  • try with resources
  • semantic code analysis tools to emit a WARN when someone forgot to call close.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is the least painful way with 1.x. Problem is how session instances are created (by client code, using def ctor of DefaultRepositorySystemSession, no factory for it) and derived. Just look thru Maven and plugin sources as example. They are not "boxed" nor are hierarchical, you can get session A and have it "derived" (using copy ctor) into session B and then continue to use it (typical when local repo is overridden in plugins), etc. And then i did not even mention "forwarding" session...

So yes, ideally session would be:

  • created by some factory (repo system, ideally?)
  • closeable

But doing this would be very disruptive, so baby steps... leave these changes for 2.0

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Understood, but the same uncertainty is now applicable to sessionEnded(...). When should consumers call it? What about sessions created with https://maven.apache.org/resolver/apidocs/org/eclipse/aether/DefaultRepositorySystemSession.html#%3Cinit%3E(org.eclipse.aether.RepositorySystemSession)? What about forwarding sessions. The Javadocs need to be extended in this regard.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Given all that I still think that a close() on RepositorySystemSession is preferable.
The different implementations need to implement that method differently:

  • DefaultRepositorySystemSession.close() should really do the cleanup in case it has been created from scratch
  • DefaultRepositorySystemSession.close() should be a noop in case it has been created via copy constructor
  • AbstractForwardingRepositorySystemSession.close() should be a noop

Doing this should be fully backwards compatible and still expose an API which is much easier to digest.

* <p>
* <en>Same session instance can be started only once.</em>
*
* @param session the session that is about to start, never {@code null}.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why can’t this be transparently handled whenever RSS is created?

@cstamas cstamas requested review from gnodet, kwin and michael-o December 29, 2022 14:11
@cstamas cstamas modified the milestones: 1.9.3, 1.10.0 Jan 5, 2023
@michael-o michael-o removed their request for review January 18, 2023 19:03
@cstamas
Copy link
Copy Markdown
Member Author

cstamas commented Nov 8, 2023

Superseded by #357

@cstamas cstamas closed this Nov 8, 2023
@cstamas cstamas deleted the MRESOLVER-302-onSessionClose branch November 8, 2023 16:09
@jira-importer
Copy link
Copy Markdown

Resolve #974

1 similar comment
@jira-importer
Copy link
Copy Markdown

Resolve #974

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.

3 participants