You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "cstamas (via GitHub)" <gi...@apache.org> on 2023/11/08 16:01:12 UTC

[PR] [MRESOLVER-302] Introduce onSessionClose [maven-resolver]

cstamas opened a new pull request, #357:
URL: https://github.com/apache/maven-resolver/pull/357

   And make it use in new HTTP/2 transports.
   
   Note about implementation:
   * code integrating resolver (like Maven) 2 SHOULD switch to new session handling
   * code using resolver w/ managing it (like Mojos) does NOT have to move to new session handling (basically that code may work unchanged).
   
   In short, the R1 session handling is still present, but is deprecated and will emit warnings if application integrating Resolver 2.x still uses Resolver 1.x session handling and is about to use new Resolver 2.x features (like HTTP/2 transport) that require onSessionClose (and will produce leaks, unless they are one-time CLI apps).
   
   ---
   
   https://issues.apache.org/jira/browse/MRESOLVER-302


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [MRESOLVER-302] Introduce onSessionClose [maven-resolver]

Posted by "cstamas (via GitHub)" <gi...@apache.org>.
cstamas commented on code in PR #357:
URL: https://github.com/apache/maven-resolver/pull/357#discussion_r1386915751


##########
maven-resolver-transport-jdk-parent/maven-resolver-transport-jdk-11/src/main/java/org/eclipse/aether/transport/jdk/JdkHttpTransporter.java:
##########
@@ -417,7 +421,14 @@ protected PasswordAuthentication getPasswordAuthentication() {
                         });
                     }
 
-                    return builder.build();
+                    HttpClient result = builder.build();
+                    // Only possible in Java21

Review Comment:
   There is already another PR that tackles this area: https://github.com/apache/maven-resolver/pull/356
   IMO we should merge that, and then this PR should just raise build time JDK requirement to Java 21 and uncomment these lines.
   
   Also, some changes will be needed to customizer, to be able to register hook for client close as well (PR #356 adds the customizer)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [MRESOLVER-302] Introduce onSessionClose [maven-resolver]

Posted by "cstamas (via GitHub)" <gi...@apache.org>.
cstamas commented on code in PR #357:
URL: https://github.com/apache/maven-resolver/pull/357#discussion_r1386892496


##########
maven-resolver-api/src/main/java/org/eclipse/aether/RepositorySystemSession.java:
##########
@@ -48,6 +51,350 @@
  */
 public interface RepositorySystemSession {
 
+    /**
+     * Immutable session that is closeable, can have onClose handlers registered and should be handled as a resource.
+     * These session instances can be created with {@link SessionBuilder}.
+     *
+     * @since TBD
+     */
+    interface CloseableRepositorySystemSession extends RepositorySystemSession, Closeable {

Review Comment:
   because that will suddenly emit warning in all the existing code (think Mojos) that "using closeable reasource without try-with-resource" or alike. Closing session is really objective of "resolver managing" client code (like Maven), but "resolver using (but not managing it)" client code (like Maven Mojos) should really not be annoyed is session closeable or not, they should NEVER close it anyway,



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [MRESOLVER-302] Introduce onSessionClose [maven-resolver]

Posted by "kwin (via GitHub)" <gi...@apache.org>.
kwin commented on code in PR #357:
URL: https://github.com/apache/maven-resolver/pull/357#discussion_r1386937750


##########
maven-resolver-api/src/main/java/org/eclipse/aether/RepositorySystem.java:
##########
@@ -304,8 +314,26 @@ List<RemoteRepository> newResolutionRepositories(
      * When shutdown happens, all the registered on-close handlers will be invoked (even if some throws), and at end
      * of operation a {@link MultiRuntimeException} may be thrown, signaling that some handler(s) failed. This exception
      * may be ignored, is at the discretion of caller.
+     * <p>
+     * Note: this method actually just calls {@link #close()}.
      *
      * @since 1.9.0
+     * @deprecated Use {@link #close()} instead.
      */
+    @Deprecated
     void shutdown();
+
+    /**
+     * Signals to repository system to shut down. Shut down instance is not usable anymore.
+     * <p>
+     * Repository system may perform some resource cleanup, if applicable. Not using this method may cause leaks or
+     * unclean shutdown of some subsystem.
+     * <p>
+     * When shutdown happens, all the registered on-close handlers will be invoked (even if some throws), and at end
+     * of operation a {@link MultiRuntimeException} may be thrown, signaling that some handler(s) failed. This exception
+     * may be ignored, is at the discretion of caller.
+     *
+     * @since TBD
+     */
+    void close();

Review Comment:
   Ok, but then I fail to see how a default method calling `shutdown(...)` may break backwards compatibility.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [MRESOLVER-302] Introduce onSessionClose [maven-resolver]

Posted by "gnodet (via GitHub)" <gi...@apache.org>.
gnodet commented on code in PR #357:
URL: https://github.com/apache/maven-resolver/pull/357#discussion_r1386866973


##########
maven-resolver-api/src/main/java/org/eclipse/aether/RepositorySystem.java:
##########
@@ -304,8 +314,26 @@ List<RemoteRepository> newResolutionRepositories(
      * When shutdown happens, all the registered on-close handlers will be invoked (even if some throws), and at end
      * of operation a {@link MultiRuntimeException} may be thrown, signaling that some handler(s) failed. This exception
      * may be ignored, is at the discretion of caller.
+     * <p>
+     * Note: this method actually just calls {@link #close()}.
      *
      * @since 1.9.0
+     * @deprecated Use {@link #close()} instead.
      */
+    @Deprecated
     void shutdown();
+
+    /**
+     * Signals to repository system to shut down. Shut down instance is not usable anymore.
+     * <p>
+     * Repository system may perform some resource cleanup, if applicable. Not using this method may cause leaks or
+     * unclean shutdown of some subsystem.
+     * <p>
+     * When shutdown happens, all the registered on-close handlers will be invoked (even if some throws), and at end
+     * of operation a {@link MultiRuntimeException} may be thrown, signaling that some handler(s) failed. This exception
+     * may be ignored, is at the discretion of caller.
+     *
+     * @since TBD
+     */
+    void close();

Review Comment:
   Do we want:
   ```
   default void close() {
       shutdown();
   }
   ```
   This would help with compatibility, but I don't think anyone is _implementing_ this interface, right ? Maybe wrapped ?



##########
maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultRepositorySystemLifecycle.java:
##########
@@ -69,6 +74,59 @@ public void addOnSystemEndedHandler(Runnable handler) {
         onSystemEndedHandlers.add(0, handler);
     }
 
+    @Override
+    public void sessionStarted(CloseableRepositorySystemSession session) {
+        requireNonNull(session, "session cannot be null");
+        requireNotShutdown();
+        String sessionId = session.sessionId();
+        onSessionEndedHandlers.compute(sessionId, (k, v) -> {
+            if (v != null) {
+                throw new IllegalStateException("session instance already registered");
+            }
+            return new CopyOnWriteArrayList<>();
+        });
+    }
+
+    @Override
+    public void sessionEnded(CloseableRepositorySystemSession session) {
+        requireNonNull(session, "session cannot be null");
+        requireNotShutdown();
+        String sessionId = session.sessionId();
+        ArrayList<Runnable> handlers = new ArrayList<>();
+        onSessionEndedHandlers.compute(sessionId, (k, v) -> {
+            if (v == null) {
+                throw new IllegalStateException("session instance not registered");
+            }
+            handlers.addAll(v);

Review Comment:
   Why not `handlers = v;` ? and initialize `handlers = Collections.emptyList()` ?



##########
maven-resolver-transport-jdk-parent/maven-resolver-transport-jdk-11/src/main/java/org/eclipse/aether/transport/jdk/JdkHttpTransporter.java:
##########
@@ -417,7 +421,14 @@ protected PasswordAuthentication getPasswordAuthentication() {
                         });
                     }
 
-                    return builder.build();
+                    HttpClient result = builder.build();
+                    // Only possible in Java21

Review Comment:
   What's the plan here ? Should that be compiled with JDK 21 and with a check on the JDK used at runtime ?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [MRESOLVER-302] Introduce onSessionClose [maven-resolver]

Posted by "kwin (via GitHub)" <gi...@apache.org>.
kwin commented on code in PR #357:
URL: https://github.com/apache/maven-resolver/pull/357#discussion_r1386875573


##########
maven-resolver-api/src/main/java/org/eclipse/aether/RepositorySystem.java:
##########
@@ -304,8 +314,26 @@ List<RemoteRepository> newResolutionRepositories(
      * When shutdown happens, all the registered on-close handlers will be invoked (even if some throws), and at end
      * of operation a {@link MultiRuntimeException} may be thrown, signaling that some handler(s) failed. This exception
      * may be ignored, is at the discretion of caller.
+     * <p>
+     * Note: this method actually just calls {@link #close()}.
      *
      * @since 1.9.0
+     * @deprecated Use {@link #close()} instead.
      */
+    @Deprecated
     void shutdown();
+
+    /**
+     * Signals to repository system to shut down. Shut down instance is not usable anymore.
+     * <p>
+     * Repository system may perform some resource cleanup, if applicable. Not using this method may cause leaks or
+     * unclean shutdown of some subsystem.
+     * <p>
+     * When shutdown happens, all the registered on-close handlers will be invoked (even if some throws), and at end
+     * of operation a {@link MultiRuntimeException} may be thrown, signaling that some handler(s) failed. This exception
+     * may be ignored, is at the discretion of caller.
+     *
+     * @since TBD
+     */
+    void close();

Review Comment:
   What about a default implementation just calling shutdown()?



##########
maven-resolver-api/src/main/java/org/eclipse/aether/RepositorySystemSession.java:
##########
@@ -48,6 +51,350 @@
  */
 public interface RepositorySystemSession {
 
+    /**
+     * Immutable session that is closeable, can have onClose handlers registered and should be handled as a resource.
+     * These session instances can be created with {@link SessionBuilder}.
+     *
+     * @since TBD
+     */
+    interface CloseableRepositorySystemSession extends RepositorySystemSession, Closeable {

Review Comment:
   why not making the `RepositorySystemSession` always implement `Closeable` with an empty default method `close()`



##########
maven-resolver-api/src/main/java/org/eclipse/aether/RepositorySystem.java:
##########
@@ -304,8 +314,26 @@ List<RemoteRepository> newResolutionRepositories(
      * When shutdown happens, all the registered on-close handlers will be invoked (even if some throws), and at end
      * of operation a {@link MultiRuntimeException} may be thrown, signaling that some handler(s) failed. This exception
      * may be ignored, is at the discretion of caller.
+     * <p>
+     * Note: this method actually just calls {@link #close()}.
      *
      * @since 1.9.0
+     * @deprecated Use {@link #close()} instead.
      */
+    @Deprecated
     void shutdown();
+
+    /**
+     * Signals to repository system to shut down. Shut down instance is not usable anymore.
+     * <p>
+     * Repository system may perform some resource cleanup, if applicable. Not using this method may cause leaks or
+     * unclean shutdown of some subsystem.
+     * <p>
+     * When shutdown happens, all the registered on-close handlers will be invoked (even if some throws), and at end
+     * of operation a {@link MultiRuntimeException} may be thrown, signaling that some handler(s) failed. This exception
+     * may be ignored, is at the discretion of caller.
+     *
+     * @since TBD
+     */

Review Comment:
   ```suggestion
        */
        @Override
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [MRESOLVER-302] Introduce onSessionClose [maven-resolver]

Posted by "kwin (via GitHub)" <gi...@apache.org>.
kwin commented on code in PR #357:
URL: https://github.com/apache/maven-resolver/pull/357#discussion_r1386938264


##########
maven-resolver-api/src/main/java/org/eclipse/aether/RepositorySystem.java:
##########
@@ -304,8 +314,26 @@ List<RemoteRepository> newResolutionRepositories(
      * When shutdown happens, all the registered on-close handlers will be invoked (even if some throws), and at end
      * of operation a {@link MultiRuntimeException} may be thrown, signaling that some handler(s) failed. This exception
      * may be ignored, is at the discretion of caller.
+     * <p>
+     * Note: this method actually just calls {@link #close()}.
      *
      * @since 1.9.0
+     * @deprecated Use {@link #close()} instead.
      */
+    @Deprecated
     void shutdown();
+
+    /**
+     * Signals to repository system to shut down. Shut down instance is not usable anymore.
+     * <p>
+     * Repository system may perform some resource cleanup, if applicable. Not using this method may cause leaks or
+     * unclean shutdown of some subsystem.
+     * <p>
+     * When shutdown happens, all the registered on-close handlers will be invoked (even if some throws), and at end
+     * of operation a {@link MultiRuntimeException} may be thrown, signaling that some handler(s) failed. This exception
+     * may be ignored, is at the discretion of caller.
+     *
+     * @since TBD
+     */
+    void close();

Review Comment:
   This is already discussed in https://github.com/apache/maven-resolver/pull/357#discussion_r1386875573 :-)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [MRESOLVER-302] Introduce onSessionClose [maven-resolver]

Posted by "cstamas (via GitHub)" <gi...@apache.org>.
cstamas commented on code in PR #357:
URL: https://github.com/apache/maven-resolver/pull/357#discussion_r1386889932


##########
maven-resolver-api/src/main/java/org/eclipse/aether/RepositorySystem.java:
##########
@@ -304,8 +314,26 @@ List<RemoteRepository> newResolutionRepositories(
      * When shutdown happens, all the registered on-close handlers will be invoked (even if some throws), and at end
      * of operation a {@link MultiRuntimeException} may be thrown, signaling that some handler(s) failed. This exception
      * may be ignored, is at the discretion of caller.
+     * <p>
+     * Note: this method actually just calls {@link #close()}.
      *
      * @since 1.9.0
+     * @deprecated Use {@link #close()} instead.
      */
+    @Deprecated
     void shutdown();
+
+    /**
+     * Signals to repository system to shut down. Shut down instance is not usable anymore.
+     * <p>
+     * Repository system may perform some resource cleanup, if applicable. Not using this method may cause leaks or
+     * unclean shutdown of some subsystem.
+     * <p>
+     * When shutdown happens, all the registered on-close handlers will be invoked (even if some throws), and at end
+     * of operation a {@link MultiRuntimeException} may be thrown, signaling that some handler(s) failed. This exception
+     * may be ignored, is at the discretion of caller.
+     *
+     * @since TBD
+     */
+    void close();

Review Comment:
   is considered "incompatible binary change" by japicmp and i kinda agree with it



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [MRESOLVER-302] Introduce onSessionClose [maven-resolver]

Posted by "kwin (via GitHub)" <gi...@apache.org>.
kwin commented on code in PR #357:
URL: https://github.com/apache/maven-resolver/pull/357#discussion_r1386901050


##########
maven-resolver-api/src/main/java/org/eclipse/aether/RepositorySystem.java:
##########
@@ -304,8 +314,26 @@ List<RemoteRepository> newResolutionRepositories(
      * When shutdown happens, all the registered on-close handlers will be invoked (even if some throws), and at end
      * of operation a {@link MultiRuntimeException} may be thrown, signaling that some handler(s) failed. This exception
      * may be ignored, is at the discretion of caller.
+     * <p>
+     * Note: this method actually just calls {@link #close()}.
      *
      * @since 1.9.0
+     * @deprecated Use {@link #close()} instead.
      */
+    @Deprecated
     void shutdown();
+
+    /**
+     * Signals to repository system to shut down. Shut down instance is not usable anymore.
+     * <p>
+     * Repository system may perform some resource cleanup, if applicable. Not using this method may cause leaks or
+     * unclean shutdown of some subsystem.
+     * <p>
+     * When shutdown happens, all the registered on-close handlers will be invoked (even if some throws), and at end
+     * of operation a {@link MultiRuntimeException} may be thrown, signaling that some handler(s) failed. This exception
+     * may be ignored, is at the discretion of caller.
+     *
+     * @since TBD
+     */
+    void close();

Review Comment:
   Well IMHO it is more binary backwards incompatible to add a new method without default impl to an interface which is exposed (and can potentially be implemented by anyone). In reality the default impl almost never causes any issues, for details refer to https://docs.oracle.com/javase/specs/jls/se11/html/jls-13.html#jls-13.5.6.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [MRESOLVER-302] Introduce onSessionClose [maven-resolver]

Posted by "cstamas (via GitHub)" <gi...@apache.org>.
cstamas commented on code in PR #357:
URL: https://github.com/apache/maven-resolver/pull/357#discussion_r1386923270


##########
maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultRepositorySystemLifecycle.java:
##########
@@ -69,6 +74,59 @@ public void addOnSystemEndedHandler(Runnable handler) {
         onSystemEndedHandlers.add(0, handler);
     }
 
+    @Override
+    public void sessionStarted(CloseableRepositorySystemSession session) {
+        requireNonNull(session, "session cannot be null");
+        requireNotShutdown();
+        String sessionId = session.sessionId();
+        onSessionEndedHandlers.compute(sessionId, (k, v) -> {
+            if (v != null) {
+                throw new IllegalStateException("session instance already registered");
+            }
+            return new CopyOnWriteArrayList<>();
+        });
+    }
+
+    @Override
+    public void sessionEnded(CloseableRepositorySystemSession session) {
+        requireNonNull(session, "session cannot be null");
+        requireNotShutdown();
+        String sessionId = session.sessionId();
+        ArrayList<Runnable> handlers = new ArrayList<>();
+        onSessionEndedHandlers.compute(sessionId, (k, v) -> {
+            if (v == null) {
+                throw new IllegalStateException("session instance not registered");
+            }
+            handlers.addAll(v);

Review Comment:
   that would make `handlers` non-immutable, no? This is within lambda...



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [MRESOLVER-302] Introduce onSessionClose [maven-resolver]

Posted by "cstamas (via GitHub)" <gi...@apache.org>.
cstamas commented on code in PR #357:
URL: https://github.com/apache/maven-resolver/pull/357#discussion_r1386915751


##########
maven-resolver-transport-jdk-parent/maven-resolver-transport-jdk-11/src/main/java/org/eclipse/aether/transport/jdk/JdkHttpTransporter.java:
##########
@@ -417,7 +421,14 @@ protected PasswordAuthentication getPasswordAuthentication() {
                         });
                     }
 
-                    return builder.build();
+                    HttpClient result = builder.build();
+                    // Only possible in Java21

Review Comment:
   There is already another PR that tackles this area: https://github.com/apache/maven-resolver/pull/356
   IMO we should merge that, and then this PR should just raise build time JDK requirement to Java 21 and uncomment these lines.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [MRESOLVER-302] Introduce onSessionClose [maven-resolver]

Posted by "cstamas (via GitHub)" <gi...@apache.org>.
cstamas commented on code in PR #357:
URL: https://github.com/apache/maven-resolver/pull/357#discussion_r1386903268


##########
maven-resolver-api/src/main/java/org/eclipse/aether/RepositorySystem.java:
##########
@@ -304,8 +314,26 @@ List<RemoteRepository> newResolutionRepositories(
      * When shutdown happens, all the registered on-close handlers will be invoked (even if some throws), and at end
      * of operation a {@link MultiRuntimeException} may be thrown, signaling that some handler(s) failed. This exception
      * may be ignored, is at the discretion of caller.
+     * <p>
+     * Note: this method actually just calls {@link #close()}.
      *
      * @since 1.9.0
+     * @deprecated Use {@link #close()} instead.
      */
+    @Deprecated
     void shutdown();
+
+    /**
+     * Signals to repository system to shut down. Shut down instance is not usable anymore.
+     * <p>
+     * Repository system may perform some resource cleanup, if applicable. Not using this method may cause leaks or
+     * unclean shutdown of some subsystem.
+     * <p>
+     * When shutdown happens, all the registered on-close handlers will be invoked (even if some throws), and at end
+     * of operation a {@link MultiRuntimeException} may be thrown, signaling that some handler(s) failed. This exception
+     * may be ignored, is at the discretion of caller.
+     *
+     * @since TBD
+     */
+    void close();

Review Comment:
   well, stop a bit: look at interface top and also read this: https://maven.apache.org/resolver/api-compatibility.html
   
   In short: no client is EVER intended to extend or implement this interface. IF someone shoots in his leg afterwards all these warnings, let it be, but is not our fault.



##########
maven-resolver-api/src/main/java/org/eclipse/aether/RepositorySystem.java:
##########
@@ -304,8 +314,26 @@ List<RemoteRepository> newResolutionRepositories(
      * When shutdown happens, all the registered on-close handlers will be invoked (even if some throws), and at end
      * of operation a {@link MultiRuntimeException} may be thrown, signaling that some handler(s) failed. This exception
      * may be ignored, is at the discretion of caller.
+     * <p>
+     * Note: this method actually just calls {@link #close()}.
      *
      * @since 1.9.0
+     * @deprecated Use {@link #close()} instead.
      */
+    @Deprecated
     void shutdown();
+
+    /**
+     * Signals to repository system to shut down. Shut down instance is not usable anymore.
+     * <p>
+     * Repository system may perform some resource cleanup, if applicable. Not using this method may cause leaks or
+     * unclean shutdown of some subsystem.
+     * <p>
+     * When shutdown happens, all the registered on-close handlers will be invoked (even if some throws), and at end
+     * of operation a {@link MultiRuntimeException} may be thrown, signaling that some handler(s) failed. This exception
+     * may be ignored, is at the discretion of caller.
+     *
+     * @since TBD
+     */
+    void close();

Review Comment:
   well, stop for a bit: look at interface top and also read this: https://maven.apache.org/resolver/api-compatibility.html
   
   In short: no client is EVER intended to extend or implement this interface. IF someone shoots in his leg afterwards all these warnings, let it be, but is not our fault.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [MRESOLVER-302] Introduce onSessionClose [maven-resolver]

Posted by "gnodet (via GitHub)" <gi...@apache.org>.
gnodet commented on code in PR #357:
URL: https://github.com/apache/maven-resolver/pull/357#discussion_r1386917972


##########
maven-resolver-api/src/main/java/org/eclipse/aether/RepositorySystem.java:
##########
@@ -304,8 +314,26 @@ List<RemoteRepository> newResolutionRepositories(
      * When shutdown happens, all the registered on-close handlers will be invoked (even if some throws), and at end
      * of operation a {@link MultiRuntimeException} may be thrown, signaling that some handler(s) failed. This exception
      * may be ignored, is at the discretion of caller.
+     * <p>
+     * Note: this method actually just calls {@link #close()}.
      *
      * @since 1.9.0
+     * @deprecated Use {@link #close()} instead.
      */
+    @Deprecated
     void shutdown();
+
+    /**
+     * Signals to repository system to shut down. Shut down instance is not usable anymore.
+     * <p>
+     * Repository system may perform some resource cleanup, if applicable. Not using this method may cause leaks or
+     * unclean shutdown of some subsystem.
+     * <p>
+     * When shutdown happens, all the registered on-close handlers will be invoked (even if some throws), and at end
+     * of operation a {@link MultiRuntimeException} may be thrown, signaling that some handler(s) failed. This exception
+     * may be ignored, is at the discretion of caller.
+     *
+     * @since TBD
+     */
+    void close();

Review Comment:
   I've added meta annotations in the Maven api for that:
     https://maven.apache.org/ref/4.0.0-alpha-8/apidocs/org/apache/maven/api/annotations/Provider.html



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [MRESOLVER-302] Introduce onSessionClose [maven-resolver]

Posted by "cstamas (via GitHub)" <gi...@apache.org>.
cstamas commented on code in PR #357:
URL: https://github.com/apache/maven-resolver/pull/357#discussion_r1386923270


##########
maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultRepositorySystemLifecycle.java:
##########
@@ -69,6 +74,59 @@ public void addOnSystemEndedHandler(Runnable handler) {
         onSystemEndedHandlers.add(0, handler);
     }
 
+    @Override
+    public void sessionStarted(CloseableRepositorySystemSession session) {
+        requireNonNull(session, "session cannot be null");
+        requireNotShutdown();
+        String sessionId = session.sessionId();
+        onSessionEndedHandlers.compute(sessionId, (k, v) -> {
+            if (v != null) {
+                throw new IllegalStateException("session instance already registered");
+            }
+            return new CopyOnWriteArrayList<>();
+        });
+    }
+
+    @Override
+    public void sessionEnded(CloseableRepositorySystemSession session) {
+        requireNonNull(session, "session cannot be null");
+        requireNotShutdown();
+        String sessionId = session.sessionId();
+        ArrayList<Runnable> handlers = new ArrayList<>();
+        onSessionEndedHandlers.compute(sessionId, (k, v) -> {
+            if (v == null) {
+                throw new IllegalStateException("session instance not registered");
+            }
+            handlers.addAll(v);

Review Comment:
   that would make `handlers` ref non-immutable, no? This is within lambda...



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [MRESOLVER-302] Introduce onSessionClose [maven-resolver]

Posted by "cstamas (via GitHub)" <gi...@apache.org>.
cstamas merged PR #357:
URL: https://github.com/apache/maven-resolver/pull/357


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org