Skip to content
This repository was archived by the owner on May 30, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
96 commits
Select commit Hold shift + click to select a range
db568d4
initial implementation of Java common SDK code (#1)
eli-darkly Mar 20, 2020
374e08e
stick with Java 7 for Android compatibility (#2)
eli-darkly Apr 15, 2020
f1b9cb4
add getters to EvaluationReason and hide its subclasses
eli-darkly Apr 20, 2020
e86ced3
completely remove EvaluationReason subclasses
eli-darkly Apr 20, 2020
a8d1a91
Merge pull request #3 from launchdarkly/eb/ch74282/hide-reason-subcla…
eli-darkly Apr 20, 2020
0ff060b
Merge pull request #4 from launchdarkly/eb/ch74282/remove-reason-subc…
eli-darkly Apr 20, 2020
d440fd0
add JSON helpers, better serialization logic, and Gson adapter
eli-darkly Apr 20, 2020
04eaf1a
javadoc fixes
eli-darkly Apr 21, 2020
433a1e7
remove @since tags, misc doc fixes, add note about changelogging
eli-darkly Apr 21, 2020
55e3c1b
Merge branch 'eb/ch74370/javadoc-since' into eb/ch73994/gson-interop
eli-darkly Apr 21, 2020
fe6f0eb
fix sample code
eli-darkly Apr 22, 2020
97a8fa3
rename Gson adapter, use factory method
eli-darkly Apr 22, 2020
2c5cc2b
Merge pull request #5 from launchdarkly/eb/ch74370/javadoc-since
eli-darkly Apr 22, 2020
511c9e2
improve and rigorously test equals() for all immutable types
eli-darkly Apr 24, 2020
525daa6
simplifying
eli-darkly Apr 24, 2020
3e222c3
simplifying
eli-darkly Apr 24, 2020
d003179
make EvaluationDetail non-nullable + use boolean singletons
eli-darkly Apr 24, 2020
b810cd7
hide Gson in pom
eli-darkly Apr 24, 2020
129d5b6
doc additions
eli-darkly Apr 24, 2020
0ab6d7c
Merge pull request #8 from launchdarkly/eb/ch74915/non-null-index
eli-darkly Apr 27, 2020
36d3fba
Merge pull request #6 from launchdarkly/eb/ch73994/gson-interop
eli-darkly Apr 27, 2020
939b879
Merge branch 'master' into eb/ch68094/test-equals
eli-darkly Apr 27, 2020
6136698
javadoc fixes
eli-darkly Apr 27, 2020
fa2dd6c
Merge branch 'master' into eb/ch68094/test-equals
eli-darkly Apr 27, 2020
9bd6dbb
Merge pull request #7 from launchdarkly/eb/ch68094/test-equals
eli-darkly Apr 28, 2020
5458738
add Jackson adapter (#9)
eli-darkly Apr 28, 2020
5635a1d
more predictable exception behavior for LDValue.parse()
eli-darkly Apr 28, 2020
4ac7396
Merge pull request #11 from launchdarkly/eb/ch73994/parse-exception
eli-darkly Apr 28, 2020
21e9167
fix the JSON behavior of EvaluationDetail (#10)
eli-darkly Apr 28, 2020
7c29e7b
maximize and enforce test coverage (#12)
eli-darkly Apr 28, 2020
7a2aa77
build and test in Android! (#13)
eli-darkly Apr 29, 2020
aa9f794
Merge branch 'master' of github.com:launchdarkly/java-sdk-common
eli-darkly Apr 29, 2020
d5c3b0d
ensure real nulls can't be stored in an LDValue
eli-darkly May 23, 2020
9e200fb
clean up some unnecessary coverage warnings
eli-darkly May 23, 2020
08f2b21
Merge pull request #15 from launchdarkly/eb/ch77641/null-safety
eli-darkly May 27, 2020
8fbc7a0
more convenient location for coverage reports
eli-darkly May 27, 2020
fbe209b
remove rc1 from changelog
eli-darkly Jun 1, 2020
7f83233
Merge branch 'master' of github.com:launchdarkly/java-sdk-common
eli-darkly Jun 2, 2020
ac4a2cd
Removed the guides link
bwoskow-ld Feb 3, 2021
1cad8c5
Use Android machine image for CircleCI Android tests. (#17)
gwhelanLD Mar 30, 2021
17f0b0b
improve Gson integration using reader/writer delegation + add LDValue…
eli-darkly Mar 30, 2021
96931b3
add LDValue.arrayOf() + misc javadoc fixes
eli-darkly Mar 30, 2021
99c51e9
Merge pull request #19 from launchdarkly/eb/ch104357/array-of
eli-darkly Mar 30, 2021
41058b9
Add inExperiment attribute to FALLTHROUGH and RULE_MATCH reasons
robertjneal Apr 3, 2021
0ea70c9
fix javadoc
robertjneal Apr 3, 2021
532fa70
Update src/main/java/com/launchdarkly/sdk/EvaluationReason.java
robertjneal Apr 6, 2021
7526a58
Update src/main/java/com/launchdarkly/sdk/EvaluationReason.java
robertjneal Apr 6, 2021
e3c06ec
Update src/main/java/com/launchdarkly/sdk/EvaluationReason.java
robertjneal Apr 6, 2021
0b6aef3
Update src/main/java/com/launchdarkly/sdk/EvaluationReason.java
robertjneal Apr 6, 2021
6e1b358
respond to review comments
robertjneal Apr 6, 2021
76533ce
fix test
robertjneal Apr 6, 2021
a9c82c7
Merge pull request #20 from launchdarkly/rneal/ch101658/add-inExperim…
robertjneal Apr 6, 2021
b468c4e
javadoc fix
eli-darkly Apr 8, 2021
fede11e
Merge branch 'master' into exp-alloc
eli-darkly Apr 8, 2021
a5abd08
add validation of javadoc build in CI
eli-darkly Apr 8, 2021
1e11684
add another Eclipse metadata exclusion to .gitignore
eli-darkly Apr 8, 2021
bceedef
Merge pull request #21 from launchdarkly/eb/ch105283/check-javadoc
eli-darkly Apr 8, 2021
3a8aa98
partially revert ch103941 fix that doesn't work in the Java SDK
eli-darkly Apr 14, 2021
3f02d6d
Merge pull request #22 from launchdarkly/eb/ch103941/revert-gson-adapter
eli-darkly Apr 14, 2021
7dee1cf
Merge branch 'master' into exp-alloc
eli-darkly Apr 14, 2021
36fe80f
unrevert some JSON improvements from previous revert
eli-darkly Apr 16, 2021
cfdece2
Merge pull request #23 from launchdarkly/eb/ch103941/json-partial-unr…
eli-darkly Apr 17, 2021
9d50c7e
improve Gson integration using reader/writer delegation - take 2
eli-darkly Apr 19, 2021
df89903
Merge pull request #24 from launchdarkly/eb/ch103941/gson-adapter-fix
eli-darkly Apr 21, 2021
b8ace9b
better Jackson adapter + misc JSON test improvements (#18)
eli-darkly Apr 21, 2021
cd9525e
omit redundant method call (this commit was mistakenly left out of th…
eli-darkly Apr 21, 2021
62c6988
merge from public after release
LaunchDarklyCI Apr 22, 2021
f5680a1
Merge branch 'master' of github.com:launchdarkly/java-sdk-common
eli-darkly Apr 22, 2021
08c734f
avoid unnecessarily adding ".0" to JSON numbers (#25)
eli-darkly Apr 22, 2021
3dbe3f2
merge from public after release
LaunchDarklyCI Apr 22, 2021
6a5a5f6
update Gradle to 6.8.3
eli-darkly May 5, 2021
113c27d
Merge pull request #26 from launchdarkly/eb/ch104534/gradle-update
eli-darkly May 5, 2021
b91dd33
Kotlinize main build script
eli-darkly May 5, 2021
9088dff
rm obsolete comments
eli-darkly May 5, 2021
41a846b
Merge pull request #27 from launchdarkly/eb/ch107687/gradle-kotlin
eli-darkly May 6, 2021
b5c338e
bump Jackson compile-time dependency to 2.10.5.1 due to CVE-2020-2564…
eli-darkly Jun 14, 2021
b9116a8
exclude Gson & Jackson from published dependencies in a more correct …
eli-darkly Jun 14, 2021
242a8f5
merge from public after release
LaunchDarklyCI Jun 15, 2021
6589606
Merge branch 'exp-alloc'
eli-darkly Jun 17, 2021
c69e187
merge from public after release
LaunchDarklyCI Jun 17, 2021
2a59948
refactor build scripts using buildSrc (#29)
eli-darkly Jun 29, 2021
03adb77
use Releaser v2 config format + newer CircleCI images (#33)
eli-darkly Sep 14, 2021
979d0de
Updates docs URLs
ember-stevens Sep 26, 2021
dee5dab
Merge pull request #34 from launchdarkly/emberstevens/sc-118589/url-a…
ember-stevens Sep 27, 2021
056ff10
update Gson to 2.8.9
eli-darkly Nov 30, 2021
e494dbc
Merge pull request #35 from launchdarkly/eb/sc-132830/gson-version
eli-darkly Nov 30, 2021
8c105c6
merge from public after release
Nov 30, 2021
30213bc
use Gradle 7
eli-darkly Jan 8, 2022
5ef951c
don't use jcenter
eli-darkly Jan 8, 2022
913f2ef
add Java 17 to CI
eli-darkly Jan 8, 2022
2a6287a
Merge pull request #37 from launchdarkly/eb/sc-122485/gradle7
eli-darkly Jan 8, 2022
8f301f0
Merge pull request #38 from launchdarkly/eb/sc-122485/java17
eli-darkly Jan 8, 2022
e8a5373
also test Java 17 in Windows
eli-darkly Jan 8, 2022
ceb6a47
Merge pull request #39 from launchdarkly/eb/sc-122485/java17win
eli-darkly Jan 10, 2022
c589a19
don't suppress null property values when we serialize with Gson
eli-darkly Jan 24, 2022
292f33b
Merge pull request #40 from launchdarkly/eb/sc-139316/serialize-nulls
eli-darkly Jan 25, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,20 @@ workflows:
- test-linux:
name: Java 11 - Linux - OpenJDK
docker-image: cimg/openjdk:11.0
requires:
- build-linux
- test-linux:
name: Java 17 - Linux - OpenJDK
docker-image: cimg/openjdk:17.0
with-coverage: true
requires:
- build-linux
- build-test-windows:
name: Java 11 - Windows - OpenJDK
openjdk-version: 11.0.2.01
- build-test-windows:
name: Java 17 - Windows - OpenJDK
openjdk-version: 17.0.1
- build-test-android:
name: Android

Expand Down Expand Up @@ -86,17 +95,20 @@ jobs:
path: coverage

build-test-windows:
parameters:
openjdk-version:
type: string
executor:
name: win/vs2019
shell: powershell.exe
steps:
- checkout
- run:
name: uninstall previous openjdk
command: choco uninstall openjdk
- run:
name: install OpenJDK
command: |
$ProgressPreference = "SilentlyContinue" # prevents console errors from CircleCI host
iwr -outf openjdk.msi https://developers.redhat.com/download-manager/file/java-11-openjdk-11.0.5.10-2.windows.redhat.x86_64.msi
Start-Process msiexec.exe -Wait -ArgumentList '/I openjdk.msi /quiet'
command: choco install openjdk --version <<parameters.openjdk-version>>
- run:
name: build and test
command: |
Expand Down
1 change: 0 additions & 1 deletion build-android.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ buildscript {
mavenCentral()
mavenLocal()
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.2.0'
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ plugins {
}

repositories {
jcenter()
gradlePluginPortal()
}
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
2 changes: 2 additions & 0 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ esac

CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar


# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
Expand Down Expand Up @@ -129,6 +130,7 @@ fi
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`

JAVACMD=`cygpath --unix "$JAVACMD"`

# We build the pattern for arguments to be converted via cygpath
Expand Down
22 changes: 4 additions & 18 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome

set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
if "%ERRORLEVEL%" == "0" goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Expand All @@ -54,7 +54,7 @@ goto fail
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto init
if exist "%JAVA_EXE%" goto execute

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
Expand All @@ -64,28 +64,14 @@ echo location of your Java installation.

goto fail

:init
@rem Get command-line arguments, handling Windows variants

if not "%OS%" == "Windows_NT" goto win9xME_args

:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2

:win9xME_args_slurp
if "x%~1" == "x" goto execute

set CMD_LINE_ARGS=%*

:execute
@rem Setup the command line

set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar


@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*

:end
@rem End local scope for the variables with windows NT shell
Expand Down
4 changes: 1 addition & 3 deletions src/main/java/com/launchdarkly/sdk/LDValue.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@
*/
@JsonAdapter(LDValueTypeAdapter.class)
public abstract class LDValue implements JsonSerializable {
static final Gson gson = new Gson();

/**
* Returns the same value if non-null, or {@link #ofNull()} if null.
*
Expand Down Expand Up @@ -393,7 +391,7 @@ public LDValue get(String name) {
* @return a JSON string
*/
public String toJsonString() {
return gson.toJson(this);
return JsonSerialization.serialize(this);
}

abstract void write(JsonWriter writer) throws IOException;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.launchdarkly.sdk.json;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.launchdarkly.sdk.EvaluationDetail;
import com.launchdarkly.sdk.EvaluationReason;
import com.launchdarkly.sdk.LDUser;
Expand Down Expand Up @@ -35,7 +36,10 @@ private JsonSerialization() {}

static final List<Class<? extends JsonSerializable>> knownDeserializableClasses = new ArrayList<>();

private static final Gson gson = new Gson();
// This Gson instance has serializeNulls enabled because we want the decision of whether to include
// a null property value to be left up to our own serializers. The default behavior would mean that
// the GsonWriter would not allow us to write a null property value ever.
private static final Gson gson = new GsonBuilder().serializeNulls().create();

/**
* Converts an object to its JSON representation.
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/com/launchdarkly/sdk/json/JsonTestHelpers.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

@SuppressWarnings("javadoc")
public abstract class JsonTestHelpers extends BaseTest {
static final Gson gson = new Gson();
static final Gson gson = new GsonBuilder().serializeNulls().create();

// Note that when we verify the behavior of Gson with LDGson in this project's unit tests, that
// is not an adequate test for whether the adapters will work in the Java SDK where there is the
Expand All @@ -24,7 +24,7 @@ public abstract class JsonTestHelpers extends BaseTest {
// that the adapters work correctly if Gson actually uses them.

public static Gson configureGson() {
return new GsonBuilder().registerTypeAdapterFactory(LDGson.typeAdapters()).create();
return new GsonBuilder().serializeNulls().registerTypeAdapterFactory(LDGson.typeAdapters()).create();
}

public static ObjectMapper configureJacksonMapper() {
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/com/launchdarkly/sdk/json/LDGsonTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public void valueMapToJsonElementMap() {
public void complexObjectToJsonTree() {
LDUser user = new LDUser.Builder("userkey").name("name")
.custom("attr1", LDValue.ofNull())
.custom("atrt2", LDValue.of(true))
.custom("attr2", LDValue.of(true))
.custom("attr3", LDValue.of(false))
.custom("attr4", LDValue.of(0))
.custom("attr5", LDValue.of(1))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public void jsonEncodingForNonNullValues() throws Exception {
verifyValueSerialization(LDValue.of(2.5d), "2.5");
verifyValueSerialization(JsonTestHelpers.basicArrayValue(), "[2,\"x\"]");
verifyValueSerialization(JsonTestHelpers.basicObjectValue(), "{\"x\":2}");
verifyValueSerialization(LDValue.buildObject().put("x", LDValue.ofNull()).build(), "{\"x\":null}");
verifyDeserializeInvalidJson(LDValue.class, "]");
}

Expand Down