Skip to content

Commit 548f1f1

Browse files
Merge pull request #121 from Flagsmith/release/6.2.0
Release 6.2.0
2 parents 3885ea3 + c666694 commit 548f1f1

File tree

7 files changed

+47
-18
lines changed

7 files changed

+47
-18
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>com.flagsmith</groupId>
88
<artifactId>flagsmith-java-client</artifactId>
9-
<version>6.1.0</version>
9+
<version>6.2.0</version>
1010
<packaging>jar</packaging>
1111

1212
<name>Flagsmith Java Client</name>

src/main/java/com/flagsmith/FlagsmithApiWrapper.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,13 @@
2020
import java.util.concurrent.TimeUnit;
2121
import java.util.concurrent.TimeoutException;
2222
import lombok.Data;
23+
import lombok.Getter;
2324
import okhttp3.HttpUrl;
2425
import okhttp3.MediaType;
2526
import okhttp3.Request;
2627
import okhttp3.RequestBody;
2728

28-
@Data
29+
@Getter
2930
public class FlagsmithApiWrapper implements FlagsmithSdk {
3031

3132
private static final String AUTH_HEADER = "X-Environment-Key";
@@ -261,6 +262,15 @@ public EnvironmentModel getEnvironment() {
261262
return null;
262263
}
263264

265+
@Override
266+
public RequestProcessor getRequestor() {
267+
return this.requestor;
268+
}
269+
270+
public void setRequestor(RequestProcessor requestor) {
271+
this.requestor = requestor;
272+
}
273+
264274
@Override
265275
public FlagsmithConfig getConfig() {
266276
return this.defaultConfig;

src/main/java/com/flagsmith/config/FlagsmithCacheConfig.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
11
package com.flagsmith.config;
22

3-
import com.flagsmith.flagengine.features.FeatureStateModel;
43
import com.flagsmith.interfaces.FlagsmithCache;
54
import com.flagsmith.models.Flags;
65
import com.github.benmanes.caffeine.cache.Cache;
76
import com.github.benmanes.caffeine.cache.Caffeine;
87
import com.github.benmanes.caffeine.cache.stats.CacheStats;
9-
import java.util.List;
8+
109
import java.util.concurrent.TimeUnit;
11-
import lombok.Data;
12-
import lombok.NonNull;
10+
import lombok.Getter;
1311
import org.apache.commons.lang3.StringUtils;
1412

15-
@Data
13+
@Getter
1614
public final class FlagsmithCacheConfig {
1715

1816
private static final int DEFAULT_MAX_SIZE = 10;
@@ -163,7 +161,7 @@ public class FlagsmithCacheImpl implements FlagsmithCache {
163161
private final String envFlagsCacheKey;
164162

165163
public FlagsmithCacheImpl(final Cache<String, Flags> cache,
166-
final String envFlagsCacheKey) {
164+
final String envFlagsCacheKey) {
167165
this.cache = cache;
168166
this.envFlagsCacheKey = envFlagsCacheKey;
169167
}

src/main/java/com/flagsmith/config/FlagsmithConfig.java

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package com.flagsmith.config;
22

3-
import com.flagsmith.FlagsmithClient;
43
import com.flagsmith.FlagsmithFlagDefaults;
5-
import com.flagsmith.interfaces.DefaultFlagHandler;
64
import com.flagsmith.threads.AnalyticsProcessor;
75

86
import java.net.Proxy;
@@ -11,7 +9,8 @@
119
import java.util.concurrent.TimeUnit;
1210
import javax.net.ssl.SSLSocketFactory;
1311
import javax.net.ssl.X509TrustManager;
14-
import lombok.Data;
12+
13+
import lombok.Getter;
1514
import okhttp3.HttpUrl;
1615
import okhttp3.Interceptor;
1716
import okhttp3.OkHttpClient;
@@ -21,7 +20,7 @@
2120
*
2221
* <p>Created by Pavlo Maksymchuk.
2322
*/
24-
@Data
23+
@Getter
2524
public final class FlagsmithConfig {
2625

2726
private static final int DEFAULT_CONNECT_TIMEOUT_MILLIS = 2000;
@@ -82,6 +81,10 @@ public static FlagsmithConfig.Builder newBuilder() {
8281
return new FlagsmithConfig.Builder();
8382
}
8483

84+
public void setFlagsmithFlagDefaults(FlagsmithFlagDefaults flagsmithFlagDefaults) {
85+
this.flagsmithFlagDefaults = flagsmithFlagDefaults;
86+
}
87+
8588
public static class Builder {
8689

8790
private final List<Interceptor> interceptors = new ArrayList<>();
@@ -187,6 +190,7 @@ public Builder withProxy(Proxy proxy) {
187190

188191
/**
189192
* Add retries for HTTP request to the builder.
193+
*
190194
* @param retries no of retries for requests
191195
* @return
192196
*/
@@ -197,6 +201,7 @@ public Builder retries(Retry retries) {
197201

198202
/**
199203
* Local evaluation config.
204+
*
200205
* @param localEvaluation boolean to enable
201206
* @return
202207
*/
@@ -206,7 +211,9 @@ public Builder withLocalEvaluation(Boolean localEvaluation) {
206211
}
207212

208213
/**
209-
* set environment refresh rate with polling manager. Only needed when local evaluation is true.
214+
* set environment refresh rate with polling manager. Only needed when local evaluation is
215+
* true.
216+
*
210217
* @param seconds seconds
211218
* @return
212219
*/
@@ -230,6 +237,7 @@ public Builder withAnalyticsProcessor(AnalyticsProcessor processor) {
230237

231238
/**
232239
* Enable Analytics Processor.
240+
*
233241
* @param enable boolean to enable
234242
* @return
235243
*/

src/main/java/com/flagsmith/threads/AnalyticsProcessor.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@
88
import java.time.Instant;
99
import java.util.HashMap;
1010
import java.util.Map;
11-
import lombok.Data;
11+
import lombok.Getter;
1212
import lombok.ToString;
1313
import okhttp3.HttpUrl;
1414
import okhttp3.MediaType;
1515
import okhttp3.OkHttpClient;
1616
import okhttp3.Request;
1717
import okhttp3.RequestBody;
1818

19-
@Data
19+
@Getter
2020
public class AnalyticsProcessor {
2121

2222
private final String analyticsEndpoint = "analytics/flags/";
@@ -92,6 +92,11 @@ public void setLogger(FlagsmithLogger logger) {
9292
this.logger = logger;
9393
}
9494

95+
96+
public void setApi(FlagsmithSdk api) {
97+
this.api = api;
98+
}
99+
95100
/**
96101
* Get the analytics url.
97102
*/

src/main/java/com/flagsmith/threads/RequestProcessor.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import okhttp3.Request;
1919
import okhttp3.Response;
2020

21-
@Data
2221
public class RequestProcessor {
2322

2423
private ExecutorService executor = Executors.newFixedThreadPool(3);
@@ -124,4 +123,11 @@ public void close() {
124123
this.executor.shutdown();
125124
}
126125

126+
public FlagsmithLogger getLogger() {
127+
return logger;
128+
}
129+
130+
public OkHttpClient getClient() {
131+
return client;
132+
}
127133
}

src/test/java/com/flagsmith/FlagsmithApiWrapperCachingTest.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535

3636

3737
public class FlagsmithApiWrapperCachingTest {
38+
3839
private final String API_KEY = "OUR_API_KEY";
3940
private final String BASE_URL = "https://unit-test.com";
4041
private FlagsmithCache flagsmithCacheImpl;
@@ -61,7 +62,8 @@ public void init() {
6162
flagsmithLogger = mock(FlagsmithLogger.class);
6263
requestProcessor = mock(RequestProcessor.class);
6364

64-
flagsmithAPIWrapper = new FlagsmithApiWrapper(flagsmithCacheImpl, defaultConfig, null, flagsmithLogger, API_KEY);
65+
flagsmithAPIWrapper = new FlagsmithApiWrapper(
66+
flagsmithCacheImpl, defaultConfig, null, flagsmithLogger, API_KEY);
6567
flagsmithAPIWrapper.setRequestor(requestProcessor);
6668
}
6769

@@ -177,7 +179,7 @@ public void testGetFeatureFlags_ReturnsFeatureFlagsFromApi_IfCacheButNoEnvCacheK
177179

178180
final List<FeatureStateModel> featureStateModels = new ArrayList<>();
179181
when(requestProcessor.executeAsync(any(), any(), any()))
180-
.thenReturn(FlagsmithTestHelper.futurableReturn(featureStateModels));
182+
.thenReturn(FlagsmithTestHelper.futurableReturn(featureStateModels));
181183

182184
// When
183185
Flags flags = flagsmithAPIWrapper.getFeatureFlags(false);

0 commit comments

Comments
 (0)