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

Add a RESTEasy Multipart extension #11893

Merged
merged 2 commits into from
Sep 14, 2020
Merged

Conversation

gsmet
Copy link
Member

@gsmet gsmet commented Sep 4, 2020

Fixes #10323 by adding a new quarkus-resteasy-multipart.
Fixes #880

When using the extension, the default charset is UTF-8 instead of US-ASCII as it looks like a much saner default. It's configurable via Quarkus configuration properties.

@boring-cyborg boring-cyborg bot added area/core area/dependencies Pull requests that update a dependency file labels Sep 4, 2020
@gsmet
Copy link
Member Author

gsmet commented Sep 4, 2020

@evialle @ejba I tried to implement an extension to fix #10323 in this PR.

But I can't get the test to pass, even if I'm positive the filter is taken into account.

If someone has any idea of what I'm doing wrong.

/cc @geoand

@geoand
Copy link
Contributor

geoand commented Sep 4, 2020

I'll pass it on to @gastaldi for the time being. Tag me in if needed :)

@gsmet
Copy link
Member Author

gsmet commented Sep 4, 2020

@evialle if you could put together a small reproducer showing that your filter solves the issue, that would be helpful. Maybe I'm missing something obvious.

@gsmet gsmet force-pushed the resteasy-multipart branch from 175d966 to 53dc0c7 Compare September 11, 2020 11:07
@gsmet gsmet marked this pull request as ready for review September 11, 2020 12:29
@gsmet
Copy link
Member Author

gsmet commented Sep 11, 2020

@asoldano could you have a look at the principle of that one? I'm changing the default for input-part default charset in Quarkus as we had a lot of people complaining about it.

In 2020, I think the default should be UTF-8.

@gsmet gsmet force-pushed the resteasy-multipart branch from 53dc0c7 to 75ab3c1 Compare September 11, 2020 13:00
@gsmet
Copy link
Member Author

gsmet commented Sep 11, 2020

@geoand interested in your feedback on this one.

@geoand
Copy link
Contributor

geoand commented Sep 11, 2020

I just have one question:

Would it make sense to not have a separate extension, but simply enable the filter conditionally at build time if the multipart dependency is present?

@gastaldi
Copy link
Contributor

Would it make sense to not have a separate extension, but simply enable the filter conditionally at build time if the multipart dependency is present?

That makes sense, as long as the necessary changes are restricted to just a filter setting 👍

@gsmet
Copy link
Member Author

gsmet commented Sep 11, 2020

It’s a very common usage. To be honest I wanted an extension for that one since a few months.

Having an extension exposes it and I think it’s the right thing to do.

The nice perk is that it won’t break existing applications not using the extension.

@gastaldi
Copy link
Contributor

Funny you mention that, I had the same impression in #879 😉

@gsmet
Copy link
Member Author

gsmet commented Sep 11, 2020

Ah ah good one, you got me here :). I think I totally underestimated back in the time the number of people using multipart.

We have a good reason to do it now so I would say let’s do it.

@geoand
Copy link
Contributor

geoand commented Sep 11, 2020

This time @gastaldi gets to say: "I told you so" 😆

@geoand
Copy link
Contributor

geoand commented Sep 11, 2020

I'm +1 for this

import io.quarkus.runtime.annotations.ConfigPhase;
import io.quarkus.runtime.annotations.ConfigRoot;

@ConfigRoot(name = "resteasy.multipart", phase = ConfigPhase.RUN_TIME)
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this be BUILD_AND_RUN_TIME_FIXED since it is not supposed to change during runtime?

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmmm, isn't the bean instantiated at runtime? So you could change the value with a -D... in another environment for instance.

* Note that the default value is UTF-8 which is different from RESTEasy's default value US-ASCII.
*/
@ConfigItem(defaultValue = "UTF-8")
public Charset defaultCharset;
Copy link
Contributor

Choose a reason for hiding this comment

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

I know strong typing is important but why a java.nio.charset.Charset if you only use the name?

Copy link
Member Author

Choose a reason for hiding this comment

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

Mostly to be consistent with the other places. And this way it gets somehow validated by the converter.

@gastaldi gastaldi linked an issue Sep 11, 2020 that may be closed by this pull request
@gsmet
Copy link
Member Author

gsmet commented Sep 14, 2020

I think this is ready and I answered all questions?

@gastaldi can I get your approval if you're good with it?

Copy link
Contributor

@gastaldi gastaldi left a comment

Choose a reason for hiding this comment

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

LGTM, good job!

@gsmet gsmet merged commit baef5d6 into quarkusio:master Sep 14, 2020
@gsmet
Copy link
Member Author

gsmet commented Sep 14, 2020

Thanks!

@gsmet gsmet modified the milestone: 1.9.0 - master Sep 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/core area/dependencies Pull requests that update a dependency file release/noteworthy-feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

UTF-8 encoding problem with MultiPart/RestEasy Introduce a RESTEasy Multipart extension
3 participants