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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
## Unreleased
Merged to `master` after 10.6.1 and not yet released. Because Retrofit changes major version, release this as **10.7.0**:
- fix: Android apps no longer get `Duplicate class okhttp3.…` build errors (`okhttp-jvm` next to `okhttp-android`), and no exclusion is needed. The SDK now publishes Gradle module metadata that leaves out `okhttp-jvm`, so Gradle picks the right OkHttp artifact per platform. The POM is unchanged, so Maven users are unaffected
- fix: `Location`, `BoundingBox` and `BoundingCircle` queries no longer depend on the default locale (`52,500000,13,400000` on a German device)
- chore(deps): OkHttp pinned to **5.3.2**: `okhttp-android` 5.4+ would force Android apps to compileSdk 36/37
- chore(deps): Retrofit **3.0.0** (#371; binary-compatible with 2.11 for `retrofit`, `converter-gson`, `adapter-rxjava3`), Gson 2.14.0 (#359), named-regexp 1.x (#370)
- chore(deps): build and test tooling updates (Truth 1.4.5, checkstyle, Maven plugins)
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/com/contentful/java/cda/QueryOperation.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.contentful.java.cda;

import java.util.Locale;

/**
* This enumeration will be used to formulate more complex search queries.
*
Expand Down Expand Up @@ -92,7 +94,7 @@ public Location(double latitude, double longitude) {
*/
@Override
public String toString() {
return String.format("%f,%f", latitude, longitude);
return String.format(Locale.ROOT, "%f,%f", latitude, longitude);
}
}

Expand Down Expand Up @@ -169,7 +171,7 @@ public BoundingCircle(double centerLatitude, double centerLongitude, double radi
* @return returns a url friendly representation.
*/
@Override public String toString() {
return String.format("%s,%f", center.toString(), radius);
return String.format(Locale.ROOT, "%s,%f", center.toString(), radius);
}
}
}
18 changes: 18 additions & 0 deletions src/test/java/com/contentful/java/cda/AbsQueryTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;

import java.util.Locale;

import static com.contentful.java.cda.QueryOperation.Exists;
import static com.contentful.java.cda.QueryOperation.HasAllOf;
import static com.contentful.java.cda.QueryOperation.HasNoneOf;
Expand Down Expand Up @@ -467,6 +469,22 @@ public void nearThrowsIfNotUsedWithContentType() {
query.where("fields.bar", IsCloseTo, new Location(52, 14));
}

@Test
public void locationsDoNotDependOnTheDefaultLocale() {
final Locale defaultLocale = Locale.getDefault();
try {
Locale.setDefault(Locale.GERMANY);

assertThat(new Location(52.5, 13.4).toString()).isEqualTo("52.500000,13.400000");
assertThat(new BoundingBox(1.5, 2.5, 3.5, 4.5).toString())
.isEqualTo("1.500000,2.500000,3.500000,4.500000");
assertThat(new BoundingCircle(new Location(52.5, 13.4), 0.5).toString())
.isEqualTo("52.500000,13.400000,0.500000");
} finally {
Locale.setDefault(defaultLocale);
}
}

@Test
public void withinBoundingBox() {
query.withContentType("foo");
Expand Down