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

GH-4374: Eliminate commons-fileupload dependency #4375

Conversation

erikgb
Copy link
Contributor

@erikgb erikgb commented Jan 18, 2023

GitHub issue resolved: #4374

Briefly describe the changes proposed in this PR:

Removing the dependency to commons-fileupload is a pre-requirement to the javax -> jakarta migration proposed in #3559.

I did the simplest thing to remove the dependency, and IMO the affected code should be refactored more, but I am leaving this to a follow-up PR.


PR Author Checklist (see the contributor guidelines for more details):

  • my pull request is self-contained
  • I've added tests for the changes I made
  • I've applied code formatting (you can use mvn process-resources to format from the command line)
  • I've squashed my commits where necessary
  • every commit message starts with the issue number (GH-xxxx) followed by a meaningful description of the change

@erikgb erikgb changed the title GH-4374 Eliminate commons-fileupload dependencies GH-4374 eliminate commons-fileupload dependencies Jan 18, 2023
@erikgb erikgb force-pushed the GH-4374-eliminate-commons-fileupload-dependencies branch from 1d1bb8d to b4608fe Compare January 18, 2023 22:34
@hmottestad hmottestad changed the base branch from main to develop January 19, 2023 06:51
@abrokenjester abrokenjester linked an issue Jan 19, 2023 that may be closed by this pull request
Copy link
Contributor

@JervenBolleman JervenBolleman left a comment

Choose a reason for hiding this comment

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

I think if the toLowerCase is removed it can be merged. But feel free to convince me that it should stay :)

if (contentType == null) {
return false;
}
if (contentType.toLowerCase(Locale.ENGLISH).startsWith("multipart/")) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the multipart/ must always be lowercase when coming from a header so my gut feeling is that enforcing a lowercase is not needed and may even be a point of failure in the future. e.g. badly configured method filtering on a proxy assuming the lowercase rule being by passed by accepting uppercase headers.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just in-lined the code from commons-fileupload when removing the dependency, to ensure we don't break anything. Is that a good enough argument? IMO better safe than sorry, even if I tend to agree with you. ;-)

@erikgb erikgb force-pushed the GH-4374-eliminate-commons-fileupload-dependencies branch from b4608fe to 4699e98 Compare January 20, 2023 11:31
@abrokenjester
Copy link
Contributor

abrokenjester commented Feb 3, 2023

It took me a while longer than expected to get back to this (the docker ecosystem is even more of a hot mess than I remember from when I last had to reinstall this stuff - took me six attempts to install the correct versions of all the bits).

Unfortunately, when trying to upload an RDF file via the workbench, immediately ran into this:

java.lang.IllegalStateException: Unable to process parts as no multi-part configuration has been provided
	org.apache.catalina.connector.Request.parseParts(Request.java:2905)
	org.apache.catalina.connector.Request.getParts(Request.java:2873)
	org.apache.catalina.connector.RequestFacade.getParts(RequestFacade.java:1086)
	javax.servlet.http.HttpServletRequestWrapper.getParts(HttpServletRequestWrapper.java:349)
	javax.servlet.http.HttpServletRequestWrapper.getParts(HttpServletRequestWrapper.java:349)
	javax.servlet.http.HttpServletRequestWrapper.getParts(HttpServletRequestWrapper.java:349)
	javax.servlet.http.HttpServletRequestWrapper.getParts(HttpServletRequestWrapper.java:349)
	org.eclipse.rdf4j.workbench.util.WorkbenchRequest.getMultipartParameterMap(WorkbenchRequest.java:284)
	org.eclipse.rdf4j.workbench.util.WorkbenchRequest.<init>(WorkbenchRequest.java:74)
	org.eclipse.rdf4j.workbench.base.TransformationServlet.service(TransformationServlet.java:96)
	org.eclipse.rdf4j.workbench.base.AbstractServlet.service(AbstractServlet.java:129)
	org.eclipse.rdf4j.workbench.proxy.ProxyRepositoryServlet.service(ProxyRepositoryServlet.java:100)
	org.eclipse.rdf4j.workbench.proxy.WorkbenchServlet.service(WorkbenchServlet.java:215)
	org.eclipse.rdf4j.workbench.proxy.WorkbenchServlet.handleRequest(WorkbenchServlet.java:137)
	org.eclipse.rdf4j.workbench.proxy.WorkbenchServlet.service(WorkbenchServlet.java:112)
	org.eclipse.rdf4j.workbench.proxy.WorkbenchGateway.service(WorkbenchGateway.java:117)
	org.eclipse.rdf4j.workbench.base.AbstractServlet.service(AbstractServlet.java:129)
	org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
	org.apache.catalina.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:109)
	org.eclipse.rdf4j.workbench.proxy.CacheFilter.doFilter(CacheFilter.java:64)
	org.eclipse.rdf4j.workbench.proxy.CookieCacheControlFilter.doFilter(CookieCacheControlFilter.java:56)

