Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to Java 17 and Kryo 5 #3994

Merged
merged 9 commits into from
Mar 17, 2022
Merged

Conversation

hannesj
Copy link
Contributor

@hannesj hannesj commented Mar 16, 2022

Summary

Update to Java 17. I needed to update a couple of libraries, in order not to have compering files of some of the dependencies.

Changelog

The changelog file
is generated from the pull-request title, make sure the title describe the feature or issue fixed.
To exclude the PR from the changelog add [changelog skip] in the title.

@hannesj hannesj added this to the 2.2 milestone Mar 16, 2022
@hannesj hannesj requested a review from a team as a code owner March 16, 2022 14:20
*
* @author <a href="mailto:[email protected]">Martin Grotzke</a>
*/
public class UnmodifiableCollectionsSerializer extends Serializer<Object> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can these be remove once we move to Kryo 5?

Copy link
Contributor Author

@hannesj hannesj Mar 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can be removed when issue magro/kryo-serializers#131 is fixed. The PR contains an update to Kryo 5

@hannesj hannesj changed the title Update to Java 17 Update to Java 17 and Kryo 5 Mar 16, 2022
@t2gran
Copy link
Member

t2gran commented Mar 16, 2022

This looks great. I only had one question, se above.

@@ -52,44 +48,28 @@ 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());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't Kryo 5 have built-in support for List.of()? https://github.com/EsotericSoftware/kryo/blob/master/src/com/esotericsoftware/kryo/serializers/ImmutableCollectionsSerializers.java

Or are they broken in the same was as the map one?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, they will return a wrong type when serializing an empty Set/List/Map, thus failing the tests which compare the loaded graph. I'll create an issue in kryo about that

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, thanks for the explanation. Can you cc me when you create the ticket?

t2gran
t2gran previously approved these changes Mar 16, 2022
@abyrd
Copy link
Member

abyrd commented Mar 17, 2022

Is this intended to be merged into dev-2.x before or after the release? I ask because there's already a 2.1-rc branch and this PR seems like a major change to introduce immediately before a release. Actually I may be misinterpreting the branching strategy because it's different than what we've used in the past. It looks like development is continuing on dev-2.x and changes intended for the release are being cherry-picked over to 2.1-rc.

@hannesj
Copy link
Contributor Author

hannesj commented Mar 17, 2022

This is intended for 2.2, so after the release has been cut

@t2gran
Copy link
Member

t2gran commented Mar 17, 2022

@abyrd I already updated the version number in dev-2.x to 2.2.0-SNAPSHOT. There is a stream of PRs constantly beeing merged and I did not want everyone to change their habit of merging into dev-2.x, so we branched of 2.1-rc at the point we thought was the best place, and then we have cherry-picked a few PRs/commits from dev-2.x after that. I plan to merge the master branch back into dev-2.x when the release is done, so we get all change (also the one done locally in 2.1-rc) in the dev-2.1. It is a bit messy - for me - but cleaner for every one else.

@hannesj hannesj merged commit a8287d3 into opentripplanner:dev-2.x Mar 17, 2022
@hannesj hannesj deleted the otp2_java17 branch March 17, 2022 15:59
t2gran pushed a commit that referenced this pull request Mar 17, 2022
@theigl
Copy link

theigl commented Apr 29, 2023

Hi @hannesj. I'm the maintainer of Kryo and just stumbled across this issue. Are you sure that the immutable collections serializers really return the wrong type at times? I just wrote a a test-case that asserts on the result type of the collection and it passes for all sizes.

@leonardehrenfried
Copy link
Member

Hi @theigl, Hannes isn't contributing a lot anymore.

However, I can try removing our custom serializers and run the test suite again. Maybe these things have been fixed in the meantime.

Thanks for chiming in!

@theigl
Copy link

theigl commented Apr 29, 2023

@leonardehrenfried: Thanks, that would be great. I'd really like to know if there is some hidden bug in those serializers that I'm currently not aware of.

@leonardehrenfried
Copy link
Member

So I just tried it by removing our custom serializers and using the built-in Kyro ones: leonardehrenfried@591a54d

(Is this setup correct?)

Unfortunately, after this change our test reports that we expect at SetN but we receive a HashSet instead.

Classes are not the same: SetN vs HashSet
Comparison stack (outermost first):
    class org.opentripplanner.routing.graph.Graph
    private final java.util.Map org.opentripplanner.routing.graph.Graph.vertices
    class java.util.concurrent.ConcurrentHashMap
    EN:NSR:Quay:122003
    class org.opentripplanner.street.model.vertex.TransitStopVertex
    private final org.opentripplanner.transit.model.site.RegularStop org.opentripplanner.street.model.vertex.TransitStopVertex.stop
    class org.opentripplanner.transit.model.site.RegularStop
    private final java.util.Set org.opentripplanner.transit.model.site.RegularStop.fareZones

Something is amiss here. It could very well be that our setup is wrong.

@leonardehrenfried
Copy link
Member

I wrote some more tests and I can confirm that with plain Kryo the type is correctly deserialized to SetN not HashMap. Presumably something is wrong with our setup.

Can you spot an error in our KryoBuilder? https://github.com/opentripplanner/OpenTripPlanner/blob/dev-2.x/src/main/java/org/opentripplanner/routing/graph/kryosupport/KryoBuilder.java

@theigl
Copy link

theigl commented Apr 29, 2023

Everything looks alright in your builder. I'll try to get to the bottom of this next week. Your branch should be enough for me to write a reproducer.

Thanks!

@leonardehrenfried
Copy link
Member

Great. If you want to run the test yourself it's called GraphSerializationTest.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants