diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c20d16e..9e7e25ba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,14 @@ Changelog ========= +## 1.11.0-SNAPSHOT (current main) + +### Bug Fixes +* Fix crash in non-contribution based endpoints caused by very long and complex filters ([#330]) + +[#330]: https://github.com/GIScience/ohsome-api/issues/330 + + ## 1.10.3 ### Bug Fixes diff --git a/src/main/lombok/org/heigit/ohsome/ohsomeapi/inputprocessing/InputProcessingUtils.java b/src/main/lombok/org/heigit/ohsome/ohsomeapi/inputprocessing/InputProcessingUtils.java index 354b8727..693d4b65 100644 --- a/src/main/lombok/org/heigit/ohsome/ohsomeapi/inputprocessing/InputProcessingUtils.java +++ b/src/main/lombok/org/heigit/ohsome/ohsomeapi/inputprocessing/InputProcessingUtils.java @@ -5,7 +5,6 @@ import java.time.format.DateTimeFormatter; import java.time.temporal.ChronoField; import java.util.ArrayList; -import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.Set; @@ -17,6 +16,7 @@ import org.heigit.ohsome.ohsomeapi.utils.TimestampFormatter; import org.heigit.ohsome.oshdb.OSHDBTag; import org.heigit.ohsome.oshdb.api.mapreducer.MapReducer; +import org.heigit.ohsome.oshdb.filter.BinaryOperator; import org.heigit.ohsome.oshdb.filter.ChangesetIdFilterEquals; import org.heigit.ohsome.oshdb.filter.ChangesetIdFilterEqualsAnyOf; import org.heigit.ohsome.oshdb.filter.ChangesetIdFilterRange; @@ -407,10 +407,16 @@ public FilterExpression parseFilter(FilterParser fp, String filter) { * see also #289.

*/ public static boolean filterSuitableForSnapshots(FilterExpression filter) { - return filter.normalize().stream().flatMap(Collection::stream) - .noneMatch(f -> f instanceof ChangesetIdFilterEquals - || f instanceof ChangesetIdFilterRange - || f instanceof ChangesetIdFilterEqualsAnyOf); + if (filter instanceof ChangesetIdFilterEquals + || filter instanceof ChangesetIdFilterRange + || filter instanceof ChangesetIdFilterEqualsAnyOf) { + return false; + } + if (filter instanceof BinaryOperator operator) { + return filterSuitableForSnapshots(operator.getLeftOperand()) + && filterSuitableForSnapshots(operator.getRightOperand()); + } + return true; } /**