From 396971efcc69d1f9873fb0ccf7d74f9378955f5b Mon Sep 17 00:00:00 2001 From: Hannes Junnila Date: Wed, 16 Mar 2022 15:10:59 +0200 Subject: [PATCH 1/8] Remove unused field from graph --- .../module/geometry/GeometryAndBlockProcessor.java | 7 ------- src/main/java/org/opentripplanner/routing/graph/Graph.java | 6 ------ 2 files changed, 13 deletions(-) diff --git a/src/main/java/org/opentripplanner/graph_builder/module/geometry/GeometryAndBlockProcessor.java b/src/main/java/org/opentripplanner/graph_builder/module/geometry/GeometryAndBlockProcessor.java index 5f8e765f061..753bfea07fb 100644 --- a/src/main/java/org/opentripplanner/graph_builder/module/geometry/GeometryAndBlockProcessor.java +++ b/src/main/java/org/opentripplanner/graph_builder/module/geometry/GeometryAndBlockProcessor.java @@ -261,13 +261,6 @@ private void interline(Collection tripPatterns, Graph graph) { } } - // Copy all interline relationships into the field holding them in the graph. - // TODO: verify whether we need to be keeping track of patterns at all here, or could just accumulate trip-trip relationships. - for (P2 patterns : interlines.keySet()) { - for (P2 trips : interlines.get(patterns)) { - graph.interlinedTrips.put(trips.first, trips.second); - } - } LOG.info("Done finding interlining trips."); } diff --git a/src/main/java/org/opentripplanner/routing/graph/Graph.java b/src/main/java/org/opentripplanner/routing/graph/Graph.java index b593babd985..d78173141bd 100644 --- a/src/main/java/org/opentripplanner/routing/graph/Graph.java +++ b/src/main/java/org/opentripplanner/routing/graph/Graph.java @@ -1,8 +1,6 @@ package org.opentripplanner.routing.graph; import com.google.common.annotations.VisibleForTesting; -import com.google.common.collect.BiMap; -import com.google.common.collect.HashBiMap; import com.google.common.collect.HashMultimap; import com.google.common.collect.Maps; import com.google.common.collect.Multimap; @@ -65,7 +63,6 @@ import org.opentripplanner.model.TimetableSnapshotProvider; import org.opentripplanner.model.TransitEntity; import org.opentripplanner.model.TransitMode; -import org.opentripplanner.model.Trip; import org.opentripplanner.model.TripPattern; import org.opentripplanner.model.WgsCoordinate; import org.opentripplanner.model.calendar.CalendarService; @@ -240,9 +237,6 @@ public class Graph implements Serializable { */ public Map tripPatternForId = Maps.newHashMap(); - /** Interlining relationships between trips. */ - public final BiMap interlinedTrips = HashBiMap.create(); - /** Pre-generated transfers between all stops. */ public final Multimap transfersByStop = HashMultimap.create(); From 502b6a279aefdf34f3b5e209329b7278f96621fc Mon Sep 17 00:00:00 2001 From: Hannes Junnila Date: Wed, 16 Mar 2022 16:17:39 +0200 Subject: [PATCH 2/8] Update to Java 17 --- .github/workflows/cibuild.yml | 4 +- .github/workflows/performance-test.yml | 4 +- docs/Basic-Tutorial.md | 2 +- pom.xml | 24 ++- .../kryo/BuildConfigSerializer.java | 2 +- .../kryo/HashBiMapSerializer.java | 19 -- .../kryo/RouterConfigSerializer.java | 2 +- .../UnmodifiableCollectionsSerializer.java | 180 ++++++++++++++++++ .../JavaImmutableListSerializer.java | 2 +- .../JavaImmutableMapSerializer.java | 43 +++++ .../JavaImmutableSetSerializer.java | 2 +- .../graph/kryosupport/KryoBuilder.java | 34 +--- .../__snapshots__/TransitSnapshotTest.snap | 2 +- .../alerts/AlertsUpdateHandlerTest.java | 2 +- 14 files changed, 260 insertions(+), 62 deletions(-) delete mode 100644 src/main/java/org/opentripplanner/kryo/HashBiMapSerializer.java create mode 100644 src/main/java/org/opentripplanner/kryo/UnmodifiableCollectionsSerializer.java create mode 100644 src/main/java/org/opentripplanner/routing/graph/kryosupport/JavaImmutableMapSerializer.java diff --git a/.github/workflows/cibuild.yml b/.github/workflows/cibuild.yml index a142ec3d45b..dda231689c5 100644 --- a/.github/workflows/cibuild.yml +++ b/.github/workflows/cibuild.yml @@ -26,10 +26,10 @@ jobs: with: fetch-depth: 0 # Java setup step completes very fast, no need to run in a preconfigured docker container - - name: Set up JDK 11 + - name: Set up JDK 17 uses: actions/setup-java@v1 with: - java-version: 11 + java-version: 17 - name: Cache local Maven repository uses: actions/cache@v2 with: diff --git a/.github/workflows/performance-test.yml b/.github/workflows/performance-test.yml index fd31db430f2..38c8c72e41d 100644 --- a/.github/workflows/performance-test.yml +++ b/.github/workflows/performance-test.yml @@ -14,10 +14,10 @@ jobs: with: fetch-depth: 0 - - name: Set up JDK 11 + - name: Set up JDK 17 uses: actions/setup-java@v1 with: - java-version: 11 + java-version: 17 - name: Set up Maven uses: stCarolas/setup-maven@v4.2 diff --git a/docs/Basic-Tutorial.md b/docs/Basic-Tutorial.md index a4d20286bd0..20e7099cfa3 100644 --- a/docs/Basic-Tutorial.md +++ b/docs/Basic-Tutorial.md @@ -4,7 +4,7 @@ This page should allow you to set up and test your own OTP2 server. If all goes ## Get Java -As a Java program, OTP must be run within a Java virtual machine (JVM), which is provided as part of the Java runtime (JRE) or Java development kit (JDK). OTP2 is compatible with Java 11 or later. We recommend running on Java 11 rather than a later version, as it is a long-term support release. Run `java -version` to check that you have version 11 or newer of the JVM installed. If you do not, you will need to install a recent OpenJDK or Oracle Java package for your operating system. +As a Java program, OTP must be run within a Java virtual machine (JVM), which is provided as part of the Java runtime (JRE) or Java development kit (JDK). OTP2 is compatible with Java 17 or later. We recommend running on Java 17 rather than a later version, as it is a long-term support release. Run `java -version` to check that you have version 17 or newer of the JVM installed. If you do not, you will need to install a recent OpenJDK or Oracle Java package for your operating system. ## Get OTP diff --git a/pom.xml b/pom.xml index f911872dd2a..e004f835248 100644 --- a/pom.xml +++ b/pom.xml @@ -139,7 +139,7 @@ 3.8.1 - 11 + 17 @@ -235,7 +235,17 @@ -Xmx2G -Dfile.encoding=UTF-8 --illegal-access=permit + --add-opens java.base/java.io=ALL-UNNAMED + --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.lang.module=ALL-UNNAMED + --add-opens java.base/java.math=ALL-UNNAMED + --add-opens java.base/java.net=ALL-UNNAMED + --add-opens java.base/java.text=ALL-UNNAMED + --add-opens java.base/java.time=ALL-UNNAMED + --add-opens java.base/java.time.zone=ALL-UNNAMED + --add-opens java.base/java.util=ALL-UNNAMED + --add-opens java.base/java.util.concurrent.locks=ALL-UNNAMED + --add-opens java.base/java.util.regex=ALL-UNNAMED --add-opens java.base/jdk.internal.reflect=ALL-UNNAMED --add-opens java.base/jdk.internal.misc=ALL-UNNAMED --add-opens java.base/jdk.internal.loader=ALL-UNNAMED @@ -243,7 +253,11 @@ --add-opens java.base/jdk.internal.util=ALL-UNNAMED --add-opens java.base/jdk.internal.util.jar=ALL-UNNAMED --add-opens java.base/jdk.internal.module=ALL-UNNAMED - --add-opens java.base/java.lang=ALL-UNNAMED + --add-opens java.base/sun.net.www.protocol.http=ALL-UNNAMED + --add-opens java.base/sun.net.www.protocol.jar=ALL-UNNAMED + --add-opens java.base/sun.util.calendar=ALL-UNNAMED + --add-opens java.base/sun.util.locale=ALL-UNNAMED + --add-opens java.xml/org.xml.sax.helpers=ALL-UNNAMED false @@ -551,8 +565,8 @@ org.mockito - mockito-all - 1.10.19 + mockito-core + 4.4.0 test @@ -566,7 +580,7 @@ com.conveyal kryo-tools - 1.3.0 + 1.4.0 diff --git a/src/main/java/org/opentripplanner/kryo/BuildConfigSerializer.java b/src/main/java/org/opentripplanner/kryo/BuildConfigSerializer.java index 613a7a3a7ab..984b0860e8c 100644 --- a/src/main/java/org/opentripplanner/kryo/BuildConfigSerializer.java +++ b/src/main/java/org/opentripplanner/kryo/BuildConfigSerializer.java @@ -29,7 +29,7 @@ public void write(Kryo kryo, Output output, BuildConfig object) { } @Override - public BuildConfig read(Kryo kryo, Input input, Class type) { + public BuildConfig read(Kryo kryo, Input input, Class type) { return new BuildConfig( ConfigLoader.nodeFromString(input.readString(), SOURCE), SOURCE, diff --git a/src/main/java/org/opentripplanner/kryo/HashBiMapSerializer.java b/src/main/java/org/opentripplanner/kryo/HashBiMapSerializer.java deleted file mode 100644 index 0b95c7534aa..00000000000 --- a/src/main/java/org/opentripplanner/kryo/HashBiMapSerializer.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.opentripplanner.kryo; - -import com.esotericsoftware.kryo.Kryo; -import com.esotericsoftware.kryo.io.Input; -import com.esotericsoftware.kryo.serializers.MapSerializer; -import com.google.common.collect.HashBiMap; - -import java.util.Map; - -/** - * Created by abyrd on 2018-10-25 - */ -public class HashBiMapSerializer extends MapSerializer { - - protected Map create(Kryo kryo, Input input, Class type) { - return HashBiMap.create(); - } - -} diff --git a/src/main/java/org/opentripplanner/kryo/RouterConfigSerializer.java b/src/main/java/org/opentripplanner/kryo/RouterConfigSerializer.java index 08b385a7234..81fe5eb9649 100644 --- a/src/main/java/org/opentripplanner/kryo/RouterConfigSerializer.java +++ b/src/main/java/org/opentripplanner/kryo/RouterConfigSerializer.java @@ -26,7 +26,7 @@ public void write(Kryo kryo, Output output, RouterConfig object) { output.writeString(object.toJson()); } @Override - public RouterConfig read(Kryo kryo, Input input, Class type) { + public RouterConfig read(Kryo kryo, Input input, Class type) { return new RouterConfig( ConfigLoader.nodeFromString(input.readString(), SOURCE), SOURCE, diff --git a/src/main/java/org/opentripplanner/kryo/UnmodifiableCollectionsSerializer.java b/src/main/java/org/opentripplanner/kryo/UnmodifiableCollectionsSerializer.java new file mode 100644 index 00000000000..6563ead3ee4 --- /dev/null +++ b/src/main/java/org/opentripplanner/kryo/UnmodifiableCollectionsSerializer.java @@ -0,0 +1,180 @@ +/* + * Copyright 2010 Martin Grotzke + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.opentripplanner.kryo; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.SortedMap; +import java.util.SortedSet; +import java.util.TreeMap; +import java.util.TreeSet; + +import com.esotericsoftware.kryo.Kryo; +import com.esotericsoftware.kryo.Serializer; +import com.esotericsoftware.kryo.io.Input; +import com.esotericsoftware.kryo.io.Output; + +/** + * A kryo {@link Serializer} for unmodifiable {@link Collection}s and {@link Map}s created via + * {@link Collections}. + * + * @author Martin Grotzke + */ +public class UnmodifiableCollectionsSerializer extends Serializer { + + @Override + public Object read(Kryo kryo, Input input, Class clazz) { + int ordinal = input.readInt(true); + UnmodifiableCollection unmodifiableCollection = UnmodifiableCollection.values()[ordinal]; + Object sourceCollection = kryo.readClassAndObject(input); + return unmodifiableCollection.create(sourceCollection); + } + + @Override + public void write(Kryo kryo, Output output, Object object) { + try { + UnmodifiableCollection unmodifiableCollection = + UnmodifiableCollection.valueOfType(object.getClass()); + // the ordinal could be replaced by s.th. else (e.g. a explicitely managed "id") + output.writeInt(unmodifiableCollection.ordinal(), true); + kryo.writeClassAndObject(output, getValues(object)); + } + catch (RuntimeException e) { + // Don't eat and wrap RuntimeExceptions because the ObjectBuffer.write... + // handles SerializationException specifically (resizing the buffer)... + throw e; + } + catch (Exception e) { + throw new RuntimeException(e); + } + } + + @Override + public Object copy(Kryo kryo, Object original) { + try { + UnmodifiableCollection unmodifiableCollection = + UnmodifiableCollection.valueOfType(original.getClass()); + Object sourceCollectionCopy = kryo.copy(getValues(original)); + return unmodifiableCollection.create(sourceCollectionCopy); + } + catch (RuntimeException e) { + // Don't eat and wrap RuntimeExceptions + throw e; + } + catch (Exception e) { + throw new RuntimeException(e); + } + } + + private Collection getValues(Object coll) { + return new ArrayList<>((Collection) coll); + } + + private enum UnmodifiableCollection { + COLLECTION(Collections.unmodifiableCollection(Arrays.asList("")).getClass()) { + @Override + public Object create(Object sourceCollection) { + return Collections.unmodifiableCollection((Collection) sourceCollection); + } + }, + RANDOM_ACCESS_LIST(Collections.unmodifiableList(new ArrayList()).getClass()) { + @Override + public Object create(Object sourceCollection) { + return Collections.unmodifiableList((List) sourceCollection); + } + }, + LIST(Collections.unmodifiableList(new LinkedList()).getClass()) { + @Override + public Object create(Object sourceCollection) { + return Collections.unmodifiableList((List) sourceCollection); + } + }, + SET(Collections.unmodifiableSet(new HashSet()).getClass()) { + @Override + public Object create(Object sourceCollection) { + return Collections.unmodifiableSet((Set) sourceCollection); + } + }, + SORTED_SET(Collections.unmodifiableSortedSet(new TreeSet()).getClass()) { + @Override + public Object create(Object sourceCollection) { + return Collections.unmodifiableSortedSet((SortedSet) sourceCollection); + } + }, + MAP(Collections.unmodifiableMap(new HashMap()).getClass()) { + @Override + public Object create(Object sourceCollection) { + return Collections.unmodifiableMap((Map) sourceCollection); + } + + }, + SORTED_MAP(Collections.unmodifiableSortedMap(new TreeMap()).getClass()) { + @Override + public Object create(Object sourceCollection) { + return Collections.unmodifiableSortedMap((SortedMap) sourceCollection); + } + }; + + private final Class type; + + UnmodifiableCollection(Class type) { + this.type = type; + } + + public abstract Object create(Object sourceCollection); + + static UnmodifiableCollection valueOfType(Class type) { + for (UnmodifiableCollection item : values()) { + if (item.type.equals(type)) { + return item; + } + } + throw new IllegalArgumentException("The type " + type + " is not supported."); + } + + } + + /** + * Creates a new {@link UnmodifiableCollectionsSerializer} and registers its serializer for the + * several unmodifiable Collections that can be created via {@link Collections}, including + * {@link Map}s. + * + * @param kryo the {@link Kryo} instance to set the serializer on. + * @see Collections#unmodifiableCollection(Collection) + * @see Collections#unmodifiableList(List) + * @see Collections#unmodifiableSet(Set) + * @see Collections#unmodifiableSortedSet(SortedSet) + * @see Collections#unmodifiableMap(Map) + * @see Collections#unmodifiableSortedMap(SortedMap) + */ + public static void registerSerializers(Kryo kryo) { + UnmodifiableCollectionsSerializer serializer = new UnmodifiableCollectionsSerializer(); + UnmodifiableCollection.values(); + for (UnmodifiableCollection item : UnmodifiableCollection.values()) { + kryo.register(item.type, serializer); + } + } + +} diff --git a/src/main/java/org/opentripplanner/routing/graph/kryosupport/JavaImmutableListSerializer.java b/src/main/java/org/opentripplanner/routing/graph/kryosupport/JavaImmutableListSerializer.java index 3efc9f3b134..49cec511ef1 100644 --- a/src/main/java/org/opentripplanner/routing/graph/kryosupport/JavaImmutableListSerializer.java +++ b/src/main/java/org/opentripplanner/routing/graph/kryosupport/JavaImmutableListSerializer.java @@ -15,7 +15,7 @@ public void write(Kryo kryo, Output output, List list) { } @Override - public List read(Kryo kryo, Input input, Class type) { + public List read(Kryo kryo, Input input, Class type) { return kryo.readObject(input, ImmSerList.class).toList(); } diff --git a/src/main/java/org/opentripplanner/routing/graph/kryosupport/JavaImmutableMapSerializer.java b/src/main/java/org/opentripplanner/routing/graph/kryosupport/JavaImmutableMapSerializer.java new file mode 100644 index 00000000000..8c6449df68d --- /dev/null +++ b/src/main/java/org/opentripplanner/routing/graph/kryosupport/JavaImmutableMapSerializer.java @@ -0,0 +1,43 @@ +package org.opentripplanner.routing.graph.kryosupport; + +import com.esotericsoftware.kryo.Kryo; +import com.esotericsoftware.kryo.Serializer; +import com.esotericsoftware.kryo.io.Input; +import com.esotericsoftware.kryo.io.Output; +import java.io.Serializable; +import java.util.Map; + +@SuppressWarnings("rawtypes") +class JavaImmutableMapSerializer extends Serializer> { + @Override + public void write(Kryo kryo, Output output, Map map) { + ImmSerMapEntry[] entries = map.entrySet().stream() + .map(ImmSerMapEntry::new) + .toArray(ImmSerMapEntry[]::new); + + kryo.writeObject(output, new ImmSerMap(entries)); + } + + @Override + public Map read(Kryo kryo, Input input, Class> type) { + return Map.ofEntries(kryo.readObject(input, ImmSerMap.class).getEntries()); + } + + private static class ImmSerMap implements Serializable { + private static final long serialVersionUID = 1L; + private final ImmSerMapEntry[] array; + private ImmSerMap(ImmSerMapEntry[] array) { this.array = array; } + private Map.Entry[] getEntries() { return array; } + } + + private static class ImmSerMapEntry implements Map.Entry, Serializable { + private final Object[] entry; + private ImmSerMapEntry(Map.Entry entry) { + this.entry = new Object[]{entry.getKey(), entry.getValue()}; + } + + @Override public K getKey() { return (K) entry[0]; } + @Override public V getValue() { return (V) entry[1]; } + @Override public V setValue(V value) { throw new UnsupportedOperationException();} + } +} diff --git a/src/main/java/org/opentripplanner/routing/graph/kryosupport/JavaImmutableSetSerializer.java b/src/main/java/org/opentripplanner/routing/graph/kryosupport/JavaImmutableSetSerializer.java index 1fe26f85a33..fb673178454 100644 --- a/src/main/java/org/opentripplanner/routing/graph/kryosupport/JavaImmutableSetSerializer.java +++ b/src/main/java/org/opentripplanner/routing/graph/kryosupport/JavaImmutableSetSerializer.java @@ -15,7 +15,7 @@ public void write(Kryo kryo, Output output, Set set) { } @Override - public Set read(Kryo kryo, Input input, Class type) { + public Set read(Kryo kryo, Input input, Class type) { return kryo.readObject(input, ImmSerList.class).toSet(); } diff --git a/src/main/java/org/opentripplanner/routing/graph/kryosupport/KryoBuilder.java b/src/main/java/org/opentripplanner/routing/graph/kryosupport/KryoBuilder.java index d1524465f1e..cb97b3b3baf 100644 --- a/src/main/java/org/opentripplanner/routing/graph/kryosupport/KryoBuilder.java +++ b/src/main/java/org/opentripplanner/routing/graph/kryosupport/KryoBuilder.java @@ -4,25 +4,21 @@ import com.conveyal.kryo.TIntIntHashMapSerializer; import com.esotericsoftware.kryo.Kryo; import com.esotericsoftware.kryo.serializers.ExternalizableSerializer; -import com.esotericsoftware.kryo.serializers.JavaSerializer; +import com.esotericsoftware.kryo.util.DefaultInstantiatorStrategy; import com.google.common.collect.ArrayListMultimap; -import com.google.common.collect.HashBiMap; import com.google.common.collect.HashMultimap; -import de.javakaffee.kryoserializers.UnmodifiableCollectionsSerializer; import de.javakaffee.kryoserializers.guava.ArrayListMultimapSerializer; import de.javakaffee.kryoserializers.guava.HashMultimapSerializer; -import de.javakaffee.kryoserializers.guava.ImmutableSetSerializer; import gnu.trove.impl.hash.TPrimitiveHash; import gnu.trove.list.array.TIntArrayList; import gnu.trove.map.hash.TIntIntHashMap; -import java.util.BitSet; import java.util.List; import java.util.Map; import java.util.Set; import org.objenesis.strategy.SerializingInstantiatorStrategy; import org.opentripplanner.kryo.BuildConfigSerializer; -import org.opentripplanner.kryo.HashBiMapSerializer; import org.opentripplanner.kryo.RouterConfigSerializer; +import org.opentripplanner.kryo.UnmodifiableCollectionsSerializer; import org.opentripplanner.standalone.config.BuildConfig; import org.opentripplanner.standalone.config.RouterConfig; @@ -52,24 +48,15 @@ public static Kryo create() { kryo.register(TIntIntHashMap.class, new TIntIntHashMapSerializer()); // Add support for the package local java.util.ImmutableCollections. - // Not supported in the current com.conveyal:kryo-tools:1.3.0. + // Not supported properly in the current com.conveyal:kryo-tools:1.4.0. // This provide support for List.of, Set.of, Map.of and Collectors.toUnmodifiable(Set|List|Map) kryo.register(List.of().getClass(), new JavaImmutableListSerializer()); kryo.register(List.of(1).getClass(), new JavaImmutableListSerializer()); kryo.register(Set.of().getClass(), new JavaImmutableSetSerializer()); kryo.register(Set.of(1).getClass(), new JavaImmutableSetSerializer()); - kryo.register(Map.of().getClass(), new JavaSerializer()); - kryo.register(Map.of(1, 1).getClass(), new JavaSerializer()); + kryo.register(Map.of().getClass(), new JavaImmutableMapSerializer()); + kryo.register(Map.of(1, 1).getClass(), new JavaImmutableMapSerializer()); - // Kryo's default instantiation and deserialization of BitSets leaves them empty. - // The Kryo BitSet serializer in magro/kryo-serializers naively writes out a dense stream of booleans. - // BitSet's built-in Java serializer saves the internal bitfields, which is efficient. We use that one. - kryo.register(BitSet.class, new JavaSerializer()); - - // BiMap has a constructor that uses its putAll method, which just puts each item in turn. - // It should be possible to reconstruct this like a standard Map. However, the HashBiMap constructor calls an - // init method that creates the two internal maps. So we have to subclass the generic Map serializer. - kryo.register(HashBiMap.class, new HashBiMapSerializer()); kryo.register(HashMultimap.class, new HashMultimapSerializer()); kryo.register(ArrayListMultimap.class, new ArrayListMultimapSerializer()); @@ -77,19 +64,12 @@ public static Kryo create() { kryo.register(RouterConfig.class, new RouterConfigSerializer()); kryo.register(BuildConfig.class, new BuildConfigSerializer()); - // OBA uses unmodifiable collections, but those classes have package-private visibility. Workaround. - // FIXME we're importing all the contributed kryo-serializers just for this one serializer - try { - Class unmodifiableCollection = Class.forName("java.util.Collections$UnmodifiableCollection"); - kryo.addDefaultSerializer(unmodifiableCollection , UnmodifiableCollectionsSerializer.class); - } catch (ClassNotFoundException e) { - throw new RuntimeException(e); - } + UnmodifiableCollectionsSerializer.registerSerializers(kryo); // Instantiation strategy: how should Kryo make new instances of objects when they are deserialized? // The default strategy requires every class you serialize, even in your dependencies, to have a zero-arg // constructor (which can be private). The setInstantiatorStrategy method completely replaces that default // strategy. The nesting below specifies the Java approach as a fallback strategy to the default strategy. - kryo.setInstantiatorStrategy(new Kryo.DefaultInstantiatorStrategy(new SerializingInstantiatorStrategy())); + kryo.setInstantiatorStrategy(new DefaultInstantiatorStrategy(new SerializingInstantiatorStrategy())); return kryo; } } diff --git a/src/test/java/org/opentripplanner/routing/algorithm/mapping/__snapshots__/TransitSnapshotTest.snap b/src/test/java/org/opentripplanner/routing/algorithm/mapping/__snapshots__/TransitSnapshotTest.snap index 4c6d859ca7a..ac139ee8147 100644 --- a/src/test/java/org/opentripplanner/routing/algorithm/mapping/__snapshots__/TransitSnapshotTest.snap +++ b/src/test/java/org/opentripplanner/routing/algorithm/mapping/__snapshots__/TransitSnapshotTest.snap @@ -2701,7 +2701,7 @@ org.opentripplanner.routing.algorithm.mapping.TransitSnapshotTest.test_trip_plan "distance": 18.806, "elevation": "", "lat": 45.53130187189895, - "lon": -122.69644484256081, + "lon": -122.69644484256082, "relativeDirection": "DEPART", "stayOn": false, "streetName": "Northwest Northrup Street", diff --git a/src/test/java/org/opentripplanner/updater/alerts/AlertsUpdateHandlerTest.java b/src/test/java/org/opentripplanner/updater/alerts/AlertsUpdateHandlerTest.java index 0ee25258363..9d227a5c6a5 100644 --- a/src/test/java/org/opentripplanner/updater/alerts/AlertsUpdateHandlerTest.java +++ b/src/test/java/org/opentripplanner/updater/alerts/AlertsUpdateHandlerTest.java @@ -17,10 +17,10 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Spy; -import org.mockito.runners.MockitoJUnitRunner; import java.util.Date; import java.util.HashSet; +import org.mockito.junit.MockitoJUnitRunner; import org.opentripplanner.routing.alertpatch.AlertCause; import org.opentripplanner.routing.alertpatch.AlertEffect; import org.opentripplanner.routing.alertpatch.AlertSeverity; From ffbe67ed571e7f65171d5c2de82c9914c1898353 Mon Sep 17 00:00:00 2001 From: Hannes Junnila Date: Wed, 16 Mar 2022 16:31:42 +0200 Subject: [PATCH 3/8] Remove old warning --- docs/Basic-Tutorial.md | 7 ------- 1 file changed, 7 deletions(-) diff --git a/docs/Basic-Tutorial.md b/docs/Basic-Tutorial.md index 20e7099cfa3..149d3edbc47 100644 --- a/docs/Basic-Tutorial.md +++ b/docs/Basic-Tutorial.md @@ -44,13 +44,6 @@ If you have extracted a smaller PBF file from a larger region, be sure to put on A typical command to start OTP looks like `java -Xmx2G -jar otp.shaded.jar `. The `-Xmx` parameter sets the limit on how much memory OTP is allowed to consume. GTFS and OSM data sets are often very large, and OTP is relatively memory-hungry. You will need at least 1GB of memory when working with the Portland TriMet data set, and several gigabytes for larger inputs. If you have sufficient memory in your computer, set this to a couple of gigabytes (e.g. `-Xmx2G`). Java uses a [garbage collection](https://en.wikipedia.org/wiki/Garbage_collection_(computer_science)) approach to memory management, which requires some "breathing room" to efficiently operate. Without sufficient free memory OTP can grind to a halt. [VisualVM](https://visualvm.github.io) is a good way to inspect Java memory usage, especially with the [VisualGC plugin](https://visualvm.github.io/plugins.html). - - Java 11 has tighter security restrictions than previous versions, so when running OTP under Java 11 you will see warnings like this: - ``` - WARNING: An illegal reflective access operation has occurred - WARNING: Please consider reporting this to the maintainers of com.esotericsoftware.kryo.util.UnsafeUtil - ``` - These warnings are expected to remain for a while, until all libraries OTP2 depends on have fully migrated to Java 11 and we have upgraded them all. ## Building Graphs From 632f80d59d51ae9fa230c07488955a7b8fef0d52 Mon Sep 17 00:00:00 2001 From: Hannes Junnila Date: Wed, 16 Mar 2022 17:09:25 +0200 Subject: [PATCH 4/8] Revert change in snapshot --- .../algorithm/mapping/__snapshots__/TransitSnapshotTest.snap | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/org/opentripplanner/routing/algorithm/mapping/__snapshots__/TransitSnapshotTest.snap b/src/test/java/org/opentripplanner/routing/algorithm/mapping/__snapshots__/TransitSnapshotTest.snap index ac139ee8147..4c6d859ca7a 100644 --- a/src/test/java/org/opentripplanner/routing/algorithm/mapping/__snapshots__/TransitSnapshotTest.snap +++ b/src/test/java/org/opentripplanner/routing/algorithm/mapping/__snapshots__/TransitSnapshotTest.snap @@ -2701,7 +2701,7 @@ org.opentripplanner.routing.algorithm.mapping.TransitSnapshotTest.test_trip_plan "distance": 18.806, "elevation": "", "lat": 45.53130187189895, - "lon": -122.69644484256082, + "lon": -122.69644484256081, "relativeDirection": "DEPART", "stayOn": false, "streetName": "Northwest Northrup Street", From e53a33344c3655b86e9c7494f9c1a395d7e1221b Mon Sep 17 00:00:00 2001 From: Hannes Junnila Date: Wed, 16 Mar 2022 17:09:39 +0200 Subject: [PATCH 5/8] Remove deprecated flag --- pom.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/pom.xml b/pom.xml index e004f835248..8715a548047 100644 --- a/pom.xml +++ b/pom.xml @@ -234,7 +234,6 @@ @{argLine} -Xmx2G -Dfile.encoding=UTF-8 - --illegal-access=permit --add-opens java.base/java.io=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.lang.module=ALL-UNNAMED From d73d9eb14385b0bce59445bf75c097d5fa0dc87b Mon Sep 17 00:00:00 2001 From: Hannes Junnila Date: Wed, 16 Mar 2022 17:35:51 +0200 Subject: [PATCH 6/8] Update dependencies --- pom.xml | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/pom.xml b/pom.xml index 8715a548047..5de9695f1da 100644 --- a/pom.xml +++ b/pom.xml @@ -25,10 +25,10 @@ 18 26.2 - 2.13.1 + 2.13.2 2.34 - 5.7.2 - 1.7.4 + 5.8.2 + 1.8.3 5.5.2 4.1.74.Final @@ -37,7 +37,7 @@ - + @@ -419,7 +419,7 @@ ch.qos.logback logback-classic - 1.2.10 + 1.2.11 @@ -514,7 +514,7 @@ org.entur netex-java-model - 1.0.11 + 1.0.13 @@ -585,7 +585,7 @@ com.google.guava guava - 31.0.1-jre + 31.1-jre @@ -705,19 +705,19 @@ net.java.dev.jets3t jets3t - 0.8.1 + 0.9.4 org.openstreetmap.osmosis osmosis-osm-binary - 0.47.3 + 0.48.3 com.beust jcommander - 1.78 + 1.82 org.apache.commons @@ -727,7 +727,7 @@ com.graphql-java graphql-java - 17.2 + 17.3 com.graphql-java @@ -737,12 +737,12 @@ org.apache.httpcomponents httpclient - 4.5.5 + 4.5.13 commons-cli commons-cli - 1.4 + 1.5.0 test From 640cf9299a6ede1e914e2ea0d4c4bf6e91c0d764 Mon Sep 17 00:00:00 2001 From: Hannes Junnila Date: Wed, 16 Mar 2022 23:00:32 +0200 Subject: [PATCH 7/8] Bump serialization version --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 5de9695f1da..b22b2573f69 100644 --- a/pom.xml +++ b/pom.xml @@ -22,7 +22,7 @@ - 18 + 19 26.2 2.13.2 From d11eea92f00c3f7ea99f9887d4dff697854dca3d Mon Sep 17 00:00:00 2001 From: Hannes Junnila Date: Thu, 17 Mar 2022 16:43:35 +0200 Subject: [PATCH 8/8] Bump serialization version --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b22b2573f69..a25eaedc8cb 100644 --- a/pom.xml +++ b/pom.xml @@ -22,7 +22,7 @@ - 19 + 20 26.2 2.13.2