Skip to content
Merged
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
40 changes: 5 additions & 35 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
env:
# Default versions for canonical release build
DEFAULT_JAVA_VERSION: '8'
DEFAULT_JRUBY_VERSION: '9.4.15.0' # Should match pom.xml <jruby.compat.version> property (AND a version inside the test matrix)
DEFAULT_JRUBY_VERSION: '10.0.6.0' # Should match pom.xml <jruby.compat.version> property (AND a version inside the test matrix)
DEFAULT_RACK_VERSION: '~> 2.2.0' # Should match Gemfile (AND a version inside the test matrix)

jobs:
Expand All @@ -19,22 +19,9 @@ jobs:

strategy:
matrix:
jruby_version: [ '9.4.15.0', '10.0.6.0', '10.1.0.0' ]
java_version: [ '8', '11', '17', '21', '25' ]
jruby_version: [ '10.0.6.0', '10.1.0.0' ]
java_version: [ '21', '25' ]
rack_version: [ '~> 2.2.0' ]
exclude:
- jruby_version: '10.0.6.0'
java_version: '8' # JRuby 10 requires Java 21
- jruby_version: '10.0.6.0'
java_version: '11' # JRuby 10 requires Java 21
- jruby_version: '10.0.6.0'
java_version: '17' # JRuby 10 requires Java 21
- jruby_version: '10.1.0.0'
java_version: '8' # JRuby 10 requires Java 21
- jruby_version: '10.1.0.0'
java_version: '11' # JRuby 10 requires Java 21
- jruby_version: '10.1.0.0'
java_version: '17' # JRuby 10 requires Java 21
fail-fast: false

steps:
Expand Down Expand Up @@ -65,28 +52,11 @@ jobs:
strategy:
matrix:
appraisal: [
'rails70_rack22',
'rails71_rack22',
'rails72_rack22',
'rails80_rack22',
]
jruby_version: [ '9.4.15.0', '10.0.6.0', '10.1.0.0' ]
java_version: [ '8', '11', '17', '21', '25' ]
exclude:
- jruby_version: '10.0.6.0'
java_version: '8' # JRuby 10 requires Java 21
- jruby_version: '10.0.6.0'
java_version: '11' # JRuby 10 requires Java 21
- jruby_version: '10.0.6.0'
java_version: '17' # JRuby 10 requires Java 21
- jruby_version: '10.1.0.0'
java_version: '8' # JRuby 10 requires Java 21
- jruby_version: '10.1.0.0'
java_version: '11' # JRuby 10 requires Java 21
- jruby_version: '10.1.0.0'
java_version: '17' # JRuby 10 requires Java 21
- appraisal: 'rails80_rack22'
jruby_version: '9.4.15.0' # Rails 8 requires Ruby 3.4 compatibility, which JRuby 9.4 does not support
jruby_version: [ '10.0.6.0', '10.1.0.0' ]
java_version: [ '21', '25' ]
fail-fast: false

