cstamas commented on code in PR #383:
URL: https://github.com/apache/maven-resolver/pull/383#discussion_r1414059162


##########
maven-resolver-api/src/main/java/org/eclipse/aether/RepositorySystemSession.java:
##########
@@ -391,20 +378,20 @@ interface SessionBuilder {
         SessionBuilder setData(SessionData data);
 
         /**
-         * Sets the custom session data supplier associated with this session.
+         * Sets the cache the repository system may use to save data for 
future reuse during the session.
          *
-         * @param dataSupplier The session data supplier, may not be {@code 
null}.
+         * @param cache The repository cache, may be {@code null} if none.
          * @return This session for chaining, never {@code null}.
          */
-        SessionBuilder setSessionDataSupplier(Supplier<SessionData> 
dataSupplier);
+        SessionBuilder setCache(RepositoryCache cache);
 
         /**
-         * Sets the cache the repository system may use to save data for 
future reuse during the session.
+         * Sets the custom session data supplier associated with this session.
          *
-         * @param cache The repository cache, may be {@code null} if none.
+         * @param dataSupplier The session data supplier, may not be {@code 
null}.
          * @return This session for chaining, never {@code null}.
          */
-        SessionBuilder setCache(RepositoryCache cache);
+        SessionBuilder setSessionDataSupplier(Supplier<SessionData> 
dataSupplier);

Review Comment:
   Internally supplier is used, and here is why:
   * create one builder
   * create session S1 out of builder
   * create another session S2 out of same builder
   
   This "seemingly" trivial operation without supplier would lead that the S1 
and S2 would use _same data and cache_, leading to hardly debuggable issues. 
Hence, I switched internally to supplier that on each call provides new 
instance (of data and cache), but IF user does use `builder.setCache(cache)` it 
will become `() -> cache` suppliers, so user intentionally can achieve same 
result.
   
   I am may overthinking this, but wanted to avoid this situation (one builder 
used for several session instances).



-- 
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-unsubscr...@maven.apache.org

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

Reply via email to