-
Notifications
You must be signed in to change notification settings - Fork 156
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
[JENKINS-73136] Adapt HTTP Request tests for Jetty 12 (EE 8) #172
[JENKINS-73136] Adapt HTTP Request tests for Jetty 12 (EE 8) #172
Conversation
The existing code doesn't use a static import for `StandardCharsets`, so preserve the existing convention to keep this diff focused on substance rather than unrelated stylistic changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice! I ran this locally and it all works quite nicely. I fixed a handful of trivial bugs and cleaned up the code a little bit. There is just one issue remaining before I am ready to approve this PR.
assertEquals(uploadFile.length(), part.getSize()); | ||
assertEquals(uploadFile.getName(), part.getSubmittedFileName()); | ||
assertEquals(MimeType.APPLICATION_ZIP.getValue(), part.getContentType()); | ||
if (multipartInputStream != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try setting a breakpoint here and running the test suite. In my tests multipartInputStream
is always null, and the code inside the if
statement is never executed. As such, this turns the test into a false negative—the assertions are never executed. Presumably the assertions were executed before, making this a regression.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the catch, yes multipartInputStream
is always null on my side too.
With what @olamy suggested here BorisYaoA#1, it is no more used and it is more clear.
And Just FTR I've run the same test in debug mode on the actual master
branch and multipartInputStream
is always null so it seems that the finally
below isn't doing nothing
http-request-plugin/src/test/java/jenkins/plugins/http_request/Registers.java
Lines 364 to 371 in 018c44c
} finally { | |
String MULTIPART = | |
"org.eclipse.jetty.servlet.MultiPartFile.multiPartInputStream"; | |
MultiPartFormInputStream multipartInputStream = | |
(MultiPartFormInputStream) request.getAttribute(MULTIPART); | |
if (multipartInputStream != null) { | |
multipartInputStream.deleteParts(); | |
} |
assertEquals(content, | ||
IOUtils.toString(modelPart.getInputStream(), StandardCharsets.UTF_8)); | ||
assertEquals(MimeType.APPLICATION_JSON.getValue(), modelPart.getContentType()); | ||
if (multipartInputStream != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto.
…into Adapt_http_request_for_jetty12 # Conflicts: # src/test/java/jenkins/plugins/http_request/HttpRequestTestBase.java
Signed-off-by: Olivier Lamy <[email protected]>
regarding Jetty 12 core handller multipart feel to look at BorisYaoA#1
|
Thank you @olamy, it is what I was missing for handling |
fix Jetty 12 core handler multipart
…into Adapt_http_request_for_jetty12
"If false is returned, then this method must not generate a response, nor complete the callback."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR!
see https://issues.jenkins.io/browse/JENKINS-73136
The goal of this PR is to adapt
http-request-plugin
for jetty 12 (EE8).There was some tests failures with
jenkins.plugins.http_request.HttpRequestStepTest
andjenkins.plugins.http_request.HttpRequestTest
so I had to fix them.The most of the work is about adapting
SimpleHandler
classes to useHandler.Abstract
Testing done
Submitter checklist