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

Commit cd60e6d

Browse files
prepare 4.14.4 release (#214)
1 parent a6777a8 commit cd60e6d

File tree

9 files changed

+88
-19
lines changed

9 files changed

+88
-19
lines changed

.circleci/config.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ workflows:
77
test:
88
jobs:
99
- build-linux
10+
- test-linux-jdk7:
11+
name: Java 7 - Linux - OpenJDK
1012
- test-linux:
1113
name: Java 8 - Linux - OpenJDK
1214
docker-image: circleci/openjdk:8
@@ -76,6 +78,30 @@ jobs:
7678
- store_artifacts:
7779
path: ~/junit
7880

81+
test-linux-jdk7:
82+
# This build uses LaunchDarkly's ld-jdk7-jdk8 image which has both OpenJDK 7 and
83+
# OpenJDK 8 installed, with 8 being the default that is used to run Gradle.
84+
# See: https://github.com/launchdarkly/sdks-ci-docker
85+
docker:
86+
- image: ldcircleci/ld-jdk7-jdk8
87+
- image: redis
88+
steps:
89+
- checkout
90+
- run: cp gradle.properties.example gradle.properties
91+
- run:
92+
name: Run tests
93+
command: ./gradlew -i -Dorg.gradle.project.overrideJavaHome=$JDK7_HOME test sourcesJar javadocJar
94+
- run:
95+
name: Save test results
96+
command: |
97+
mkdir -p ~/junit/
98+
find . -type f -regex ".*/build/test-results/.*xml" -exec cp {} ~/junit/ \;
99+
when: always
100+
- store_test_results:
101+
path: ~/junit
102+
- store_artifacts:
103+
path: ~/junit
104+
79105
build-test-windows:
80106
executor:
81107
name: win/vs2019

build.gradle

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ ext.versions = [
5858
"gson": "2.7",
5959
"guava": "19.0",
6060
"jodaTime": "2.9.3",
61-
"okhttp": "3.14.9", // specify this for the SDK build instead of relying on the transitive dependency from okhttp-eventsource
62-
"okhttpEventsource": "1.11.0",
61+
"okhttp": "3.12.2", // specify this for the SDK build instead of relying on the transitive dependency from okhttp-eventsource
62+
"okhttpEventsource": "1.11.2",
6363
"slf4j": "1.7.21",
6464
"snakeyaml": "1.26",
6565
"jedis": "2.9.0"
@@ -445,3 +445,34 @@ gitPublish {
445445
}
446446
commitMessage = 'publishing javadocs'
447447
}
448+
449+
// Overriding JAVA_HOME/executable paths allows us to build/test under Java 7 even though
450+
// Gradle itself has to run in Java 8+.
451+
452+
tasks.withType(AbstractCompile) {
453+
options.with {
454+
if (overrideJavaHome != "") {
455+
System.out.println("Building with JAVA_HOME=" + overrideJavaHome)
456+
fork = true
457+
forkOptions.javaHome = file(overrideJavaHome)
458+
}
459+
}
460+
}
461+
462+
tasks.withType(Javadoc) {
463+
if (overrideJavaHome != "") {
464+
executable = new File(overrideJavaHome, "bin/javadoc")
465+
}
466+
}
467+
468+
tasks.withType(Test) {
469+
if (overrideJavaHome != "") {
470+
executable = new File(overrideJavaHome, "bin/java")
471+
}
472+
}
473+
474+
tasks.withType(JavaExec) {
475+
if (overrideJavaHome != "") {
476+
executable = new File(overrideJavaHome, "bin/java")
477+
}
478+
}

gradle.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,8 @@ version=4.14.3
44
ossrhUsername=
55
ossrhPassword=
66

7+
# See build.gradle
8+
overrideJavaHome=
9+
710
# See https://github.com/gradle/gradle/issues/11308 regarding the following property
811
systemProp.org.gradle.internal.publish.checksums.insecure=true

gradle.properties.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,6 @@ signing.password = SIGNING_PASSWORD
66
signing.secretKeyRingFile = SECRET_RING_FILE
77
ossrhUsername = launchdarkly
88
ossrhPassword = OSSHR_PASSWORD
9+
10+
# See build.gradle
11+
overrideJavaHome=

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

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,6 @@ public interface LDClientInterface extends Closeable {
5050

5151
/**
5252
* Tracks that a user performed an event, and provides an additional numeric value for custom metrics.
53-
* <p>
54-
* As of this version’s release date, the LaunchDarkly service does not support the {@code metricValue}
55-
* parameter. As a result, calling this overload of {@code track} will not yet produce any different
56-
* behavior from calling {@link #track(String, LDUser, JsonElement)} without a {@code metricValue}.
57-
* Refer to the <a href="https://docs.launchdarkly.com/docs/java-sdk-reference#section-track">SDK reference guide</a> for the latest status.
5853
*
5954
* @param eventName the name of the event
6055
* @param user the user that performed the event
@@ -70,11 +65,6 @@ public interface LDClientInterface extends Closeable {
7065

7166
/**
7267
* Tracks that a user performed an event, and provides an additional numeric value for custom metrics.
73-
* <p>
74-
* As of this version’s release date, the LaunchDarkly service does not support the {@code metricValue}
75-
* parameter. As a result, calling this overload of {@code track} will not yet produce any different
76-
* behavior from calling {@link #trackData(String, LDUser, LDValue)} without a {@code metricValue}.
77-
* Refer to the <a href="https://docs.launchdarkly.com/docs/java-sdk-reference#section-track">SDK reference guide</a> for the latest status.
7868
*
7969
* @param eventName the name of the event
8070
* @param user the user that performed the event

src/main/java/com/launchdarkly/client/value/LDValue.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.google.common.base.Function;
44
import com.google.common.collect.ImmutableList;
55
import com.google.common.collect.Iterables;
6+
import com.google.common.collect.Ordering;
67
import com.google.gson.Gson;
78
import com.google.gson.JsonElement;
89
import com.google.gson.annotations.JsonAdapter;
@@ -468,7 +469,9 @@ public int hashCode() {
468469
return ah;
469470
case OBJECT:
470471
int oh = 0;
471-
for (String name: keys()) {
472+
// We sort the keys here to guarantee ordering equivalence with LDValueJsonElement
473+
// wrapping JsonObjects.
474+
for (String name: Ordering.natural().immutableSortedCopy(keys())) {
472475
oh = (oh * 31 + name.hashCode()) * 31 + get(name).hashCode();
473476
}
474477
return oh;

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import com.google.gson.JsonArray;
88
import com.google.gson.JsonElement;
99
import com.google.gson.JsonObject;
10+
import com.google.gson.JsonPrimitive;
1011
import com.google.gson.reflect.TypeToken;
1112
import com.launchdarkly.client.value.LDValue;
1213

@@ -29,6 +30,7 @@
2930
import static org.junit.Assert.assertEquals;
3031
import static org.junit.Assert.assertNotNull;
3132
import static org.junit.Assert.assertNull;
33+
import static org.junit.Assert.assertTrue;
3234

3335
@SuppressWarnings("javadoc")
3436
public class LDUserTest {
@@ -344,8 +346,14 @@ private Map<LDUser, String> getUserPropertiesJsonMap() {
344346
@Test
345347
public void defaultJsonEncodingHasPrivateAttributeNames() {
346348
LDUser user = new LDUser.Builder("userkey").privateName("x").privateEmail("y").build();
347-
String expected = "{\"key\":\"userkey\",\"name\":\"x\",\"email\":\"y\",\"privateAttributeNames\":[\"name\",\"email\"]}";
348-
assertEquals(defaultGson.fromJson(expected, JsonElement.class), defaultGson.toJsonTree(user));
349+
JsonObject serialized = defaultGson.toJsonTree(user).getAsJsonObject();
350+
assertEquals(serialized.get("key").getAsJsonPrimitive().getAsString(), "userkey");
351+
assertEquals(serialized.get("name").getAsJsonPrimitive().getAsString(), "x");
352+
assertEquals(serialized.get("email").getAsJsonPrimitive().getAsString(), "y");
353+
JsonArray privateAttrs = serialized.get("privateAttributeNames").getAsJsonArray();
354+
assertEquals(privateAttrs.size(), 2);
355+
assertTrue(privateAttrs.contains(new JsonPrimitive("name")));
356+
assertTrue(privateAttrs.contains(new JsonPrimitive("email")));
349357
}
350358

351359
@Test

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import okhttp3.mockwebserver.MockWebServer;
1818
import okhttp3.tls.HandshakeCertificates;
1919
import okhttp3.tls.HeldCertificate;
20-
import okhttp3.tls.internal.TlsUtil;
2120

2221
class TestHttpUtil {
2322
static MockWebServer makeStartedServer(MockResponse... responses) throws IOException {
@@ -72,9 +71,14 @@ public ServerWithCert() throws IOException, GeneralSecurityException {
7271
.certificateAuthority(1)
7372
.commonName(hostname)
7473
.addSubjectAlternativeName(hostname)
74+
.rsa2048()
7575
.build();
7676

77-
HandshakeCertificates hc = TlsUtil.localhost();
77+
HandshakeCertificates hc = new HandshakeCertificates.Builder()
78+
.addPlatformTrustedCertificates()
79+
.heldCertificate(cert)
80+
.addTrustedCertificate(cert.certificate())
81+
.build();
7882
socketFactory = hc.sslSocketFactory();
7983
trustManager = hc.trustManager();
8084

src/test/java/com/launchdarkly/client/value/LDValueTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import org.junit.Test;
1111

1212
import java.util.ArrayList;
13+
import java.util.Collections;
1314
import java.util.List;
1415

1516
import static org.junit.Assert.assertEquals;
@@ -277,7 +278,7 @@ public void objectKeysCanBeEnumerated() {
277278
for (String key: LDValue.buildObject().put("1", LDValue.of("x")).put("2", LDValue.of("y")).build().keys()) {
278279
keys.add(key);
279280
}
280-
keys.sort(null);
281+
Collections.sort(keys);
281282
assertEquals(ImmutableList.of("1", "2"), keys);
282283
}
283284

@@ -287,7 +288,7 @@ public void objectValuesCanBeEnumerated() {
287288
for (LDValue value: LDValue.buildObject().put("1", LDValue.of("x")).put("2", LDValue.of("y")).build().values()) {
288289
values.add(value.stringValue());
289290
}
290-
values.sort(null);
291+
Collections.sort(values);
291292
assertEquals(ImmutableList.of("x", "y"), values);
292293
}
293294

0 commit comments

Comments
 (0)