Skip to content

Commit

Permalink
[MRESOLVER-278] On session close reworked (#209)
Browse files Browse the repository at this point in the history
Drops problematic onSessionClose, keeps only onSystemClose support. Issue will be adjusted accordingly.

Key changes:
* undone all related to onSessionClose
* kept onRepositorySystemClose + shutdown
* all 3 users on onSessionClose (locking + 2 "recording" features) will act on shutdown
* moved out of session.data use as it is completely unreliable, now singleton components hold caches (hence the shutdown persistence)
* DefaultSyncContext: fixed as explained, does not use system properties anymore, but is made pretty much same as before #196
* renamed all new components to `camelCase`

----

https://issues.apache.org/jira/browse/MRESOLVER-278
  • Loading branch information
cstamas authored Oct 28, 2022
1 parent 505b4c8 commit 0572277
Show file tree
Hide file tree
Showing 26 changed files with 741 additions and 587 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
Expand All @@ -20,7 +20,6 @@
*/

import java.util.Map;
import java.util.function.Consumer;

import org.eclipse.aether.artifact.ArtifactTypeRegistry;
import org.eclipse.aether.collection.DependencyGraphTransformer;
Expand All @@ -41,10 +40,10 @@

/**
* A special repository system session to enable decorating or proxying another session. To do so, clients have to
* create a subclass and implement {@link #getSession()}.
* create a subclass and implement {@link #getSession()}, and optionally override other methods.
*/
public abstract class AbstractForwardingRepositorySystemSession
implements RepositorySystemSession
implements RepositorySystemSession
{

/**
Expand All @@ -58,7 +57,7 @@ protected AbstractForwardingRepositorySystemSession()
* Gets the repository system session to which this instance forwards calls. It's worth noting that this class does
* not save/cache the returned reference but queries this method before each forwarding. Hence, the session
* forwarded to may change over time or depending on the context (e.g. calling thread).
*
*
* @return The repository system session to forward calls to, never {@code null}.
*/
protected abstract RepositorySystemSession getSession();
Expand Down Expand Up @@ -212,34 +211,10 @@ public RepositoryCache getCache()
{
return getSession().getCache();
}

@Override
public FileTransformerManager getFileTransformerManager()
{
return getSession().getFileTransformerManager();
}

@Override
public final void addOnCloseHandler( Consumer<RepositorySystemSession> handler )
{
getSession().addOnCloseHandler( handler );
}

@Override
public final boolean isClosed()
{
return getSession().isClosed();
}

/**
* This method is special: by default it throws (nested session should never be closed), the "top level" session
* should be closed instead. Still, this method is NOT {@code final}, to allow implementations overriding it,
* and in case when needed, handle forwarded session as "top level" session.
*/
@Override
public void close()
{
throw new IllegalStateException( "Forwarding session should not be closed, "
+ "close the top-level (forwarded) session instead." );
}
}
Loading

0 comments on commit 0572277

Please sign in to comment.