Skip to content

Commit eb93090

Browse files
committed
Merge branch 'master' into releases/r4.0.0
Signed-off-by: Franz Wilhelmstötter <franz.wilhelmstoetter@gmail.com> ; Conflicts: ; buildSrc/src/main/kotlin/Env.kt
2 parents 97af57a + d14c867 commit eb93090

File tree

5 files changed

+87
-8
lines changed

5 files changed

+87
-8
lines changed

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ org.acme.NonValidatingDocumentBuilder
314314

315315
The library is licensed under the [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.html).
316316

317-
Copyright 2016-2024 Franz Wilhelmstötter
317+
Copyright 2016-2025 Franz Wilhelmstötter
318318

319319
Licensed under the Apache License, Version 2.0 (the "License");
320320
you may not use this file except in compliance with the License.
@@ -330,6 +330,12 @@ The library is licensed under the [Apache License, Version 2.0](http://www.apach
330330

331331
## Release notes
332332

333+
### [3.2.1](https://github.com/jenetics/jpx/releases/tag/v3.2.1)
334+
335+
#### Improvements
336+
337+
* [#186](https://github.com/jenetics/jpx/issues/186): LENIENT mode allows GPX tags without creator attributes.
338+
333339
### [3.2.0](https://github.com/jenetics/jpx/releases/tag/v3.2.0)
334340

335341
#### Improvements

RELEASE_NOTES.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
## Release notes
22

3+
### [3.2.1](https://github.com/jenetics/jpx/releases/tag/v3.2.1)
4+
5+
#### Improvements
6+
7+
* [#186](https://github.com/jenetics/jpx/issues/186): LENIENT mode allows GPX tags without creator attributes.
8+
39
### [3.2.0](https://github.com/jenetics/jpx/releases/tag/v3.2.0)
410

511
#### Improvements

jpx/src/main/java/io/jenetics/jpx/GPX.java

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -302,14 +302,16 @@ public static Version of(final String version) {
302302
*
303303
* @param creator the name or URL of the software that created your GPX
304304
* document. This allows others to inform the creator of a GPX
305-
* instance document that fails to validate.
305+
* instance document that fails to validate. If the {@code creator}
306+
* is {@code null}, {@code "JPX - https://github.com/jenetics/jpx"}
307+
* is used instead.
306308
* @param version the GPX version
307309
* @param metadata the metadata about the GPS file
308310
* @param wayPoints the way-points
309311
* @param routes the routes
310312
* @param tracks the tracks
311313
* @param extensions the XML extensions document
312-
* @throws NullPointerException if the {@code creator} or {@code version} is
314+
* @throws NullPointerException if the {@code version} is
313315
* {@code null}
314316
*/
315317
private GPX(
@@ -322,7 +324,7 @@ private GPX(
322324
final Document extensions
323325
) {
324326
_version = requireNonNull(version);
325-
_creator = requireNonNull(creator);
327+
_creator = creator != null ? creator : _CREATOR;
326328
_metadata = metadata;
327329
_wayPoints = copyOf(wayPoints);
328330
_routes = copyOf(routes);
@@ -1701,7 +1703,9 @@ public static Writer of(final Indent indent) {
17011703
*
17021704
* @param creator the name or URL of the software that created your GPX
17031705
* document. This allows others to inform the creator of a GPX
1704-
* instance document that fails to validate.
1706+
* instance document that fails to validate. If the {@code creator}
1707+
* is {@code null}, {@code "JPX - https://github.com/jenetics/jpx"}
1708+
* is used instead.
17051709
* @param version the GPX version
17061710
* @param metadata the metadata about the GPS file
17071711
* @param wayPoints the way-points
@@ -1737,7 +1741,9 @@ public static GPX of(
17371741
*
17381742
* @param creator the name or URL of the software that created your GPX
17391743
* document. This allows others to inform the creator of a GPX
1740-
* instance document that fails to validate.
1744+
* instance document that fails to validate. If the {@code creator}
1745+
* is {@code null}, {@code "JPX - https://github.com/jenetics/jpx"}
1746+
* is used instead.
17411747
* @param metadata the metadata about the GPS file
17421748
* @param wayPoints the way-points
17431749
* @param routes the routes
@@ -1771,7 +1777,9 @@ public static GPX of(
17711777
*
17721778
* @param creator the name or URL of the software that created your GPX
17731779
* document. This allows others to inform the creator of a GPX
1774-
* instance document that fails to validate.
1780+
* instance document that fails to validate. If the {@code creator}
1781+
* is {@code null}, {@code "JPX - https://github.com/jenetics/jpx"}
1782+
* is used instead.
17751783
* @param metadata the metadata about the GPS file
17761784
* @param wayPoints the way-points
17771785
* @param routes the routes
@@ -1805,7 +1813,9 @@ public static GPX of(
18051813
*
18061814
* @param creator the name or URL of the software that created your GPX
18071815
* document. This allows others to inform the creator of a GPX
1808-
* instance document that fails to validate.
1816+
* instance document that fails to validate. If the {@code creator}
1817+
* is {@code null}, {@code "JPX - https://github.com/jenetics/jpx"}
1818+
* is used instead.
18091819
* @param version the GPX version
18101820
* @param metadata the metadata about the GPS file
18111821
* @param wayPoints the way-points

jpx/src/test/java/io/jenetics/jpx/GPXTest.java

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -960,4 +960,45 @@ public void issue170_InvalidGPXVersion() throws IOException {
960960
assertThat(gpx.getTracks().get(0).getSegments().get(0)).hasSize(2);
961961
}
962962

963+
@Test
964+
public void issue186_MissingCreator() throws IOException {
965+
final var resource = "/io/jenetics/jpx/ISSUE-186.gpx";
966+
final GPX gpx_lenient;
967+
try (InputStream in = getClass().getResourceAsStream(resource)) {
968+
gpx_lenient = GPX.Reader.of(Mode.LENIENT).read(in);
969+
}
970+
971+
assertThat(gpx_lenient.getVersion()).isEqualTo("1.1");
972+
assertThat(gpx_lenient.getCreator()).isEqualTo("JPX - https://github.com/jenetics/jpx");
973+
assertThat(gpx_lenient.getTracks()).hasSize(1);
974+
assertThat(gpx_lenient.getTracks().get(0).getSegments()).hasSize(1);
975+
assertThat(gpx_lenient.getTracks().get(0).getSegments().get(0)).hasSize(9);
976+
977+
978+
try (InputStream in = getClass().getResourceAsStream("/path/to/resource")) {
979+
GPX.Reader.of(Mode.STRICT).read(in);
980+
Assert.fail("Expected InvalidObjectException to be thrown.");
981+
} catch (NullPointerException e) {
982+
// Expected to fail in STRICT mode, as Creator attribute is missing
983+
} catch (Exception e) {
984+
Assert.fail("Unexpected exception was thrown: " + e);
985+
}
986+
}
987+
988+
@Test
989+
public void issue186_NullCreator() throws IOException {
990+
Random random = new Random();
991+
GPX createGPX = GPX.of(
992+
Version.V11,
993+
null,
994+
random.nextBoolean() ? MetadataTest.nextMetadata(random) : null,
995+
random.nextBoolean() ? WayPointTest.nextWayPoints(random) : null,
996+
random.nextBoolean() ? RouteTest.nextRoutes(random) : null,
997+
random.nextBoolean() ? TrackTest.nextTracks(random) : null,
998+
random.nextBoolean() ? doc() : null
999+
);
1000+
1001+
assertThat(createGPX.getCreator()).isEqualTo("JPX - https://github.com/jenetics/jpx");
1002+
}
1003+
9631004
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version='1.0' encoding='UTF-8' standalone='yes' ?>
2+
<gpx version="1.1">
3+
<trk>
4+
<trkseg>
5+
<trkpt lat="47.1849902" lon="9.3118156"><ele>1411.7906106047938</ele><time>2018-09-30T09:43:37Z</time></trkpt>
6+
<trkpt lat="47.1847356" lon="9.3116516"><ele>1392.486126435269</ele><time>2018-09-30T09:44:41Z</time></trkpt>
7+
<trkpt lat="47.1844677" lon="9.3115969"><ele>1395.0386210201773</ele><time>2018-09-30T09:45:09Z</time></trkpt>
8+
<trkpt lat="47.1841943" lon="9.3116178"><ele>1399.1852111777555</ele><time>2018-09-30T09:45:39Z</time></trkpt>
9+
<trkpt lat="47.1839262" lon="9.311698"><ele>1400.9042412783833</ele><time>2018-09-30T09:46:06Z</time></trkpt>
10+
<trkpt lat="47.1836688" lon="9.3118495"><ele>1404.8712068295272</ele><time>2018-09-30T09:46:30Z</time></trkpt>
11+
<trkpt lat="47.1834009" lon="9.3119155"><ele>1406.7036626781644</ele><time>2018-09-30T09:46:56Z</time></trkpt>
12+
<trkpt lat="47.1831309" lon="9.3119291"><ele>1408.6363346678631</ele><time>2018-09-30T09:47:24Z</time></trkpt>
13+
<trkpt lat="47.18286" lon="9.311905"><ele>1410.9618086711207</ele><time>2018-09-30T09:47:48Z</time></trkpt>
14+
</trkseg>
15+
</trk>
16+
</gpx>

0 commit comments

Comments
 (0)