env:
Expand Down
2 changes: 0 additions & 2 deletions Appraisals
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ version_spec = ->(prefix, desc) { "~> #{desc.split(prefix).last.insert(1, ".")}.
# Rails version -> rack versions in format
# rails#{MAJOR}#{MINOR} => %w[ rack#{MAJOR}#{MINOR} ]
{
"rails70" => %w[rack22],
"rails71" => %w[rack22],
"rails72" => %w[rack22],
"rails80" => %w[rack22]
}.each do |rails_desc, rack_descs|
Expand Down
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
- Officially support Javax Servlet API 4.0 (JEE 8)

Breaking compatibility changes
- Drop support for JRuby 9.3
- Drop support for Rails < 7.0
- Drop support for JRuby 9.x
- Drop support for Rails < 7.2

Breaking behavioral changes
- Change context listener to throw by default in case of an exception during initialization
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ For more information on Rack, visit http://rack.github.io/.

## Compatibility

| JRuby-Rack Series | Status | Rack | JRuby | Java | Rails | Target Servlet API | Notes |
|----------------------------------------------------------------|---------------|-----------|------------|------|-----------|---------------------|----------------------------------------------------------------|
| **2.0 (_planned_, _unreleased_)** | Dev | 2.2 | 9.4 → 10.1 | 8+ | 7.0 → 8.0 | 5.0+ (Jakarta EE 9) | ❌ Servlet < 5.0 containers will not work |
| **1.3 (master, _unreleased_)** | Dev | 2.2 | 9.4 → 10.1 | 8+ | 7.0 → 8.0 | 4.0 (Java EE 8) | ✅ _Unofficial_: Servlet 2.5 → 3.1 & Rails 6.1 likely working |
| [**1.2**](https://github.com/jruby/jruby-rack/tree/1.2-stable) | Maintained | 2.2 | 9.3 → 10.1 | 8+ | 5.0 → 8.0 | 3.0 (Java EE 6) | ✅ _Unofficial_: Servlet 3.1 → 4.0 also OK with most containers |
| [**1.1**](https://github.com/jruby/jruby-rack/tree/1.1-stable) | EOL @ 2024-05 | 1.x → 2.2 | 1.6 → 9.4 | 6+ | 2.1 → 5.2 | 2.5 (Java EE 5) | ✅ _Unofficial_: Servlet 3.0 → 4.0 also OK with most containers |
| [**1.0**](https://github.com/jruby/jruby-rack/tree/1.0.10) | EOL @ 2011-11 | 0.9 → 1.x | 1.1 → 1.9 | 5+ | 2.1 → 3.x | 2.5 (Java EE 5) | |
| JRuby-Rack Series | Status | Rack | JRuby | Java | Rails | Target Servlet API | Notes |
|----------------------------------------------------------------|---------------|-----------|-------------|------|-----------|---------------------|----------------------------------------------------------------|
| **2.0 (_planned_, _unreleased_)** | Dev | 2.2 | 10.0 → 10.1 | 8+ | 7.2 → 8.0 | 5.0+ (Jakarta EE 9) | ❌ Servlet < 5.0 containers will not work |
| **1.3 (master, _unreleased_)** | Dev | 2.2 | 10.0 → 10.1 | 8+ | 7.2 → 8.0 | 4.0 (Java EE 8) | ✅ _Unofficial_: Servlet 2.5 → 3.1 & Rails 6.1 likely working |
| [**1.2**](https://github.com/jruby/jruby-rack/tree/1.2-stable) | Maintained | 2.2 | 9.3 → 10.1 | 8+ | 5.0 → 8.0 | 3.0 (Java EE 6) | ✅ _Unofficial_: Servlet 3.1 → 4.0 also OK with most containers |
| [**1.1**](https://github.com/jruby/jruby-rack/tree/1.1-stable) | EOL @ 2024-05 | 1.x → 2.2 | 1.6 → 9.4 | 6+ | 2.1 → 5.2 | 2.5 (Java EE 5) | ✅ _Unofficial_: Servlet 3.0 → 4.0 also OK with most containers |
| [**1.0**](https://github.com/jruby/jruby-rack/tree/1.0.10) | EOL @ 2011-11 | 0.9 → 1.x | 1.1 → 1.9 | 5+ | 2.1 → 3.x | 2.5 (Java EE 5) | |

## Getting Started

Expand Down
7 changes: 5 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ directory 'target/test-classes'

desc "Compile test classes"
task(:test_prepare => ['target/classes', 'target/test-classes']) do
sh "./mvnw -ntp -Dstyle.color=always test-compile"
# This has to be jruby-complete when running with bundler-maven-plugin since it has special logic to
# exclude jruby-complete - otherwise it conflicts with the bootclasspath if using different
# "target compile version" to "runtime version"
sh "./mvnw -ntp -Dstyle.color=always -Djruby.compat.artifact=jruby-complete test-compile"
end

desc "Unpack the rack gem"
Expand Down Expand Up @@ -175,7 +178,7 @@ task :gem => [target_jar, target_jruby_rack, target_jruby_rack_version] do
gem.email = ['nick@nicksieger.com']
gem.files = FileList["./**/*"].exclude("*.gem").map{ |f| f.sub(/^\.\//, '') }
gem.homepage = %q{http://jruby.org}
gem.required_ruby_version = '>= 3.1.0' # JRuby >= 9.4
gem.required_ruby_version = '>= 3.4.0' # JRuby >= 10.0
end

require 'rubygems/package'
Expand Down
2 changes: 1 addition & 1 deletion examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This directory includes samples using JRuby-Rack to build Rack web applications
into Java app servers.

- All use [Warbler](https://github.com/jruby/warbler) to do so for easy of packaging.
- Require JRuby `9.4` and a compatible JVM (Java `8` -> `25`).
- Require JRuby `10.0` and a compatible JVM (Java `21` -> `25`).

### Building/running

Expand Down
15 changes: 0 additions & 15 deletions gemfiles/rails61_rack22.gemfile

This file was deleted.

18 changes: 0 additions & 18 deletions gemfiles/rails70_rack22.gemfile

This file was deleted.

18 changes: 0 additions & 18 deletions gemfiles/rails71_rack22.gemfile

This file was deleted.

12 changes: 7 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<!-- Version to target at compile time -->
<jruby.compat.version>9.4.15.0</jruby.compat.version>
<jruby.compat.version>10.0.6.0</jruby.compat.version>
<jruby.compat.artifact>jruby</jruby.compat.artifact>
<!-- Version to execute tests with -->
<jruby.test.version>${jruby.compat.version}</jruby.test.version>

Expand Down Expand Up @@ -80,9 +81,10 @@
<dependencies>
<dependency>
<groupId>org.jruby</groupId>
<!-- This has to be jruby-complete, as bundler-maven-plugin has special logic to exclude jruby-complete - otherwise
it conflicts with the bootclasspath if using different "target compile version" to "runtime version" -->
<artifactId>jruby-complete</artifactId>
<!-- This has to be jruby-complete when running with bundler-maven-plugin since it has special logic to
exclude jruby-complete - otherwise it conflicts with the bootclasspath if using different
"target compile version" to "runtime version" -->
<artifactId>${jruby.compat.artifact}</artifactId>
<version>${jruby.compat.version}</version>
<scope>provided</scope>
</dependency>
Expand Down Expand Up @@ -199,7 +201,7 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.15.0</version>
<configuration>
<release>8</release>
<release>21</release>
<showDeprecation>true</showDeprecation>
<showWarnings>true</showWarnings>
</configuration>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/jruby/rack/AbstractRackDispatcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ protected void handleException(

protected abstract RackApplication getApplication() throws RackException;

protected abstract void afterProcess(RackApplication app) throws IOException;
protected abstract void afterProcess(RackApplication app);

protected abstract void afterException(
RackEnvironment request,
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/jruby/rack/DefaultErrorApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public void respond(RackResponseEnvironment response) {
}

private void log(RackLogger.Level level, String message, Throwable e) {
if ( context != null ) context.log(level, (CharSequence) message, e);
if ( context != null ) context.log(level, message, e);
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,11 @@ public IRubyObject createErrorApplicationObject(final Ruby runtime) {

}
if (errorApp == null) {
errorApp = "require 'jruby/rack/error_app' \n" +
"use JRuby::Rack::ErrorApp::ShowStatus \n" +
"run JRuby::Rack::ErrorApp.new";
errorApp = """
require 'jruby/rack/error_app'
use JRuby::Rack::ErrorApp::ShowStatus
run JRuby::Rack::ErrorApp.new
""";
}
runtime.evalScriptlet("load 'jruby/rack/boot/rack.rb'");
return createRackServletWrapper(runtime, errorApp, errorAppPath);
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/org/jruby/rack/RackDispatcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
* @author nicksieger
*/
public interface RackDispatcher {
void process(RackEnvironment request, RackResponseEnvironment response)
throws ServletException, IOException;
void process(RackEnvironment request, RackResponseEnvironment response) throws IOException;
void destroy();
}
9 changes: 3 additions & 6 deletions src/main/java/org/jruby/rack/RackResponseEnvironment.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,22 +102,19 @@ public interface RackResponseEnvironment {
/**
* Send a simple error page response (based on the status code).
* @param code the (HTTP) status code
* @throws IOException if there's an IO exception
*/
void sendError(int code) throws IOException ;
void sendError(int code) throws IOException;

/**
* @see javax.servlet.ServletResponse#getOutputStream()
* @return the output stream
* @throws IOException if there's an IO exception
*/
OutputStream getOutputStream() throws IOException ;
OutputStream getOutputStream() throws IOException;

/**
* @see javax.servlet.ServletResponse#getWriter()
* @return the writer
* @throws IOException if there's an IO exception
*/
PrintWriter getWriter() throws IOException ;
PrintWriter getWriter() throws IOException;

}
19 changes: 6 additions & 13 deletions src/main/java/org/jruby/rack/UnmappedRackFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import java.util.stream.Collectors;
import javax.servlet.FilterChain;
Expand Down Expand Up @@ -46,18 +45,12 @@ public class UnmappedRackFilter extends AbstractFilter {

private boolean responseHandledByDefault = true;

private static final Collection<Integer> RESPONSE_NOT_HANDLED_STATUSES;
static {
final Set<Integer> statuses = new HashSet<>(8, 1);
statuses.add(404);
// 403 due containers not supporting PUT/DELETE correctly (Tomcat 6)
statuses.add(403);
// 405 returned by Jetty 7/8 on PUT/DELETE requests by default
statuses.add(405);
// 501 is returned for non standard http verbs like PATCH
statuses.add(501);
RESPONSE_NOT_HANDLED_STATUSES = Collections.unmodifiableSet(statuses);
}
private static final Collection<Integer> RESPONSE_NOT_HANDLED_STATUSES = Set.of(
404,
403, // 403 due to containers not supporting PUT/DELETE correctly (Tomcat 6)
405, // 405 returned by Jetty 7/8 on PUT/DELETE requests by default
501 // 501 is returned for non-standard http verbs like PATCH
);

private Collection<Integer> responseNotHandledStatuses = RESPONSE_NOT_HANDLED_STATUSES;
private RackContext context;
Expand Down
11 changes: 7 additions & 4 deletions src/main/java/org/jruby/rack/embed/Dispatcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import java.io.IOException;

import org.jruby.Ruby;
import org.jruby.api.Access;
import org.jruby.javasupport.JavaUtil;
import org.jruby.rack.AbstractRackDispatcher;
import org.jruby.rack.DefaultRackApplication;
Expand All @@ -18,6 +19,7 @@
import org.jruby.rack.RackEnvironment;
import org.jruby.rack.RackInitializationException;
import org.jruby.rack.RackResponseEnvironment;
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.builtin.IRubyObject;

/**
Expand All @@ -40,10 +42,11 @@ private void initialize() {
if (context instanceof Context) {
((Context) context).getConfig().doInitialize(runtime);
}
IRubyObject rubyContext = JavaUtil.convertJavaToRuby(runtime, context);
IRubyObject rackModule = runtime.getModule("JRuby").getConstantAt("Rack");
ThreadContext currentContext = runtime.getCurrentContext();
// `JRuby::Rack.context = context`
rackModule.callMethod(runtime.getCurrentContext(), "context=", rubyContext);
Access.getModule(currentContext, "JRuby")
.getConstantAt(currentContext, "Rack")
.callMethod(currentContext, "context=", JavaUtil.convertJavaToRuby(runtime, context));
}

@Override
Expand All @@ -70,7 +73,7 @@ protected void afterException(
}

@Override
protected void afterProcess(RackApplication app) throws IOException {
protected void afterProcess(RackApplication app) {
// NOOP
}

Expand Down
Loading