From e447b47236bd09b13b63ab5253c7a2aff94b60be Mon Sep 17 00:00:00 2001 From: Leonard Ehrenfried Date: Wed, 5 Jan 2022 12:41:32 +0100 Subject: [PATCH 01/13] Configure JaCoCo coverage --- pom.xml | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b88f296d1a0..c1417e580bc 100644 --- a/pom.xml +++ b/pom.xml @@ -222,8 +222,11 @@ 3 - + + @{argLine} -Xmx2G -Dfile.encoding=UTF-8 --illegal-access=permit @@ -241,6 +244,26 @@ false + + + org.jacoco + jacoco-maven-plugin + 0.8.7 + + + + prepare-agent + + + + jacoco-report + prepare-package + + report + + + + UTF-8 opentripplanner/OpenTripPlanner + + From 3165eddf52c5cfe54f119e426b7faf0c0005c9fe Mon Sep 17 00:00:00 2001 From: Hannes Junnila Date: Wed, 12 Jan 2022 20:45:32 +0200 Subject: [PATCH 07/13] Guard against null in isPartOfSameStationAs --- src/main/java/org/opentripplanner/model/StationElement.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/org/opentripplanner/model/StationElement.java b/src/main/java/org/opentripplanner/model/StationElement.java index 6fd846d27b0..151671a1bd2 100644 --- a/src/main/java/org/opentripplanner/model/StationElement.java +++ b/src/main/java/org/opentripplanner/model/StationElement.java @@ -116,6 +116,10 @@ public boolean isPartOfStation() { * (element). */ public boolean isPartOfSameStationAs(StopLocation other) { + if (other == null) { + return false; + } + return isPartOfStation() && parentStation.equals(other.getParentStation()); } From b6e5c5644cf31c36b5bfee8d8565e12a6c432db4 Mon Sep 17 00:00:00 2001 From: Hannes Junnila Date: Wed, 12 Jan 2022 20:45:48 +0200 Subject: [PATCH 08/13] Do not try cleanup if nothing to do --- src/main/java/org/opentripplanner/routing/RoutingService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/opentripplanner/routing/RoutingService.java b/src/main/java/org/opentripplanner/routing/RoutingService.java index b19b3f2947f..c301bb3cdb8 100644 --- a/src/main/java/org/opentripplanner/routing/RoutingService.java +++ b/src/main/java/org/opentripplanner/routing/RoutingService.java @@ -57,7 +57,7 @@ public RoutingResponse route(RoutingRequest request, Router router) { RoutingWorker worker = new RoutingWorker(router, request, zoneId); return worker.route(); } finally { - if (request != null) { + if (request != null && request.rctx != null) { request.cleanup(); } } From 213f2d77ef97b17433e33073b52f072b2ff1594b Mon Sep 17 00:00:00 2001 From: Hannes Junnila Date: Wed, 12 Jan 2022 20:46:13 +0200 Subject: [PATCH 09/13] Log state creation with invalid edge --- .../java/org/opentripplanner/routing/core/StateEditor.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/org/opentripplanner/routing/core/StateEditor.java b/src/main/java/org/opentripplanner/routing/core/StateEditor.java index 51c111d969d..46edad1c931 100644 --- a/src/main/java/org/opentripplanner/routing/core/StateEditor.java +++ b/src/main/java/org/opentripplanner/routing/core/StateEditor.java @@ -47,6 +47,11 @@ public StateEditor(State parent, Edge e) { child.backState = null; child.vertex = parent.vertex; child.stateData = child.stateData.clone(); + } else if (e.getFromVertex() == null || e.getToVertex() == null) { + child.vertex = parent.vertex; + child.stateData = child.stateData.clone(); + LOG.error("From or to vertex is null for {}", e); + defectiveTraversal = true; } else { // be clever // Note that we use equals(), not ==, here to allow for dynamically From 6544583e25a82704441ce7f67c9c1f86598cd1e1 Mon Sep 17 00:00:00 2001 From: Hannes Junnila Date: Wed, 12 Jan 2022 20:46:36 +0200 Subject: [PATCH 10/13] Guard against invalid id in Transmodel API --- .../ext/transmodelapi/TransmodelGraphQLSchema.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/ext/java/org/opentripplanner/ext/transmodelapi/TransmodelGraphQLSchema.java b/src/ext/java/org/opentripplanner/ext/transmodelapi/TransmodelGraphQLSchema.java index b8bd543ede4..df0cce730e9 100644 --- a/src/ext/java/org/opentripplanner/ext/transmodelapi/TransmodelGraphQLSchema.java +++ b/src/ext/java/org/opentripplanner/ext/transmodelapi/TransmodelGraphQLSchema.java @@ -760,8 +760,10 @@ private GraphQLSchema create() { .type(new GraphQLNonNull(Scalars.GraphQLID)) .build()) .dataFetcher(environment -> { - return GqlUtil.getRoutingService(environment).getRouteForId(TransitIdMapper - .mapIDToDomain(environment.getArgument("id"))); + final String id = environment.getArgument("id"); + if (id.isBlank()) { return null; } + return GqlUtil.getRoutingService(environment) + .getRouteForId(TransitIdMapper.mapIDToDomain(id)); }) .build()) .field(GraphQLFieldDefinition From 06689433dbe7b378258847af6e7ac13e816c551a Mon Sep 17 00:00:00 2001 From: Hannes Junnila Date: Thu, 13 Jan 2022 16:16:24 +0200 Subject: [PATCH 11/13] Simplify cleanup --- .../org/opentripplanner/routing/RoutingService.java | 2 +- .../routing/api/request/RoutingRequest.java | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/opentripplanner/routing/RoutingService.java b/src/main/java/org/opentripplanner/routing/RoutingService.java index c301bb3cdb8..b19b3f2947f 100644 --- a/src/main/java/org/opentripplanner/routing/RoutingService.java +++ b/src/main/java/org/opentripplanner/routing/RoutingService.java @@ -57,7 +57,7 @@ public RoutingResponse route(RoutingRequest request, Router router) { RoutingWorker worker = new RoutingWorker(router, request, zoneId); return worker.route(); } finally { - if (request != null && request.rctx != null) { + if (request != null) { request.cleanup(); } } diff --git a/src/main/java/org/opentripplanner/routing/api/request/RoutingRequest.java b/src/main/java/org/opentripplanner/routing/api/request/RoutingRequest.java index fb85507ee9d..1cba4bc47ff 100644 --- a/src/main/java/org/opentripplanner/routing/api/request/RoutingRequest.java +++ b/src/main/java/org/opentripplanner/routing/api/request/RoutingRequest.java @@ -1239,11 +1239,13 @@ public RoutingContext getRoutingContext() { /** Tear down any routing context (remove temporary edges from edge lists) */ public void cleanup() { - if (this.rctx == null) - LOG.warn("routing context was not set, cannot destroy it."); - else { - rctx.destroy(); - LOG.debug("routing context destroyed"); + if (this.rctx != null) { + try { + rctx.destroy(); + } + catch (Exception e) { + LOG.error("Could not destroy the routing context", e); + } } } From af6e382a2f07d5bfd05fe14aeeb707f66b35f07a Mon Sep 17 00:00:00 2001 From: OTP Changelog Bot Date: Thu, 13 Jan 2022 14:30:18 +0000 Subject: [PATCH 12/13] Add changelog entry for #3811 [ci skip] --- docs/Changelog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/Changelog.md b/docs/Changelog.md index 97ca6747d40..71ee5d9bd40 100644 --- a/docs/Changelog.md +++ b/docs/Changelog.md @@ -110,6 +110,7 @@ - Fix: Account for wait-time in no-wait Raptor strategy [#3798](https://github.com/opentripplanner/OpenTripPlanner/pull/3798) - Read in flex window from Netex feeds [#3800](https://github.com/opentripplanner/OpenTripPlanner/pull/3800) - Fix NPE when routing on a graph without transit data. [#3804](https://github.com/opentripplanner/OpenTripPlanner/pull/3804) +- Capture code coverage with jacoco and codecov.io [#3811](https://github.com/opentripplanner/OpenTripPlanner/pull/3811) [](AUTOMATIC_CHANGELOG_PLACEHOLDER_DO_NOT_REMOVE) From 8dc91ab84a448d31931d8355bff64908c0fb3f63 Mon Sep 17 00:00:00 2001 From: Leonard Ehrenfried Date: Fri, 14 Jan 2022 11:56:34 +0100 Subject: [PATCH 13/13] Disable codecov comment bot --- codecov.yml | 1 + 1 file changed, 1 insertion(+) create mode 100644 codecov.yml diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 00000000000..69cb76019a4 --- /dev/null +++ b/codecov.yml @@ -0,0 +1 @@ +comment: false