Skip to content
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
18 changes: 14 additions & 4 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
matrix:
jruby_version: [ '9.4.14.0', '10.0.2.0' ]
java_version: [ '8', '11', '17', '21', '25' ]
rack_version: [ '~> 2.2.0' ]
rack_version: [ '~> 2.2.0', '~> 3.1.0', '~> 3.2.0' ]
exclude:
- jruby_version: '10.0.2.0'
java_version: '8' # JRuby 10 requires Java 21
Expand Down Expand Up @@ -61,9 +61,10 @@ jobs:
appraisal: [
'rails61_rack22',
'rails70_rack22',
'rails71_rack22',
'rails72_rack22',
'rails80_rack22',
'rails71_rack22', 'rails71_rack31',
'rails72_rack22', 'rails72_rack31',
'rails80_rack22', 'rails80_rack31', 'rails80_rack32',
'rails81_rack31', 'rails81_rack32',
]
jruby_version: [ '9.4.14.0', '10.0.2.0' ]
java_version: [ '8', '11', '17', '21', '25' ]
Expand All @@ -76,6 +77,15 @@ jobs:
java_version: '17' # JRuby 10 requires Java 21
- appraisal: 'rails80_rack22'
jruby_version: '9.4.14.0' # Rails 8 requires Ruby 3.4 compatibility, which JRuby 9.4 does not support
- appraisal: 'rails80_rack31'
jruby_version: '9.4.14.0' # Rails 8 requires Ruby 3.4 compatibility, which JRuby 9.4 does not support
- appraisal: 'rails80_rack32'
jruby_version: '9.4.14.0' # Rails 8 requires Ruby 3.4 compatibility, which JRuby 9.4 does not support
- appraisal: 'rails81_rack31'
jruby_version: '9.4.14.0' # Rails 8 requires Ruby 3.4 compatibility, which JRuby 9.4 does not support
- appraisal: 'rails81_rack32'
jruby_version: '9.4.14.0' # Rails 8 requires Ruby 3.4 compatibility, which JRuby 9.4 does not support

fail-fast: false

