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
22 changes: 20 additions & 2 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,16 @@ jobs:

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

steps:
Expand Down Expand Up @@ -59,16 +66,27 @@ jobs:
'rails70_rack22',
'rails71_rack22',
'rails72_rack22',
'rails80_rack22',
]
jruby_version: [ '9.3.15.0', '9.4.14.0' ]
jruby_version: [ '9.3.15.0', '9.4.14.0', '10.0.5.0' ]
java_version: [ '8', '11', '17', '21', '25' ]
exclude:
- jruby_version: '10.0.5.0'
java_version: '8' # JRuby 10 requires Java 21
- jruby_version: '10.0.5.0'
java_version: '11' # JRuby 10 requires Java 21
- jruby_version: '10.0.5.0'
java_version: '17' # JRuby 10 requires Java 21
- appraisal: 'rails70_rack22' # Requires Ruby 2.7 compatibility, which JRuby 9.3 does not support
jruby_version: '9.3.15.0'
- appraisal: 'rails71_rack22' # Requires Ruby 2.7 compatibility, which JRuby 9.3 does not support
jruby_version: '9.3.15.0'
- appraisal: 'rails72_rack22' # Requires Ruby 3.1 compatibility, which JRuby 9.3 does not support
jruby_version: '9.3.15.0'
- appraisal: 'rails80_rack22' # Requires Ruby 3.4 compatibility, which JRuby 9.3 does not support
jruby_version: '9.3.15.0'
- appraisal: 'rails80_rack22' # Requires Ruby 3.4 compatibility, which JRuby 9.4 does not support
jruby_version: '9.4.14.0'
fail-fast: false

env:
Expand Down
26 changes: 15 additions & 11 deletions Appraisals
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
version_spec = ->(prefix, desc) { "~> #{desc.split(prefix).last.insert(1, ".")}.0" }

# Rails version -> rack versions in format
# rails#{MAJOR}#{MINOR} => %w[ rack#{MAJOR}#{MINOR} ]
# rails#{MAJOR}#{MINOR} => config_obj
{
"rails50" => %w[rack22],
"rails52" => %w[rack22],
"rails60" => %w[rack22],
"rails61" => %w[rack22],
"rails70" => %w[rack22],
"rails71" => %w[rack22],
"rails72" => %w[rack22]
}.each do |rails_desc, rack_descs|
rack_descs.each do |rack_desc|
"rails50" => {racks: %w[rack22], ext_gems: %w[mutex_m bigdecimal base64]},
"rails52" => {racks: %w[rack22], ext_gems: %w[mutex_m bigdecimal]},
"rails60" => {racks: %w[rack22], ext_gems: %w[mutex_m bigdecimal]},
"rails61" => {racks: %w[rack22], ext_gems: %w[mutex_m bigdecimal]},
"rails70" => {racks: %w[rack22]},
"rails71" => {racks: %w[rack22]},
"rails72" => {racks: %w[rack22]},
"rails80" => {racks: %w[rack22]},
}.each do |rails_desc, c|
c[:racks].each do |rack_desc|

appraise "#{rails_desc}_#{rack_desc}" do
group :default do
gem "rack", version_spec.call("rack", rack_desc)
gem "rails", version_spec.call("rails", rails_desc)

c[:ext_gems]&.each do |gem_name|
gem gem_name
end
end
end
end
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## 1.2.7 (UNRELEASED)

