-
Notifications
You must be signed in to change notification settings - Fork 104
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
[stapler#114] Update to Servlet API 3.1.0 #131
Conversation
This also updates the JSP api to 2.30 as it is also part of Java EE 7 and so will be found in tandem with the servlet API.
Mainly updates jetty and stapler to versions that use servlet 3.1.0 API
@@ -45,8 +46,8 @@ | |||
<artifactId>maven-compiler-plugin</artifactId> | |||
|
|||
<configuration> | |||
<source>1.5</source> | |||
<target>1.5</target> | |||
<source>1.7</source> |
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.
minimum target of java ee 7
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.
works for us
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.
I think I remember a discussion somewhere: is stapler stil in-use outside Jenkins? If not, and even if so, why not go to Java 8? It's probably time anyway, as now JDK9 just got GA a few days ago, even JDK8 is legacy now ;-).
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.
It is in a few places (2 or 3 iirc) 7 is required for the servlet spec which is the min requirement here
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.
Stapler is on Java 8 already.
@@ -13,24 +13,25 @@ | |||
<dependency> | |||
<groupId>org.kohsuke.stapler</groupId> | |||
<artifactId>stapler-jsp</artifactId> | |||
<version>1.144</version> | |||
<!-- TODO update after releasing --> | |||
<version>1.253-SNAPSHOT</version> |
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.
not part of the build so would need to be fixed later.
This pull request originates from a CloudBees employee. At CloudBees, we require that all pull requests be reviewed by other CloudBees employees before we seek to have the change accepted. If you want to learn more about our process please see this explanation. |
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
<repositories> |
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.
stapler is now on maven central
@@ -305,7 +305,7 @@ public OutputStream getCompressedOutputStream(HttpServletRequest req) throws IOE | |||
// CompressionFilter not available, so do it on our own. | |||
// see CompressionFilter for why this is not desirable | |||
setHeader("Content-Encoding","gzip"); | |||
return recordOutput(new FilterServletOutputStream(new GZIPOutputStream(super.getOutputStream()))); | |||
return recordOutput(new FilterServletOutputStream(new GZIPOutputStream(super.getOutputStream()), super.getOutputStream())); |
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.
this is pretty ugly - there is no need for stapler to do gzip at all - see #130
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.
currently only 2 uses outside of stapler that I found - I have PRs for both, both of which means this can be completely removed in #130
@@ -340,4 +341,46 @@ public void setContentType(String type) { | |||
public void setLocale(Locale loc) { | |||
getWrapped().setLocale(loc); | |||
} | |||
|
|||
/** {@inheritDoc} */ |
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.
new APIs in ServletResponse
@@ -58,7 +58,7 @@ public ServletOutputStream getOutputStream() throws IOException { | |||
public void activate() throws IOException { | |||
if (stream==null) { | |||
super.setHeader("Content-Encoding", "gzip"); | |||
stream = new FilterServletOutputStream(new GZIPOutputStream(super.getOutputStream())); | |||
stream = new FilterServletOutputStream(new GZIPOutputStream(super.getOutputStream()), stream); |
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.
this is pretty ugly - there is no need for stapler to do gzip at all - see #130
* @param out the stream that sits above the realStream, performing some filtering. This must be eventually delegating eventual writes to {@code realStream}. | ||
* @param realStream the actual underlying ServletOutputStream from the container. Used to check the {@link #isReady()} state and to add {@link WriteListener}s. | ||
*/ | ||
public FilterServletOutputStream(OutputStream out, ServletOutputStream realStream) { |
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.
this is pretty ugly - there is no need for stapler to do gzip at all - see #130
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.
The usage of this in Jenkins core shows that this is not appropriate there.
I found 2 external uses of this
1 in jenkins core
1 in a propriatary plugin
in both cases it is a mock stream, that does not respond to the client at all and as such has a different use case to this.
Downstream updates from jenkinsci/stapler#131 The stapler API was built using servlet 2.5 and yet Jenkins uses 3.1. This meant some of the code that stapler used was missing new methods that where part of the updated spec and if a plugin happened to call them you would end up with a LinkageError or some other crazyness. This also make Jenkins depend on a dummy version of the old serlet-api maven co-ordinates such that if any plugin gets aa dependency on it transitivly (e.g. Jenkins test harness) they will get a version with no code so the classpath should always be clean (this was more an issue for eclipse than an mvn command)
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.
Generally looks good to me, especially since Jenkins was able to work with Stapler without blowing up.
@jtnord Have you checked compatibility of other projects within the Stapler organization? Maybe they require update before merging
@@ -45,8 +46,8 @@ | |||
<artifactId>maven-compiler-plugin</artifactId> | |||
|
|||
<configuration> | |||
<source>1.5</source> | |||
<target>1.5</target> | |||
<source>1.7</source> |
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.
works for us
|
||
<groupId>org.eclipse.jetty</groupId> | ||
<artifactId>jetty-maven-plugin</artifactId> | ||
<version>9.4.7.v20170914</version> |
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.
CC @olamy just in case he is aware about any issues with that
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.
nope. I cannot see any issue with that.
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.
FWIW we are using 9.4.5.v20170502
in various other places in the Jenkins project.
@oleg-nenashev No, updated this repo and the test project only. I did search for the class that had an API signature change and found only 2 occurences of it - neither of which where in the stapler org. If you are aware of any other tests I should do can you outline them? (I ran the example project |
@jtnord It should be fine. It would be great if you reference the changed methods in the PR description, so that we could mention it in the changelogs and upgrade guidelines if anything goes wrong. |
@oleg-nenashev updated the PR description to add a proposed change-log |
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.
🐝
@@ -45,8 +46,8 @@ | |||
<artifactId>maven-compiler-plugin</artifactId> | |||
|
|||
<configuration> | |||
<source>1.5</source> | |||
<target>1.5</target> | |||
<source>1.7</source> |
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.
Stapler is on Java 8 already.
|
||
<groupId>org.eclipse.jetty</groupId> | ||
<artifactId>jetty-maven-plugin</artifactId> | ||
<version>9.4.7.v20170914</version> |
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.
FWIW we are using 9.4.5.v20170502
in various other places in the Jenkins project.
<artifactId>servlet-api</artifactId> | ||
<version>2.3</version> | ||
<artifactId>javax.servlet-api</artifactId> | ||
<version>3.1.0</version> |
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.
Please use <dependencyManagement>
to avoid repetition.
Update stapler to use Servlet API 3.1.0 (and other servlet APIs coming from Java EE 7)
Fixes #114
Code could be cleaned up further with the inclusion of #130
Proposed Change Log Entry
org.kohsuke.stapler.compression.FilterServletOutputStream
.@reviewbybees