Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 9 additions & 3 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ jobs:
matrix:
java: [ "11", "17", "21" ]
distribution: [ "zulu", "adopt" ]
okhttp: [ "okhttp5", "okhttp4" ]
include:
- okhttp: "okhttp5"
maven_profiles: ""
- okhttp: "okhttp4"
maven_profiles: "-P test-okhttp4"

steps:
- name: Checkout repository
Expand All @@ -31,8 +37,8 @@ jobs:
uses: actions/cache@v4
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
key: ${{ runner.os }}-m2-${{ matrix.okhttp }}-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2

- name: Build with Maven
run: mvn clean install
- name: Build with Maven (OkHttp ${{ matrix.okhttp }})
run: mvn clean install ${{ matrix.maven_profiles }}
28 changes: 22 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,17 @@
<slf4j.version>1.7.30</slf4j.version>
<maven.checkstyle.version>3.4.0</maven.checkstyle.version>
<junit.jupiter.version>5.14.0</junit.jupiter.version>
<!-- OkHttp dependency coordinates — overridden by the test-okhttp4 profile -->
<okhttp.artifactId>okhttp-jvm</okhttp.artifactId>
<okhttp.version>5.0.0</okhttp.version>
<okhttp.mockwebserver.version>5.0.0</okhttp.mockwebserver.version>
</properties>

<dependencies>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>4.12.0</version>
<artifactId>${okhttp.artifactId}</artifactId>
<version>${okhttp.version}</version>
</dependency>
<dependency>
<groupId>com.jayway.jsonpath</groupId>
Expand Down Expand Up @@ -157,7 +161,7 @@
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>mockwebserver</artifactId>
<version>3.10.0</version>
<version>${okhttp.mockwebserver.version}</version>
<scope>test</scope>
</dependency>
<dependency>
Expand All @@ -173,9 +177,9 @@
<version>1.14.17</version>
</dependency>
<dependency>
<groupId>com.github.gmazzo</groupId>
<artifactId>okhttp-mock</artifactId>
<version>1.4.1</version>
<groupId>com.github.gmazzo.okhttp.mock</groupId>
<artifactId>mock-client</artifactId>
<version>2.0.0</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down Expand Up @@ -368,5 +372,17 @@
</plugins>
</build>
</profile>
<profile>
<!--
Run the test suite against OkHttp 4.x to verify backward compatibility.
Activate with: mvn test -P test-okhttp4
-->
<id>test-okhttp4</id>
<properties>
<okhttp.artifactId>okhttp</okhttp.artifactId>
<okhttp.version>4.12.0</okhttp.version>
<okhttp.mockwebserver.version>4.12.0</okhttp.mockwebserver.version>
</properties>
</profile>
</profiles>
</project>
2 changes: 1 addition & 1 deletion src/main/java/com/flagsmith/FlagsmithApiWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ public Flags identifyUserWithTraits(
node.putPOJO("traits", traits);
}

MediaType json = MediaType.parse("application/json; charset=utf-8");
MediaType json = MediaType.get("application/json; charset=utf-8");
RequestBody body = RequestBody.create(node.toString(), json);

HttpUrl url = defaultConfig.getIdentitiesUri();
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/flagsmith/config/FlagsmithConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public final class FlagsmithConfig {
private static final int DEFAULT_READ_TIMEOUT_MILLIS = 5000;
private static final int DEFAULT_ENVIRONMENT_REFRESH_SECONDS = 60;
private static final HttpUrl DEFAULT_BASE_URI = HttpUrl
.parse("https://edge.api.flagsmith.com/api/v1/");
.get("https://edge.api.flagsmith.com/api/v1/");
private final HttpUrl flagsUri;
private final HttpUrl identitiesUri;
private final HttpUrl traitsUri;
Expand Down Expand Up @@ -129,7 +129,7 @@ private Builder() {
*/
public Builder baseUri(String baseUri) {
if (baseUri != null) {
this.baseUri = HttpUrl.parse(baseUri);
this.baseUri = HttpUrl.get(baseUri);
}
return this;
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/flagsmith/threads/AnalyticsProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ public void flush() {
return;
}

MediaType json = MediaType.parse("application/json; charset=utf-8");
RequestBody body = RequestBody.create(json, response);
MediaType json = MediaType.get("application/json; charset=utf-8");
RequestBody body = RequestBody.create(response, json);

Request request = api.newPostRequest(getAnalyticsUrl(), body);

Expand Down
1 change: 0 additions & 1 deletion src/test/java/com/flagsmith/FlagsmithApiWrapperTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
import okhttp3.Response;
import okhttp3.ResponseBody;
import okhttp3.mock.MockInterceptor;
import org.bouncycastle.ocsp.Req;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

Expand Down
Loading