Skip to content

Conversation

@pjfanning
Copy link
Contributor

Pull Request Checklist

Helpful things

Fixes

Fixes #xxxx

Purpose

To check on whether Play builds cleanly with Pekko 1.1.0-M1

What does this PR do?

Background Context

Why did you take this approach?

References

Are there any relevant issues / PRs / mailing lists discussions?

@pjfanning
Copy link
Contributor Author

Issues in these tests.

[error] 	play.api.libs.ws.ahc.AhcWSSpec
[error] 	play.api.data.FormUtilsSpec
[error] 	play.it.libs.PekkoHttpJavaWSSpec
[error] 	play.it.http.parsing.MultipartFormDataParserSpec
[error] 	play.it.libs.PekkoHttpScalaWSSpec
[error] 	play.it.http.parsing.JacksonJsonBodyParserSpec
[error] 	play.it.action.FormActionSpec

@mkurz
Copy link
Member

mkurz commented May 30, 2024

Thanks, this will be definitely looked at 👍
(I already knew that you upgraded jackson and that is causing problems in Play, the other stuff I am not sure yet)

@pjfanning
Copy link
Contributor Author

pjfanning commented May 30, 2024

I had a look at one test. play.api.libs.ws.ahc.AhcWSSpec

The test case that fails involves using ahc-client to send a multipart message based on 2 sources (representing a data part and a file part). The server side receives the request but the file part parsed data is incomplete. It seems like the ahc client sends the right request data but it's possible that there could be boundary or whitespace issues that prevent the multipart parser from handling the request properly.

@gwak
Copy link
Contributor

gwak commented Jul 7, 2024

I had a look at one test. play.api.libs.ws.ahc.AhcWSSpec

The test case that fails involves using ahc-client to send a multipart message based on 2 sources (representing a data part and a file part). The server side receives the request but the file part parsed data is incomplete. It seems like the ahc client sends the right request data but it's possible that there could be boundary or whitespace issues that prevent the multipart parser from handling the request properly.

From what I understand from the Pekko migration guide, we now need to specify the Pekko stream supervision strategy explicitly when using the splitWhen function.

the following code:

.splitWhen(_.isLeft)
.prefixAndTail(1)

should now be:

.splitWhen(_.isLeft)
.withAttributes(ActorAttributes.supervisionStrategy(Supervision.resumingDecider))
.prefixAndTail(1)

@gwak
Copy link
Contributor

gwak commented Jul 7, 2024

@pjfanning There's another occurence of that function here:

@pjfanning pjfanning marked this pull request as draft July 7, 2024 21:33
@pjfanning
Copy link
Contributor Author

@gwak @mkurz I'm not sure if #12793 has helped. The tests still seem broken. #12793 is probably ok to keep but there might be more to the pekko 1.1 issues than that.

@gwak
Copy link
Contributor

gwak commented Jul 9, 2024

@gwak @mkurz I'm not sure if #12793 has helped. The tests still seem broken. #12793 is probably ok to keep but there might be more to the pekko 1.1 issues than that.

Hi @pjfanning I just had a look into this and tested with the 1.1.x Pekko release. This is what I tried but did not pass the MultiFormDataParserSpec:

.splitWhen(_.isLeft)
.withAttributes(ActorAttributes.supervisionStrategy(Supervision.resumingDecider))
.prefixAndTail(1)

But when using the deprecated SubstreamCancelStrategy it works fine:

.splitWhen(SubstreamCancelStrategy.drain)(_.isLeft)

So it seems that either the migration guide does not fully explain how to get the old behaviour back or there're still unresolved bugs in Pekko 1.1 ?

@mkurz Maybe we should just use the "deprecated" way of setting the cancel strategy for now until it's resolved in Pekko ?

.splitWhen(SubstreamCancelStrategy.drain)(_.isLeft)

@pjfanning
Copy link
Contributor Author

@gwak @mdedetrich b447af5 fixed a lot of tests. There are still some other failures but I think at least one of them relates to upgrading Jackson (so unrelated to the internal Pekko changes).

@mkurz
Copy link
Member

mkurz commented Jul 9, 2024

@gwak @mdedetrich b447af5 fixed a lot of tests. There are still some other failures but I think at least one of them relates to upgrading Jackson (so unrelated to the internal Pekko changes).

yes the failing tests having nothing to do with pekko anymore, they are all about the jackson upgrade.

@mkurz

This comment was marked as resolved.

@mergify

This comment was marked as resolved.

@pjfanning
Copy link
Contributor Author

pjfanning commented Sep 4, 2024

Pekko 1.1.0 is out. Pekko HTTP 1.1.0 is not yet released but could possibly be released within a couple of weeks.

The main thing blocking this is the fact that Play does not support the recent versions of Jackson - and Pekko 1.1.0 uses Jackson 2.17.

[error] 	play.api.data.FormUtilsSpec
[error] 	play.it.http.parsing.JacksonJsonBodyParserSpec

@pjfanning pjfanning changed the title test with Pekko 1.1 milestone releases test with Pekko 1.1 releases Jan 5, 2025
@mkurz mkurz mentioned this pull request Mar 17, 2025
6 tasks
@pjfanning pjfanning force-pushed the pekko-1.1 branch 2 times, most recently from 1f651a9 to a9db673 Compare June 1, 2025 17:54
@pjfanning
Copy link
Contributor Author

@mkurz this PR is a bit stale but it has a few elements that might be useful to work on after upgraded play-json is released

  • there is some Jackson code in this repo too and it needs changing to fix test issues
    • core/play/src/main/java/play/libs/Json.java - this PR sets the StreamReadConstraints for that class to be max values but it may make sense to make it configurable too
  • there is a Pekko enhancements for ByteString that has a more performant way to get an InputStream (this PR has the changes for Play to uptake that)

@mkurz
Copy link
Member

mkurz commented Jul 9, 2025

but it may make sense to make it configurable too

If you want to add that to this PR that would be great (if you have the resources to do so)

@mkurz mkurz merged commit 523a401 into playframework:main Nov 10, 2025
29 checks passed
@mkurz
Copy link
Member

mkurz commented Nov 10, 2025

Finally. I feel very comfortable merging this PR now - specially because of the scripted test I added (plus I digged into this and play-ws, play-json and Jackson code very intensely).

I reverted some of the ideas from @pjfanning regarding on how to configure the objectmapper via hocon, most importantly because ConfigFactory.load was used to load a config - which in Play is not correct, because you always should get the config from a running Play application (which can build the config in who knows which way).
But even more important, before this PR, we had multiple objectmappers getting created - some of them hardcoded, totally unable to configure. With this PR (assuming ObjectMapperModule is enabled, which is the default anyway), we just have one single ObjectMapper instance across Play, play-json and play-ws anymore.
And this single ObjectMapper instance gets supplied by Pekko and can therefore be configued via the pekko.serialization.jackson.play {} config key. Plus: A Play app can now also configure the Play JSON standalone specific settings via play.json {} (which when using Play JSON standalone can only be set via system properties).

To make sure everything works as supposed to, the scripted test nails down the jackson config in various scenarios.
Another good thing about this scripted test is we now see on each jackson version bump which Jackson configs changed, got added and/or removed. To be honest because of that I feel much more comfortable now to upgrade (minor 2.x) Jackson even in a Play patch release (until now I was worried something might break, because Jackson is kind of a black whole for me). Also I think it will help us when upgrading to Jackson 3 one day.

I hope with this refactoring we can close the Jackson chapter for a while now (to be honest it seems it was a bit a messy before, most likely because play-json and play-ws was extraced from Play and were cooking their own soup).

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants