1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2024-12-27 13:28:00 +01:00

ProviderFactory: Avoid accessing subclass in parent class initialization

This commit is contained in:
Paul Schaub 2021-08-15 15:40:31 +02:00
parent adc69caa51
commit 672acd38d0

View file

@ -19,7 +19,7 @@ import java.security.Provider;
public abstract class ProviderFactory {
private static ProviderFactory FACTORY = new BouncyCastleProviderFactory();
private static ProviderFactory FACTORY;
protected abstract Provider _getProvider();
protected abstract String _getProviderName();
@ -28,12 +28,19 @@ public abstract class ProviderFactory {
ProviderFactory.FACTORY = factory;
}
public static ProviderFactory getFactory() {
if (FACTORY == null) {
FACTORY = new BouncyCastleProviderFactory();
}
return FACTORY;
}
public static Provider getProvider() {
return ProviderFactory.FACTORY._getProvider();
return ProviderFactory.getFactory()._getProvider();
}
public static String getProviderName() {
return ProviderFactory.FACTORY._getProviderName();
return ProviderFactory.getFactory()._getProviderName();
}
}