env:
Expand Down
7 changes: 4 additions & 3 deletions Appraisals
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ version_spec = ->(prefix, desc) { "~> #{desc.split(prefix).last.insert(1, ".")}.
{
"rails61" => %w[rack22],
"rails70" => %w[rack22],
"rails71" => %w[rack22],
"rails72" => %w[rack22],
"rails80" => %w[rack22]
"rails71" => %w[rack22 rack31],
"rails72" => %w[rack22 rack31],
"rails80" => %w[rack22 rack31 rack32],
"rails81" => %w[rack31 rack32],
}.each do |rails_desc, rack_descs|
rack_descs.each do |rack_desc|

Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## 1.3.0 (UNRELEASED)

- Support Javax Servlet API 4.0 (JEE 8)
- Support Rack 3.0 -> 3.2 (default vendored Rack is still 2.2)
- Adds basic compatibility with JRuby 10.0
- Drop support for JRuby 9.3
- Drop support for Rails < 6.1
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ For more information on Rack, visit http://rack.github.io/.

| JRuby-Rack Series | Status | Rack | JRuby | Java | Rails | Target Servlet API | Notes |
|------------------------------------------------------------|------------|-----------|------------|------|-----------|---------------------|--------------------------------------------|
| 2.0 (_planned_) | Dev | 2.2 | 9.4 → 10.0 | 8+ | 6.1 → 8.0 | 5.0+ (Jakarta EE 9) | Pre 5.0 servlet APIs non functional. |
| 1.3 (master, _unreleased_) | Dev | 2.2 | 9.4 → 10.0 | 8+ | 6.1 → 8.0 | 4.0 (Java EE 8) | Servlet 2.5 → 3.1 likely to work fine. |
| 2.0 (_planned_) | Dev | 2.2 → 3.2 | 9.4 → 10.0 | 8+ | 6.1 → 8.1 | 5.0+ (Jakarta EE 9) | Pre 5.0 servlet APIs non functional. |
| 1.3 (master, _unreleased_) | Dev | 2.2 → 3.2 | 9.4 → 10.0 | 8+ | 6.1 → 8.1 | 4.0 (Java EE 8) | Servlet 2.5 → 3.1 likely to work fine. |
| [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) | Servlet 3.1 → 4.0 OK with some containers. |
| [1.1](https://github.com/jruby/jruby-rack/tree/1.1-stable) | EOL | 1.x → 2.2 | 1.6 → 9.4 | 6+ | 2.1 → 5.2 | 2.5 (Java EE 5) | Servlet 3.0 → 4.0 OK with some containers. |
| 1.0 | EOL | 0.9 → 1.x | 1.1 → 1.9 | 5+ | 2.1 → 3.x | 2.5 (Java EE 5) | |
Expand Down Expand Up @@ -354,7 +354,7 @@ package and push the .jar every time a commit changes a source file).
```shell
VERSION=rails72
cd src/spec/stub
rm -rf $VERSION && BUNDLE_GEMFILE=~/Projects/community/jruby-rack/gemfiles/${VERSION}_rack22.gemfile bundle exec rails new $VERSION --minimal --skip-git --skip-docker --skip-active-model --skip-active-record --skip-test --skip-system-test --skip-dev-gems --skip-bundle --skip-keeps --skip-asset-pipeline --skip-ci --skip-brakeman --skip-rubocop
rm -rf $VERSION && BUNDLE_GEMFILE=~/Projects/community/jruby-rack/gemfiles/${VERSION}_rack32.gemfile bundle exec rails new $VERSION --minimal --skip-git --skip-docker --skip-active-model --skip-active-record --skip-test --skip-system-test --skip-dev-gems --skip-bundle --skip-keeps --skip-asset-pipeline --skip-ci --skip-brakeman --skip-rubocop
```
* Manual changes to make to support testing
* In `config/production.rb` comment out the default `config.logger` value so jruby-rack applies its own `RailsLogger`.
Expand Down
15 changes: 15 additions & 0 deletions gemfiles/rails71_rack31.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", "~> 3.1.0"
gem "rails", "~> 7.1.0"
end

group :development do
gem "appraisal", require: nil
end
15 changes: 15 additions & 0 deletions gemfiles/rails72_rack31.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", "~> 3.1.0"
gem "rails", "~> 7.2.0"
end

group :development do
gem "appraisal", require: nil
end
15 changes: 15 additions & 0 deletions gemfiles/rails80_rack31.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", "~> 3.1.0"
gem "rails", "~> 8.0.0"
end

group :development do
gem "appraisal", require: nil
end
15 changes: 15 additions & 0 deletions gemfiles/rails80_rack32.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", "~> 3.2.0"
gem "rails", "~> 8.0.0"
end

group :development do
gem "appraisal", require: nil
end
15 changes: 15 additions & 0 deletions gemfiles/rails81_rack31.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", "~> 3.1.0.beta"
gem "rails", "~> 8.1.0.beta"
end

group :development do
gem "appraisal", require: nil
end
15 changes: 15 additions & 0 deletions gemfiles/rails81_rack32.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", "~> 3.2.0.beta"
gem "rails", "~> 8.1.0.beta"
end

group :development do
gem "appraisal", require: nil
end
6 changes: 6 additions & 0 deletions src/main/java/org/jruby/rack/RackEnvironment.java
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,10 @@ public interface RackEnvironment {
* @return the remote user
*/
String getRemoteUser();

/**
* @see javax.servlet.http.HttpServletRequest#getProtocol()
* @return a String containing the name of the scheme used to make this request
*/
String getProtocol();
}
30 changes: 16 additions & 14 deletions src/main/ruby/jruby/rack/chunked.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,23 @@
# See the file LICENSE.txt for details.
#++

require 'rack/chunked' # exists since Rack 1.1
if Rack.release < '3'
require 'rack/chunked' # exists since Rack 1.1, removed in Rack 3.0

# Disables the Rack response body chunking performed by `Rack::Chunked::Body`.
# It is "necessary" since Rails does instantiate the body directly instead of
# using `Rack::Chunked` as a middleware.
#
# @note This monkey-patch is not required to support chunking with servlets and
# won't be applied unless **jruby.rack.response.dechunk** is 'patch' (default).
# Set **jruby.rack.response.dechunk** to 'true' to simply "dechunk" the body and
# keep the `Rack::Chunked::Body` class as is (or 'false' to do no de-chunking at
# all).
Rack::Chunked::Body.class_eval do
# Disables the Rack response body chunking performed by `Rack::Chunked::Body`.
# It is "necessary" since Rails does instantiate the body directly instead of
# using `Rack::Chunked` as a middleware.
#
# @note This monkey-patch is not required to support chunking with servlets and
# won't be applied unless **jruby.rack.response.dechunk** is 'patch' (default).
# Set **jruby.rack.response.dechunk** to 'true' to simply "dechunk" the body and
# keep the `Rack::Chunked::Body` class as is (or 'false' to do no de-chunking at
# all).
Rack::Chunked::Body.class_eval do

def each(&block)
@body.each(&block) # no-chunking on servlets
end

def each(&block)
@body.each(&block) # no-chunking on servlets
end

end
1 change: 0 additions & 1 deletion src/main/ruby/jruby/rack/error_app/show_status.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ def initialize(app)

def call(env)
status, headers, body = @app.call(env)
headers = ::Rack::Utils::HeaderHash.new(headers)
empty = headers['Content-Length'].to_i <= 0

detail = env['rack.showstatus.detail']
Expand Down
22 changes: 15 additions & 7 deletions src/main/ruby/rack/handler/servlet/default_env.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,20 @@ class Servlet
# ServletRequest input stream to be not read (e.g. for POSTs).
class DefaultEnv < Hash # The environment must be an instance of Hash !

BUILTINS = %w(rack.version rack.input rack.errors rack.url_scheme
rack.multithread rack.multiprocess rack.run_once rack.hijack?
java.servlet_request java.servlet_response java.servlet_context
jruby.rack.version).
map!(&:freeze)
BUILTINS = Rack.release < '3' ?
# rack 2.2.x
Set.new(%w(rack.version rack.multithread rack.multiprocess rack.run_once
rack.input rack.errors rack.url_scheme rack.hijack?
java.servlet_request java.servlet_response java.servlet_context
jruby.rack.context jruby.rack.version).map!(&:freeze)) :
# rack 3.0 and later
Set.new(%w(rack.input rack.errors rack.url_scheme rack.hijack?
java.servlet_request java.servlet_response java.servlet_context
jruby.rack.context jruby.rack.version).map!(&:freeze))

VARIABLES = %w(CONTENT_TYPE CONTENT_LENGTH PATH_INFO QUERY_STRING
REMOTE_ADDR REMOTE_HOST REMOTE_USER REQUEST_METHOD REQUEST_URI
SCRIPT_NAME SERVER_NAME SERVER_PORT SERVER_SOFTWARE).
SCRIPT_NAME SERVER_NAME SERVER_PORT SERVER_SOFTWARE SERVER_PROTOCOL).
map!(&:freeze)

attr_reader :env
Expand Down Expand Up @@ -216,6 +221,7 @@ def load_variable(env, key)
when 'SCRIPT_NAME' then env[key] = @servlet_env.getScriptName
when 'SERVER_NAME' then env[key] = @servlet_env.getServerName || ''
when 'SERVER_PORT' then env[key] = @servlet_env.getServerPort.to_s
when 'SERVER_PROTOCOL' then env[key] = @servlet_env.getProtocol
when 'SERVER_SOFTWARE' then env[key] = rack_context.getServerInfo
else
# NOTE: even though we allowed for overrides and loaded all attributes
Expand All @@ -230,8 +236,10 @@ def load_variable(env, key)
end

def load_builtin(env, key)
return nil unless BUILTINS.include?(key)

case key
when 'rack.version' then env[key] = ::Rack::RELEASE
when 'rack.version' then env[key] = ::Rack.release
when 'rack.multithread' then env[key] = true
when 'rack.multiprocess' then env[key] = false
when 'rack.run_once' then env[key] = false
Expand Down
Loading