Skip to content

Commit 48ced07

Browse files
committed
[chore] Remove pre Rack 2.2 parameter type error compatibility logic
1 parent 5a16cf1 commit 48ced07

File tree

2 files changed

+4
-17
lines changed

2 files changed

+4
-17
lines changed

src/main/ruby/rack/handler/servlet/servlet_env.rb

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,6 @@ def load_env_key(env, key)
5151
# @private
5252
POST_PARAM_METHODS = [ 'POST', 'PUT', 'DELETE' ].freeze
5353

54-
if defined? Rack::Utils::ParameterTypeError
55-
ParameterTypeError = Rack::Utils::ParameterTypeError
56-
else
57-
ParameterTypeError = TypeError
58-
end
59-
6054
# Load parameters into the (Rack) env from the Servlet API.
6155
# using javax.servlet.http.HttpServletRequest#getParameterMap
6256
def load_parameters
@@ -188,8 +182,8 @@ def parse_query_string
188182
end
189183

190184
def mark_parameter_error(msg)
191-
raise ParameterTypeError, msg
192-
rescue ParameterTypeError => e
185+
raise Rack::Utils::ParameterTypeError, msg
186+
rescue Rack::Utils::ParameterTypeError => e
193187
@parameter_error = e
194188
end
195189

src/spec/ruby/rack/handler/servlet_spec.rb

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -473,16 +473,9 @@ def getAttributeNames
473473
env = servlet.create_env(@servlet_env)
474474
rack_request = Rack::Request.new(env)
475475

476-
# Rack::Utils::ParameterTypeError (< TypeError) since 1.6.0
477-
if Rack::Utils.const_defined? :ParameterTypeError
478-
error = Rack::Utils::ParameterTypeError
479-
else
480-
error = TypeError
481-
end
482-
483-
expect { rack_request.GET }.to raise_error(error, "expected Hash (got Array) for param `foo'")
476+
expect { rack_request.GET }.to raise_error(Rack::Utils::ParameterTypeError, "expected Hash (got Array) for param `foo'")
484477
expect(rack_request.POST).to eq({})
485-
expect { rack_request.params }.to raise_error(error, "expected Hash (got Array) for param `foo'")
478+
expect { rack_request.params }.to raise_error(Rack::Utils::ParameterTypeError, "expected Hash (got Array) for param `foo'")
486479

487480
expect(rack_request.query_string).to eq 'foo[]=0&foo[bar]=1'
488481
end

0 commit comments

Comments
 (0)