Skip to content
This repository was archived by the owner on May 30, 2024. It is now read-only.

Commit 80b4185

Browse files
authored
Merge pull request #81 from launchdarkly/dr/allFlagsOffline
allFlags() no longer returns null when client is offline
2 parents 0157693 + 8bfae78 commit 80b4185

File tree

5 files changed

+27
-7
lines changed

5 files changed

+27
-7
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33

44
All notable changes to the LaunchDarkly Java SDK will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org).
5+
## [2.0.7] - 2016-12-21
6+
### Changed
7+
- allFlags() method on client no longer returns null when client is in offline mode.
8+
59
## [2.0.6] - 2016-11-21
610
### Changed
711
- RedisFeatureStore: Update Jedis dependency. Improved thread/memory management.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Quick setup
1111
<dependency>
1212
<groupId>com.launchdarkly</groupId>
1313
<artifactId>launchdarkly-client</artifactId>
14-
<version>2.0.6</version>
14+
<version>2.0.7</version>
1515
</dependency>
1616

1717
1. Import the LaunchDarkly package:

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ repositories {
1919

2020
allprojects {
2121
group = 'com.launchdarkly'
22-
version = "2.0.6"
22+
version = "2.0.7-SNAPSHOT"
2323
sourceCompatibility = 1.7
2424
targetCompatibility = 1.7
2525
}

src/main/java/com/launchdarkly/client/LDClient.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,7 @@ private void sendFlagRequestEvent(String featureKey, LDUser user, JsonElement va
200200
@Override
201201
public Map<String, JsonElement> allFlags(LDUser user) {
202202
if (isOffline()) {
203-
logger.warn("allFlags() was called when client is in offline mode! Returning null.");
204-
return null;
203+
logger.debug("allFlags() was called when client is in offline mode.");
205204
}
206205

207206
if (!initialized()) {

src/test/java/com/launchdarkly/client/LDClientTest.java

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
package com.launchdarkly.client;
22

33
import com.google.gson.JsonArray;
4+
import com.google.gson.JsonElement;
45
import com.google.gson.JsonPrimitive;
56
import org.easymock.EasyMockSupport;
67
import org.junit.Before;
78
import org.junit.Test;
89

910
import java.io.IOException;
11+
import java.util.Map;
1012
import java.util.concurrent.ExecutionException;
1113
import java.util.concurrent.Future;
1214
import java.util.concurrent.TimeUnit;
1315
import java.util.concurrent.TimeoutException;
1416

1517
import static org.easymock.EasyMock.anyObject;
1618
import static org.easymock.EasyMock.expect;
17-
import static org.junit.Assert.assertEquals;
18-
import static org.junit.Assert.assertFalse;
19-
import static org.junit.Assert.assertTrue;
19+
import static org.junit.Assert.*;
2020

2121
public class LDClientTest extends EasyMockSupport {
2222
private FeatureRequestor requestor;
@@ -71,6 +71,23 @@ public void testTestFeatureStoreSetFeatureTrue() throws IOException, Interrupted
7171
verifyAll();
7272
}
7373

74+
@Test
75+
public void testTestOfflineModeAllFlags() throws IOException, InterruptedException, ExecutionException, TimeoutException {
76+
TestFeatureStore testFeatureStore = new TestFeatureStore();
77+
LDConfig config = new LDConfig.Builder()
78+
.startWaitMillis(10L)
79+
.offline(true)
80+
.featureStore(testFeatureStore)
81+
.build();
82+
83+
client = new LDClient("", config);//createMockClient(config);
84+
testFeatureStore.setFeatureTrue("key");
85+
Map<String, JsonElement> allFlags = client.allFlags(new LDUser("user"));
86+
assertNotNull("Expected non-nil response from allFlags() when offline mode is set to true", allFlags);
87+
assertEquals("Didn't get expected flag count from allFlags() in offline mode", 1, allFlags.size());
88+
assertTrue("Test flag should be true, but was not.", allFlags.get("key").getAsBoolean());
89+
}
90+
7491
@Test
7592
public void testTestFeatureStoreSetFalse() throws IOException, InterruptedException, ExecutionException, TimeoutException {
7693
TestFeatureStore testFeatureStore = new TestFeatureStore();

0 commit comments

Comments
 (0)