Skip to content

Commit

Permalink
Avoid NullPointerExceptions when rerouting vehicles
Browse files Browse the repository at this point in the history
These could happen with vehicles that process transport orders
containing drive order steps that don't have a path.

Also bump version number and set release date for the bugfix release.

Co-authored-by: Stefan Walter <stefan.walter@iml.fraunhofer.de>
Merged-by: Stefan Walter <stefan.walter@iml.fraunhofer.de>
  • Loading branch information
martingr and swltr committed Jun 19, 2024
1 parent be80b89 commit 1379262
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
2 changes: 1 addition & 1 deletion gradle/common.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ else if (System.env.CI_PIPELINE_IID) {
// - The minor version number should be incremented when new feature were added.
// - The patch level should be incremented with every small change to the code
// (e.g. bugfixes).
project.version = "5.17.0"
project.version = "5.17.1"
if (!(project.hasProperty("NO_BUILD_NUMBER")
&& Boolean.valueOf(project.getProperties().get("NO_BUILD_NUMBER")))) {
project.version += "-$versionBuild"
Expand Down
5 changes: 5 additions & 0 deletions openTCS-Documentation/src/docs/release-notes/changelog.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ The openTCS developers

This change log lists the most relevant changes for past releases in reverse chronological order.

== Version 5.17.1 (2024-06-19)

* Bugs fixed:
** Avoid `NullPointerException`s when rerouting vehicles that process transport orders containing drive order steps that don't have a path.

== Version 5.17 (2024-05-21)

* Bugs fixed:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,12 +185,22 @@ private List<DriveOrder> updatePathLocks(List<DriveOrder> orders) {
List<Step> updatedSteps = new ArrayList<>();

for (Step step : order.getRoute().getSteps()) {
Path path = transportOrderService.fetchObject(Path.class, step.getPath().getReference());
updatedSteps.add(new Route.Step(path,
step.getSourcePoint(),
step.getDestinationPoint(),
step.getVehicleOrientation(),
step.getRouteIndex()));
if (step.getPath() != null) {
updatedSteps.add(
new Route.Step(
transportOrderService.fetchObject(Path.class, step.getPath().getReference()),
step.getSourcePoint(),
step.getDestinationPoint(),
step.getVehicleOrientation(),
step.getRouteIndex()
)
);
}
else {
// If the step doesn't have a path, there are no path locks to be updated and we can
// simply keep the step as it is.
updatedSteps.add(step);
}
}

Route updatedRoute = new Route(updatedSteps, order.getRoute().getCosts());
Expand Down Expand Up @@ -245,6 +255,7 @@ private boolean containsLockedPath(List<DriveOrder> orders) {
return orders.stream()
.map(order -> order.getRoute().getSteps())
.flatMap(steps -> steps.stream())
.filter(step -> step.getPath() != null)
.anyMatch(step -> step.getPath().isLocked());
}

Expand Down Expand Up @@ -288,7 +299,7 @@ public boolean test(Step step) {
}
break;
case PAUSE_AT_PATH_LOCK:
if (step.getPath().isLocked()) {
if (step.getPath() != null && step.getPath().isLocked()) {
executionAllowed = false;
}
break;
Expand Down

0 comments on commit 1379262

Please sign in to comment.