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

[stapler#114] Update to Servlet API 3.1.0 #131

Merged
merged 3 commits into from
Oct 10, 2017

Conversation

jtnord
Copy link
Member

@jtnord jtnord commented Sep 20, 2017

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

  • updated API to compiled against Java Servlet API 3.1.0, JSP API 2.3.0 and JSTL API 1.2.1
  • This required a API signature change of org.kohsuke.stapler.compression.FilterServletOutputStream.
    • It is recommended that users of this class do not upgrade but replace the implementation as this call may be removed in a future version.

@reviewbybees

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>
Copy link
Member Author

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

Copy link
Member

Choose a reason for hiding this comment

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

works for us

Copy link
Member

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 ;-).

Copy link
Member Author

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

Copy link
Member

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>
Copy link
Member Author

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.

@ghost
Copy link

ghost commented Sep 20, 2017

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>
Copy link
Member Author

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()));
Copy link
Member Author

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

Copy link
Member Author

@jtnord jtnord Sep 22, 2017

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} */
Copy link
Member Author

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);
Copy link
Member Author

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) {
Copy link
Member Author

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

Copy link
Member Author

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.

@jglick jglick self-requested a review September 21, 2017 15:22
jtnord added a commit to jtnord/jenkins that referenced this pull request Sep 22, 2017
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)
Copy link
Member

@oleg-nenashev oleg-nenashev left a 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>
Copy link
Member

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>
Copy link
Member

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

Copy link
Member

@olamy olamy Sep 24, 2017

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.

Copy link
Member

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.

@jtnord
Copy link
Member Author

jtnord commented Sep 25, 2017

Have you checked compatibility of other projects within the Stapler organization? Maybe they require update before merging

@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 mvn jetty:run and verified it started up and returned information for various pages)

@oleg-nenashev
Copy link
Member

@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.

@jtnord
Copy link
Member Author

jtnord commented Sep 25, 2017

@oleg-nenashev updated the PR description to add a proposed change-log

Copy link
Member

@oleg-nenashev oleg-nenashev left a 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>
Copy link
Member

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>
Copy link
Member

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>
Copy link
Member

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.

@jglick jglick merged commit dc2afaa into jenkinsci:master Oct 10, 2017
@jtnord jtnord deleted the servlet_3.x branch October 10, 2017 18:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants