Skip to content

[v1.3.x] Drop JRuby 9.3 testing, bumping to Java 11 minimum with Servlet 3.1 and 4.0 compilation compatibility #286

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

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 6 additions & 18 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:

env:
# Default versions for canonical release build
DEFAULT_JAVA_VERSION: '8'
DEFAULT_JAVA_VERSION: '11'
DEFAULT_JRUBY_VERSION: '9.4.12.1' # Should match pom.xml <jruby.version> property (AND a version inside the test matrix)

jobs:
Expand All @@ -18,11 +18,9 @@ jobs:

strategy:
matrix:
jruby_version: [ '9.3.15.0', '9.4.12.1', '10.0.0.1' ]
java_version: [ '8', '11', '17', '21' ]
jruby_version: [ '9.4.12.1', '10.0.0.1' ]
java_version: [ '11', '17', '21' ]
exclude:
- jruby_version: '10.0.0.1'
java_version: '8' # JRuby 10 requires Java 21
- jruby_version: '10.0.0.1'
java_version: '11' # JRuby 10 requires Java 21
- jruby_version: '10.0.0.1'
Expand Down Expand Up @@ -54,22 +52,12 @@ jobs:

strategy:
matrix:
jruby_version: [ '9.3.15.0', '9.4.12.1', '10.0.0.1' ]
java_version: [ '8', '11', '17', '21' ]
jruby_version: [ '9.4.12.1', '10.0.0.1' ]
java_version: [ '11', '17', '21' ]
appraisal: [ 'rails50', 'rails52', 'rails60', 'rails61', 'rails70', 'rails71', 'rails72', 'rails80' ]
exclude:
- jruby_version: '9.3.15.0'
appraisal: 'rails70' # Requires Ruby 2.7 compatibility, which JRuby 9.3 does not support
- jruby_version: '9.3.15.0'
appraisal: 'rails71' # Requires Ruby 2.7 compatibility, which JRuby 9.3 does not support
- jruby_version: '9.3.15.0'
appraisal: 'rails72' # Requires Ruby 3.1 compatibility, which JRuby 9.3 does not support
- jruby_version: '9.3.15.0'
appraisal: 'rails80' # Requires Ruby 3.4 compatibility, which JRuby 9.3 does not support
- jruby_version: '9.4.12.1'
appraisal: 'rails80' # Requires Ruby 3.4 compatibility, which JRuby 9.4 does not support
- jruby_version: '10.0.0.1'
java_version: '8' # JRuby 10 requires Java 21
- jruby_version: '10.0.0.1'
java_version: '11' # JRuby 10 requires Java 21
- jruby_version: '10.0.0.1'
Expand All @@ -95,7 +83,7 @@ jobs:
with:
ruby-version: jruby-${{ matrix.jruby_version }}
bundler-cache: 'false' # Need to install later so we can vary from Gemfile.lock as required for JRuby version compatibility
bundler: ${{ startsWith(matrix.jruby_version, '9.3') && '2.3.27' || 'Gemfile.lock' }}
bundler: 'Gemfile.lock'

- name: Run appraisal for ${{ matrix.appraisal }}
run: bundle install && bundle exec rake spec
Expand Down
1 change: 0 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ GEM
thor (1.3.2)

PLATFORMS
universal-java-1.8
universal-java-11
universal-java-17
universal-java-21
Expand Down
3 changes: 3 additions & 0 deletions History.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
- Adds basic compatibility with JRuby 10.0
- Drop unnecessary jruby.compat.version and RackConfig.getCompatVersion() API
- Drop JMS support
- Drop support for JRuby 9.3
- Require Java 11 or later
- Support Jakarta Servlet API 4.0 (JEE 8)
- update (bundled) rack to 2.2.16

## 1.2.4 (UNRELEASED)
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ current stable 1.1.x releases.**
## Compatibility

JRuby-Rack 1.3.x
- aims to be compatible with JRuby 9.3 -> 10.0 and their supported JDK versions
- supports any container compatible with Java Servlet 3.0 API
- aims to be compatible with JRuby 9.4 -> 10.0 and Java 11+
- supports any container compatible with Java Servlet 4.0 API

JRuby-Rack 1.2.x
- compatible with JRuby 9.3 -> 9.4 and their supported JDK versions
Expand Down
1 change: 0 additions & 1 deletion gemfiles/rails50.gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ GEM
websocket-extensions (0.1.5)

PLATFORMS
universal-java-1.8
universal-java-11
universal-java-17
universal-java-21
Expand Down
1 change: 0 additions & 1 deletion gemfiles/rails52.gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ GEM
websocket-extensions (0.1.5)

PLATFORMS
universal-java-1.8
universal-java-11
universal-java-17
universal-java-21
Expand Down
1 change: 0 additions & 1 deletion gemfiles/rails60.gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ GEM
zeitwerk (2.7.2)

PLATFORMS
universal-java-1.8
universal-java-11
universal-java-17
universal-java-21
Expand Down
1 change: 0 additions & 1 deletion gemfiles/rails61.gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ GEM
zeitwerk (2.7.2)

PLATFORMS
universal-java-1.8
universal-java-11
universal-java-17
universal-java-21
Expand Down
1 change: 0 additions & 1 deletion gemfiles/rails70.gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ GEM
zeitwerk (2.7.2)

PLATFORMS
universal-java-1.8
universal-java-11
universal-java-17
universal-java-21
Expand Down
1 change: 0 additions & 1 deletion gemfiles/rails71.gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,6 @@ GEM
zeitwerk (2.7.2)

PLATFORMS
universal-java-1.8
universal-java-11
universal-java-17
universal-java-21
Expand Down
1 change: 0 additions & 1 deletion gemfiles/rails72.gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,6 @@ GEM
zeitwerk (2.7.2)

PLATFORMS
universal-java-1.8
universal-java-11
universal-java-17
universal-java-21
Expand Down
12 changes: 6 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<jruby.maven.plugins.version>3.0.5</jruby.maven.plugins.version>
<gem.home>${project.build.directory}/rubygems</gem.home>
<slf4j.version>2.0.17</slf4j.version>
<spring.version>4.3.30.RELEASE</spring.version>
<spring.version>5.3.39</spring.version>
</properties>

<issueManagement>
Expand Down Expand Up @@ -99,9 +99,9 @@
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
<version>4.0.4</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -199,8 +199,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.14.0</version>
<configuration>
<source>8</source>
<target>8</target>
<source>11</source>
<target>11</target>
<showDeprecation>true</showDeprecation>
<showWarnings>true</showWarnings>
</configuration>
Expand Down
64 changes: 52 additions & 12 deletions src/main/java/org/jruby/rack/servlet/DefaultServletRackContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -270,57 +270,97 @@ public void declareRoles(String... roleNames) {
context.declareRoles(roleNames);
}

@Override
public String getVirtualServerName() {
return context.getVirtualServerName();
}

@Override
public int getSessionTimeout() {
return context.getSessionTimeout();
}

@Override
public void setSessionTimeout(int sessionTimeout) {
context.setSessionTimeout(sessionTimeout);
}

@Override
public String getRequestCharacterEncoding() {
return context.getRequestCharacterEncoding();
}

@Override
public void setRequestCharacterEncoding(String encoding) {
context.setRequestCharacterEncoding(encoding);
}

@Override
public String getResponseCharacterEncoding() {
return context.getResponseCharacterEncoding();
}

@Override
public void setResponseCharacterEncoding(String encoding) {
context.setResponseCharacterEncoding(encoding);
}

@Override
public <T extends Servlet> T createServlet(Class<T> type) throws ServletException {
return context.createServlet(type);
}

@Override // 3.0 in method signature
@Override
public ServletRegistration.Dynamic addServlet(String servletName, String className) throws IllegalArgumentException, IllegalStateException {
return context.addServlet(servletName, className);
}

@Override // 3.0 in method signature
@Override
public ServletRegistration.Dynamic addServlet(String servletName, Servlet servlet) throws IllegalArgumentException, IllegalStateException {
return context.addServlet(servletName, servlet);
}

@Override // 3.0 in method signature
@Override
public ServletRegistration.Dynamic addServlet(String servletName, Class<? extends Servlet> servletClass) throws IllegalArgumentException, IllegalStateException {
return context.addServlet(servletName, servletClass);
}

@Override // 3.0 in method signature
@Override
public ServletRegistration.Dynamic addJspFile(String servletName, String jspFile) {
return context.addJspFile(servletName, jspFile);
}

@Override
public ServletRegistration getServletRegistration(String servletName) {
return context.getServletRegistration(servletName);
}

@Override // 3.0 in method signature
@Override
public Map<String, ? extends ServletRegistration> getServletRegistrations() {
return context.getServletRegistrations();
}

@Override // 3.0 in method signature
@Override
public <T extends Filter> T createFilter(Class<T> type) throws ServletException {
return context.createFilter(type);
}

@Override // 3.0 in method signature
@Override
public FilterRegistration.Dynamic addFilter(String filterName, String className) throws IllegalArgumentException, IllegalStateException {
return context.addFilter(filterName, className);
}

@Override // 3.0 in method signature
@Override
public FilterRegistration.Dynamic addFilter(String filterName, Filter filter) throws IllegalArgumentException, IllegalStateException {
return context.addFilter(filterName, filter);
}

@Override // 3.0 in method signature
@Override
public FilterRegistration.Dynamic addFilter(String filterName, Class<? extends Filter> filterClass) throws IllegalArgumentException, IllegalStateException {
return context.addFilter(filterName, filterClass);
}

@Override // 3.0 in method signature
@Override
public FilterRegistration getFilterRegistration(String filterName) {
return context.getFilterRegistration(filterName);
}
Expand Down Expand Up @@ -350,7 +390,7 @@ public <T extends EventListener> T createListener(Class<T> listenerClass) throws
return context.createListener(listenerClass);
}

@Override // 3.0 in method signature
@Override
public SessionCookieConfig getSessionCookieConfig() {
return context.getSessionCookieConfig();
}
Expand All @@ -370,7 +410,7 @@ public Set<SessionTrackingMode> getEffectiveSessionTrackingModes() {
return context.getEffectiveSessionTrackingModes();
}

@Override // 3.0 in method signature
@Override
public JspConfigDescriptor getJspConfigDescriptor() {
return context.getJspConfigDescriptor();
}
Expand Down
12 changes: 11 additions & 1 deletion src/main/java/org/jruby/rack/servlet/ResponseCapture.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.util.Set;

import javax.servlet.ServletOutputStream;
import javax.servlet.WriteListener;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpServletResponseWrapper;
Expand Down Expand Up @@ -166,7 +167,16 @@ public ServletOutputStream getOutputStream() throws IOException {
// backwards compatibility with isError() :
return new ServletOutputStream() {
@Override
public void write(int b) throws IOException {
public boolean isReady() {
return false;
}

@Override
public void setWriteListener(WriteListener writeListener) {
}

@Override
public void write(int b) {
// swallow output, because we're going to discard it
}
};
Expand Down
16 changes: 15 additions & 1 deletion src/main/java/org/jruby/rack/servlet/RewindableInputStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import java.io.RandomAccessFile;
import java.nio.ByteBuffer;

import javax.servlet.ReadListener;
import javax.servlet.ServletInputStream;

/**
Expand Down Expand Up @@ -401,5 +402,18 @@ public int getCurrentBufferSize() {
public int getMaximumBufferSize() {
return bufferMax;
}


@Override
public boolean isFinished() {
return buffer != null;
}

@Override
public boolean isReady() {
return buffer != null;
}

@Override // 4.0 in method signature
public void setReadListener(ReadListener readListener) {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import javax.servlet.ServletOutputStream;
import javax.servlet.ServletResponse;
import javax.servlet.WriteListener;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpServletResponseWrapper;

Expand Down Expand Up @@ -158,7 +159,7 @@ private void initializeOutputStream() {
*/
private static class ByteArrayServletOutputStream extends ServletOutputStream {

private final static String LINE_SEPARATOR = System.getProperty("line.separator");
private final static String LINE_SEPARATOR = System.lineSeparator();
private final DataOutputStream dataOutputStream;
private final String charSet;

Expand Down Expand Up @@ -226,6 +227,15 @@ public void println(double d) throws IOException {
println();
}

@Override
public boolean isReady() {
return false;
}

@Override // 4.0 in method signature
public void setWriteListener(WriteListener writeListener) {
}

@Override
public void println(float f) throws IOException {
print(f);
Expand Down