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

Fix File handling as a JAX-RS body parameter #35659

Merged
merged 2 commits into from
Jan 4, 2024
Merged

Conversation

geoand
Copy link
Contributor

@geoand geoand commented Aug 31, 2023

No description provided.

@geoand
Copy link
Contributor Author

geoand commented Aug 31, 2023

At the least the first commit should be backported.

@quarkus-bot

This comment has been minimized.

@quarkus-bot

This comment has been minimized.

@geoand
Copy link
Contributor Author

geoand commented Sep 4, 2023

@FroMage can you have a look at this?

@geoand
Copy link
Contributor Author

geoand commented Sep 13, 2023

@FroMage ping :)

@geoand
Copy link
Contributor Author

geoand commented Nov 30, 2023

@FroMage can you have a look at this please?

Copy link

quarkus-bot bot commented Jan 4, 2024

✔️ The latest workflow run for the pull request has completed successfully.

It should be safe to merge provided you have a look at the other checks in the summary.

@FroMage
Copy link
Member

FroMage commented Jan 4, 2024

Ouch, I'm late again. Looking.

Copy link
Member

@FroMage FroMage left a comment

Choose a reason for hiding this comment

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

LGTM except questions to consider. But don't let that prevent you from merging.

@@ -40,4 +42,8 @@ public Boolean call() {
}
});
}

protected String fileSizeAsStr(File file) throws IOException {
return "" + Files.readAllBytes(file.toPath()).length;
Copy link
Member

Choose a reason for hiding this comment

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

🤢

throws IOException, WebApplicationException {
// unfortunately we don't do much here to avoid the file leak
// however this should never be called in a real world scenario
return FileBodyHandler.doRead(httpHeaders, entityStream, Files.createTempFile(PREFIX, SUFFIX).toFile()).toPath();
Copy link
Member

Choose a reason for hiding this comment

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

Is there really no way to obtain the current context in this case? Feels a bit dangerous and optimistic to assume this never gets called. Perhaps we should at least log an INFO message so that people get something in their logs to explain why their /tmp folder would keep growing and crash?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We control the calling of the method, so it should indeed never be called

Copy link
Member

Choose a reason for hiding this comment

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

🤞

@@ -21,8 +21,8 @@
import org.jboss.resteasy.reactive.common.headers.HeaderUtil;

public class FileBodyHandler implements MessageBodyReader<File>, MessageBodyWriter<File> {
Copy link
Member

Choose a reason for hiding this comment

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

Is this even used outside of the Quarkus version, which now overrides it? If not, I wonder if it wouldn't be less complex to ditch the reader overrides build items and pass the proper config and cleaner to the non-quarkus RR, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

IIRC, it was used in some tests in the independent project

Copy link
Member

Choose a reason for hiding this comment

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

🤷

@geoand geoand merged commit 09c7d8a into quarkusio:main Jan 4, 2024
43 checks passed
@geoand geoand deleted the rr-file branch January 4, 2024 14:20
@quarkus-bot quarkus-bot bot added this to the 3.7 - main milestone Jan 4, 2024
@gsmet gsmet modified the milestones: 3.7 - main, 3.6.5 Jan 9, 2024
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.

4 participants