Skip to content

Commit e1a6d9c

Browse files
Creating FactoryInstantiationService
1 parent a68dee1 commit e1a6d9c

File tree

1 file changed

+2
-14
lines changed

1 file changed

+2
-14
lines changed

client/src/main/java/io/split/client/SplitFactoryImpl.java

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -72,19 +72,7 @@ public class SplitFactoryImpl implements SplitFactory {
7272
public SplitFactoryImpl(String apiToken, SplitClientConfig config) throws URISyntaxException {
7373
_apiToken = apiToken;
7474

75-
if (USED_API_TOKENS.contains(apiToken)) {
76-
String message = String.format("factory instantiation: You already have %s with this API Key. " +
77-
"We recommend keeping only one instance of the factory at all times (Singleton pattern) and reusing " +
78-
"it throughout your application.",
79-
USED_API_TOKENS.count(apiToken) == 1 ? "1 factory" : String.format("%s factories", USED_API_TOKENS.count(apiToken)));
80-
_log.warn(message);
81-
} else if (!USED_API_TOKENS.isEmpty()) {
82-
String message = "factory instantiation: You already have an instance of the Split factory. " +
83-
"Make sure you definitely want this additional instance. We recommend keeping only one instance of " +
84-
"the factory at all times (Singleton pattern) and reusing it throughout your application.“";
85-
_log.warn(message);
86-
}
87-
USED_API_TOKENS.add(apiToken);
75+
FactoryInstantiationsService.getFactoryInstantiationsServiceInstance().addToken(apiToken);
8876

8977
if (config.blockUntilReady() == -1) {
9078
//BlockUntilReady not been set
@@ -209,7 +197,7 @@ public void destroy() {
209197
synchronized (SplitFactoryImpl.class) {
210198
if (!isTerminated) {
211199
destroyer.run();
212-
USED_API_TOKENS.remove(_apiToken);
200+
FactoryInstantiationsService.getFactoryInstantiationsServiceInstance().removeToken(_apiToken);
213201
isTerminated = true;
214202
}
215203
}

0 commit comments

Comments
 (0)