You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Tamas Cservenak (Jira)" <ji...@apache.org> on 2022/10/11 12:36:00 UTC

[jira] [Updated] (MRESOLVER-278) Session should be explicitly closed, and introduce onCloseHanlders

     [ https://issues.apache.org/jira/browse/MRESOLVER-278?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Tamas Cservenak updated MRESOLVER-278:
--------------------------------------
    Description: 
So far, in (vanilla) Maven, the lifecycle of session was on par with lifecycle of SISU container, as Maven does something like this:
 * boot, create container
 * create session
 * work
 * destroy container
 * exit JVM

So, Maven execution is 1 session 1 container, are on par.

This is not true for cases where container (and resolver components) are reused across several sessions, like mvnd does. Also, current code on master (named locks adapter) uses {{@PreDestroy}} to shut down adapters, that is invoked when container is shut down, while the adapters are created per-session.

While Maven has "session scoped" notion, resolver has not. Hence, simplest and cleanest solution is to make RepositorySystemSession have a method to "close", denoting that "this session is done" (but should not be AutoCloseable or Closeable!). Also, if we can provide hooks for "onSessionClose", this resolves all the problems, as for example the adapter, that is created per session, could be now cleanly shut down at session end.

One gotcha: this change implies a breaking change, integrator is resolver library should make sure they close the session after they are done with it.

  was:
So far, in (vanilla) Maven, the lifecycle of session was on par with lifecycle of SISU container, as Maven does something like this:
 * boot, create container
 * create session
 * work
 * destroy container
 * exit JVM

So, Maven execution is 1 session 1 container, are on par.

This is not true for cases where container (and resolver components) are reused across several sessions, like mvnd does. Also, currentl code on master (named locks adapter) uses {{@PreDestroy}} to shut down adapters, that is invoked when container is shut down, while the adapters are created per-session.

While Maven has "session scoped" notion, resolver has not. Hence, simplest and cleanest solution is to make RepositorySystemSession have a method to "close", denoting that "this session is done" (but should not be AutoCloseable or Closeable!). Also, if we can provide hooks for "onSessionClose", this resolves all the problems, as for example the adapter, that is created per session, could be now cleanly shut down at session end.

One gotcha: this change implies a breaking change, integrator is resolver library should make sure they close the session after they are done with it.


> Session should be explicitly closed, and introduce onCloseHanlders
> ------------------------------------------------------------------
>
>                 Key: MRESOLVER-278
>                 URL: https://issues.apache.org/jira/browse/MRESOLVER-278
>             Project: Maven Resolver
>          Issue Type: Improvement
>          Components: Resolver
>            Reporter: Tamas Cservenak
>            Priority: Major
>             Fix For: resolver-next
>
>
> So far, in (vanilla) Maven, the lifecycle of session was on par with lifecycle of SISU container, as Maven does something like this:
>  * boot, create container
>  * create session
>  * work
>  * destroy container
>  * exit JVM
> So, Maven execution is 1 session 1 container, are on par.
> This is not true for cases where container (and resolver components) are reused across several sessions, like mvnd does. Also, current code on master (named locks adapter) uses {{@PreDestroy}} to shut down adapters, that is invoked when container is shut down, while the adapters are created per-session.
> While Maven has "session scoped" notion, resolver has not. Hence, simplest and cleanest solution is to make RepositorySystemSession have a method to "close", denoting that "this session is done" (but should not be AutoCloseable or Closeable!). Also, if we can provide hooks for "onSessionClose", this resolves all the problems, as for example the adapter, that is created per session, could be now cleanly shut down at session end.
> One gotcha: this change implies a breaking change, integrator is resolver library should make sure they close the session after they are done with it.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)