Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

avoid NoMethodError: undefined method `split' for nil:NilClass with b…

…undler 1.1.x when ENV is cleared
  • Loading branch information...
commit 5ffda346a6bb5bc9f918e37c89e191d081426d5e 1 parent c7d7124
Karol Bucek kares authored
3  src/main/java/org/jruby/rack/DefaultRackApplicationFactory.java
View
@@ -187,6 +187,9 @@ private void initializeRuntime(Ruby runtime) throws RackInitializationException
runtime.getGlobalVariables().set("$servlet_context", context);
if (rackContext.getConfig().isIgnoreEnvironment()) {
runtime.evalScriptlet("ENV.clear");
+ // bundler 1.1.x assumes ENV['PATH'] is a string
+ // `ENV['PATH'].split(File::PATH_SEPARATOR)` ...
+ runtime.evalScriptlet("ENV['PATH'] = ''");
}
runtime.evalScriptlet("require 'rack/handler/servlet'");
} catch (RaiseException re) {
26 src/spec/ruby/rack/application_spec.rb
View
@@ -244,25 +244,33 @@ def createRackServletWrapper(runtime, rackup); end
should_eval_as_eql_to "$LOADED_FEATURES.reject { |p| #{reject_files} }", []
end
- it "should initialize the $servlet_context global variable" do
+ it "initializes the $servlet_context global variable" do
@runtime = app_factory.new_runtime
should_not_eval_as_nil "defined?($servlet_context)"
end
- it "should handle jruby.compat.version == '1.9' and start up in 1.9 mode" do
- @rack_config.stub!(:getCompatVersion).and_return org.jruby.CompatVersion::RUBY1_9
- @runtime = app_factory.new_runtime
- @runtime.is1_9.should be_true
- end
-
- it "should have environment variables cleared if the configuration ignores the environment" do
+ it "clears environment variables if the configuration ignores the environment" do
ENV["HOME"].should_not == ""
@rack_config.stub!(:isIgnoreEnvironment).and_return true
@runtime = app_factory.new_runtime
should_eval_as_nil "ENV['HOME']"
end
- it "should handle jruby.runtime.arguments == '-X+O -Ke' and start with object space enabled and KCode EUC" do
+ it "sets ENV['PATH'] to an empty string if the configuration ignores the environment" do
+ ENV["PATH"].should_not be nil
+ ENV["PATH"].should_not == ""
+ @rack_config.stub!(:isIgnoreEnvironment).and_return true
+ @runtime = app_factory.new_runtime
+ should_eval_as_eql_to "ENV['PATH']", ''
+ end
+
+ it "handles jruby.compat.version == '1.9' and starts in 1.9 mode" do
+ @rack_config.stub!(:getCompatVersion).and_return org.jruby.CompatVersion::RUBY1_9
+ @runtime = app_factory.new_runtime
+ @runtime.is1_9.should be_true
+ end
+
+ it "handles jruby.runtime.arguments == '-X+O -Ke' and start with object space enabled and KCode EUC" do
@rack_config.stub!(:getRuntimeArguments).and_return ['-X+O', '-Ke'].to_java(:String)
@runtime = app_factory.new_runtime
@runtime.object_space_enabled.should be_true
Please sign in to comment.
Something went wrong with that request. Please try again.