- Fix compatibility with JRuby 10.0 and Rails 8.0 (#419)
- Fix ability to include and forward to JSPs under Rails (#370)
- Update (bundled) rack to 2.2.23 (#417)

Expand Down
12 changes: 5 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ For more information on Rack, visit http://rack.github.io/.

## Compatibility

| JRuby-Rack Series | Status | Rack | JRuby | Java | Rails | Target Servlet API | Notes |
|----------------------------------------------------------------|---------------|-----------|-----------|------|-----------|--------------------|----------------------------------------------------------------|
| [**1.2**](https://github.com/jruby/jruby-rack/tree/1.2-stable) | Maintained | 2.2 | 9.3 → 9.4 | 8+ | 5.0 → 7.2 | 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 |
|----------------------------------------------------------------|---------------|-----------|------------|------|-----------|--------------------|----------------------------------------------------------------|
| [**1.2**](https://github.com/jruby/jruby-rack/tree/1.2-stable) | Maintained | 2.2 | 9.3 → 10.0 | 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 Expand Up @@ -209,8 +209,6 @@ as context init parameters in web.xml or as VM-wide system properties.
sub-path of the main servlet context root.
- `gem.path`: Relative path to the bundled gem repository. Defaults to
`/WEB-INF/gems`.
- `jruby.compat.version`: Set to "1.8" or "1.9" to make JRuby run a specific
version of Ruby (same as the --1.8 / --1.9 command line flags).
- `jruby.min.runtimes`: For non-threadsafe Rails applications using a runtime
pool, specify an integer minimum number of runtimes to hold in the pool.
- `jruby.max.runtimes`: For non-threadsafe Rails applications, an integer
Expand Down
3 changes: 3 additions & 0 deletions gemfiles/rails50_rack22.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ gem "rspec", group: :test
group :default do
gem "rack", "~> 2.2.0"
gem "rails", "~> 5.0.0"
gem "mutex_m"
gem "bigdecimal"
gem "base64"
end

group :development do
Expand Down
2 changes: 2 additions & 0 deletions gemfiles/rails52_rack22.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ gem "rspec", group: :test
group :default do
gem "rack", "~> 2.2.0"
gem "rails", "~> 5.2.0"
gem "mutex_m"
gem "bigdecimal"
end

group :development do
Expand Down
2 changes: 2 additions & 0 deletions gemfiles/rails60_rack22.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ gem "rspec", group: :test
group :default do
gem "rack", "~> 2.2.0"
gem "rails", "~> 6.0.0"
gem "mutex_m"
gem "bigdecimal"
end

group :development do
Expand Down
2 changes: 2 additions & 0 deletions gemfiles/rails61_rack22.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ gem "rspec", group: :test
group :default do
gem "rack", "~> 2.2.0"
gem "rails", "~> 6.1.0"
gem "mutex_m"
gem "bigdecimal"
end

group :development do
Expand Down
15 changes: 15 additions & 0 deletions gemfiles/rails80_rack22.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "rake", "~> 13.3", group: :test, require: nil
gem "rspec", group: :test

group :default do
gem "rack", "~> 2.2.0"
gem "rails", "~> 8.0.0"
end

group :development do
gem "appraisal", require: nil
end
Original file line number Diff line number Diff line change
Expand Up @@ -302,10 +302,6 @@ protected RubyInstanceConfig initRuntimeConfig(final RubyInstanceConfig config)
// Process arguments, namely any that might be in RUBYOPT
config.processArguments(rackConfig.getRuntimeArguments());

if ( rackConfig.getCompatVersion() != null ) {
config.setCompatVersion(rackConfig.getCompatVersion());
}

try { // try to set jruby home to jar file path
final URL resource = Ruby.class.getResource("/META-INF/jruby.home");
if ( resource != null && "jar".equals( resource.getProtocol() ) ) {
Expand Down Expand Up @@ -487,7 +483,7 @@ private void captureMessage(final RaiseException re) {
rubyException.callMethod(context, "capture");
rubyException.callMethod(context, "store");
}
catch (Exception e) {
catch (Throwable e) {
Comment thread
chadlwilson marked this conversation as resolved.
rackContext.log(INFO, "failed to capture exception message", e);
// won't be able to capture anything
}
Comment thread
chadlwilson marked this conversation as resolved.
Expand Down
21 changes: 0 additions & 21 deletions src/main/java/org/jruby/rack/DefaultRackConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,12 @@
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.jruby.CompatVersion;
import org.jruby.rack.logging.OutputStreamLogger;
import org.jruby.rack.logging.StandardOutLogger;
import org.jruby.util.SafePropertyAccessor;

import static org.jruby.rack.RackLogger.Level.WARN;

/**
* A base implementation of that retrieves settings from system properties.
*
Expand Down Expand Up @@ -81,23 +77,6 @@ public void setQuiet(boolean quiet) {

@Override
public CompatVersion getCompatVersion() {
final String version = getProperty("jruby.compat.version");
if ( version != null ) {
// we handle 1.8, RUBY1_9, --2.0 1_9 2.1.0.dev etc :
final Pattern pattern = Pattern.compile("([123])[._]([8901234567])");
final Matcher matcher = pattern.matcher(version);
if ( matcher.find() ) {
final String name = "RUBY" +
matcher.group(1) + '_' + matcher.group(2);
try {
return Enum.valueOf(CompatVersion.class, name);
}
catch (IllegalArgumentException e) {
getLogger().log(WARN,
"could not resolve compat version from '"+ version +"' will use default", e);
}
}
}
return null;
}

Expand Down
3 changes: 3 additions & 0 deletions src/main/java/org/jruby/rack/RackConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ public interface RackConfig {
/**
* Return the Ruby version that JRuby should run.
* @return <code>RUBY_VERSION</code> (e.g. 1.8, 1.9)
*
* @deprecated Since jruby-rack 1.2 (and JRuby 9.2), for removal in 1.3.0
*/
@Deprecated
CompatVersion getCompatVersion();
Comment thread
chadlwilson marked this conversation as resolved.

/**
Expand Down
10 changes: 7 additions & 3 deletions src/main/java/org/jruby/rack/embed/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ public class Config implements RackConfig {

private RackLogger logger;
private Map<String, String> rubyENV;
private CompatVersion compatVersion;

public Config() {
delegate = new DefaultRackConfig() {
Expand All @@ -66,7 +65,6 @@ public void doInitialize(final Ruby runtime) {
setOut( runtime.getOut() );
setErr( runtime.getErr() );
rubyENV = runtime.getENV();
compatVersion = runtime.getInstanceConfig().getCompatVersion();
}


Expand Down Expand Up @@ -106,9 +104,15 @@ public final Number getNumberProperty(String key, Number defaultValue) {
return delegate.getNumberProperty(key, defaultValue);
}

/**
* @return Always CompatVersion.RUBY2_1, consistent with JRuby 9.3+
*
* @deprecated Since jruby-rack 1.2 (and JRuby 9.2), for removal in 1.3.0
*/
@Deprecated
@Override
public CompatVersion getCompatVersion() {
return compatVersion;
return CompatVersion.RUBY2_1;
Comment thread
chadlwilson marked this conversation as resolved.
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/ruby/jruby/rack/core_ext.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Exception
include JRuby::Rack::Capture::Environment if $DEBUG
include JRuby::Rack::Capture::RubyGems
include JRuby::Rack::Capture::Bundler
include JRuby::Rack::Capture::JRubyRackConfig
include JRuby::Rack::Capture::JRubyRackConfig if JRUBY_VERSION.start_with?("9.") # Workaround for JRuby 10 with missing CompatVersion class
include JRuby::Rack::Capture::JavaEnvironment if $DEBUG
end

Expand Down
10 changes: 5 additions & 5 deletions src/main/ruby/jruby/rack/rack_ext.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,18 @@ def render(path, params={})
end
end

if JRUBY_VERSION >= '9.4'
::Rack::Request::Helpers.module_eval do
include ::JRuby::Rack::RackExt::RequestHelpers
end
else
if JRUBY_VERSION.start_with?("9.3")
::Rack::Request.module_eval do
include ::JRuby::Rack::RackExt::RequestHelpers
end

::ActionDispatch::Request.module_eval do
include ::JRuby::Rack::RackExt::RequestHelpers
end if defined?(::ActionDispatch::Request)
else
::Rack::Request::Helpers.module_eval do
include ::JRuby::Rack::RackExt::RequestHelpers
end
end
end
end
Expand Down
17 changes: 17 additions & 0 deletions src/spec/java/org/jruby/CompatVersion.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package org.jruby;

/**
* This was removed from JRuby Core as of 10.0; but deprecated and unused for a long time.
* <p/>
* While this is not actually used at runtime unless people specifically invoke the methods on Rack Config, various
* tests mock RackConfig which causes tests to try and load the class. So we add back/override a minimal version here
* to allow the tests to work on JRuby 10, and be able to add JRuby 10 and Rails 8.0 support to the 1.2.x line.
* <p/>>
* <a href="https://github.com/jruby/jruby/blob/jruby-9.4/core/src/main/java/org/jruby/CompatVersion.java">CompatVersion@9.4 source</a>}
* @deprecated since JRuby 9.2 with no replacement; for removal with jruby-rack 1.3.0
*/
public enum CompatVersion {
RUBY1_8, // used in specs
RUBY2_1, // used as default by jruby-rack
BOTH // used as the default by JRuby 9.3/9.4 at runtime
}
2 changes: 1 addition & 1 deletion src/spec/ruby/jruby/rack/error_app_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def in_tmpdir_with_files(files = {})
end
yield path
ensure
FileUtils.rm_rf(path) if path && File.exists?(path)
FileUtils.rm_rf(path) if path && File.exist?(path)
end

end
Expand Down
12 changes: 4 additions & 8 deletions src/spec/ruby/jruby/rack/integration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
before do
@servlet_context = org.jruby.rack.mock.RackLoggingMockServletContext.new "file://#{STUB_DIR}/rack"
@servlet_context.logger = raise_logger
# make sure we always boot runtimes in the same mode as specs :
set_compat_version @servlet_context
end

it "initializes" do
Expand Down Expand Up @@ -221,6 +219,10 @@
it_should_behave_like 'a rails app'
end

describe 'rails 8.0', lib: :rails80 do
it_should_behave_like 'a rails app'
end

def expect_to_have_monkey_patched_chunked
@runtime.evalScriptlet "require 'rack/chunked'"
script = %{
Expand Down Expand Up @@ -260,16 +262,10 @@ def new_servlet_context(base_path = nil)
end

def prepare_servlet_context(servlet_context, base_path)
set_compat_version servlet_context
servlet_context.addInitParameter('rails.root', base_path)
servlet_context.addInitParameter('jruby.rack.layout_class', 'FileSystemLayout')
end

def set_compat_version(servlet_context = @servlet_context); require 'jruby'
compat_version = JRuby.runtime.getInstanceConfig.getCompatVersion # RUBY1_9
servlet_context.addInitParameter("jruby.compat.version", compat_version.to_s)
end

GEMFILES_DIR = File.expand_path('../../../gemfiles', STUB_DIR)

def copy_gemfile
Expand Down
Loading