I'll take a look if adding the annotation in AddServlet is enough to fix things.

@abrokenjester
Copy link
Contributor

abrokenjester commented Feb 3, 2023

It does not seem to a case of simply adding this to AddServlet :( I'm afraid you're going to have to tweak/test things a bit more on your end @erikgb .

You can find some instructions on how to build and run a local docker image in docker/README_DEV.md. Or if you prefer not to use docker, you can also run mvn -Pquick clean install from the workbench dir and then manually deploy the created warfile in a local Tomcat installation.

@erikgb
Copy link
Contributor Author

erikgb commented Feb 4, 2023

@abrokenjester No worries! I suspected this, and will take another look. Could you share your test setup, or is it documented somewhere?

@erikgb
Copy link
Contributor Author

erikgb commented Feb 4, 2023

Sorry, I need to read before I write. 😂

@erikgb erikgb force-pushed the GH-4374-eliminate-commons-fileupload-dependencies branch 2 times, most recently from 2e9a29f to 894b01e Compare February 5, 2023 16:08
@erikgb
Copy link
Contributor Author

erikgb commented Feb 5, 2023

@abrokenjester I am having trouble getting this to work in my local environment. The first issue was docker-compse vs. docker compose (the modern variant), but that was easy to fix. I am considering filing a PR to change that. Have you had any discussions about that in the team?

Next issue I am still trying to resolve is that I cannot access the workbench app from my browser. My setup is a bit complex, so I am reaching out to a colleague.

I have now moved the multi-part annotation to all concrete subclasses - since the annotation is not inherited. If you can take another look now at smoke testing, it would be greatly appreciated! I will try to fix my local environment, but I have no idea how the workbench works. So I will probably have a hard time knowing how to test/verify if this is working now.

@abrokenjester
Copy link
Contributor

@erikgb yeah good point, I had logged a ticket for the docker issues (#4399) but I haven't pushed changes through yet. I'll make that a priority because it saves a lot of hassle.

@erikgb erikgb force-pushed the GH-4374-eliminate-commons-fileupload-dependencies branch from 894b01e to c89c620 Compare February 13, 2023 15:44
@erikgb erikgb changed the title GH-4374 eliminate commons-fileupload dependencies GH-4374: eliminate commons-fileupload dependencies Feb 16, 2023
@erikgb erikgb force-pushed the GH-4374-eliminate-commons-fileupload-dependencies branch 2 times, most recently from 9a8b9a7 to c77668b Compare February 20, 2023 09:07
@erikgb erikgb requested review from JervenBolleman and abrokenjester and removed request for JervenBolleman February 20, 2023 09:34
@erikgb erikgb changed the title GH-4374: eliminate commons-fileupload dependencies GH-4374: Eliminate commons-fileupload dependencies Feb 20, 2023
@erikgb erikgb force-pushed the GH-4374-eliminate-commons-fileupload-dependencies branch from c77668b to 8c72872 Compare February 25, 2023 10:15
@erikgb erikgb force-pushed the GH-4374-eliminate-commons-fileupload-dependencies branch from 8c72872 to 19c7f3c Compare February 25, 2023 14:03
@erikgb erikgb changed the title GH-4374: Eliminate commons-fileupload dependencies GH-4374: Eliminate commons-fileupload dependency Feb 25, 2023
@erikgb
Copy link
Contributor Author

erikgb commented Feb 25, 2023

After seeing this comment in WorkbenchGateway:

All requests are serviced by this Servlet, though it usually delegates to other Servlets.

And being able to run the workbench locally after #4447, I think this works now! 😅 It was simpler to change than expected.

Maybe you can take another look @abrokenjester?

Copy link
Contributor

@abrokenjester abrokenjester left a comment

Choose a reason for hiding this comment

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

Tested locally and workbench appears to work fine. Tested file uploads, exports, queries, updates, and repo creation. 👍

@abrokenjester abrokenjester dismissed JervenBolleman’s stale review February 25, 2023 22:15

In discussion current solution was considered acceptable.

@erikgb
Copy link
Contributor Author

erikgb commented Mar 3, 2023

Tested locally and workbench appears to work fine. Tested file uploads, exports, queries, updates, and repo creation. 👍

Thanks for verifying, @abrokenjester! ❤️ Could we get this merged?

@abrokenjester abrokenjester merged commit 0e920e2 into eclipse-rdf4j:develop Mar 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants