Ensure managed provider is unset by registered provider (#1506)

Signed-off-by: Chris Jackson <chris@cd-jackson.com>
This commit is contained in:
Chris Jackson 2020-06-01 00:28:25 +01:00 committed by GitHub
parent 5b325aa3d2
commit 795a19249c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -48,8 +48,11 @@ import org.slf4j.LoggerFactory;
* @author Kai Kreuzer - switched to parameterized logging
* @author Hilbrand Bouwkamp - Made protected fields private and added new methods to give access.
* @author Markus Rathgeb - Use separate collections to improve performance
* @author Chris Jackson - Ensure managed provider is only unset by current provider
*
* @param <E> type of the element
* @param <K> type of the key
* @param <P> type of the provider
*/
@NonNullByDefault
public abstract class AbstractRegistry<@NonNull E extends Identifiable<K>, @NonNull K, @NonNull P extends Provider<E>>
@ -530,7 +533,9 @@ public abstract class AbstractRegistry<@NonNull E extends Identifiable<K>, @NonN
}
protected void unsetManagedProvider(ManagedProvider<E, K> provider) {
managedProvider = Optional.empty();
if (managedProvider.equals(provider)) {
managedProvider = Optional.empty();
}
}
/**