Skip to content

Commit fceebed

Browse files
committed
Remove jruby.compat.version which is no longer needed for supported JRubies
This has been set to 2.0 for all supported JRubies for a long time. (cherry picked from commit 54b3c20)
1 parent c50a3d3 commit fceebed

File tree

10 files changed

+1
-150
lines changed

10 files changed

+1
-150
lines changed

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,6 @@ as context init parameters in web.xml or as VM-wide system properties.
206206
sub-path of the main servlet context root.
207207
- `gem.path`: Relative path to the bundled gem repository. Defaults to
208208
*/WEB-INF/gems*.
209-
- `jruby.compat.version`: Set to "1.8" or "1.9" to make JRuby run a specific
210-
version of Ruby (same as the --1.8 / --1.9 command line flags).
211209
- `jruby.min.runtimes`: For non-threadsafe Rails applications using a runtime
212210
pool, specify an integer minimum number of runtimes to hold in the pool.
213211
- `jruby.max.runtimes`: For non-threadsafe Rails applications, an integer

src/main/java/org/jruby/rack/DefaultRackApplicationFactory.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -309,10 +309,6 @@ protected RubyInstanceConfig initRuntimeConfig(final RubyInstanceConfig config)
309309
// Process arguments, namely any that might be in RUBYOPT
310310
config.processArguments(rackConfig.getRuntimeArguments());
311311

312-
if ( rackConfig.getCompatVersion() != null ) {
313-
config.setCompatVersion(rackConfig.getCompatVersion());
314-
}
315-
316312
try { // try to set jruby home to jar file path
317313
final URL resource = Ruby.class.getResource("/META-INF/jruby.home");
318314
if ( resource != null && "jar".equals( resource.getProtocol() ) ) {

src/main/java/org/jruby/rack/DefaultRackConfig.java

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,9 @@
1717
import java.util.HashMap;
1818
import java.util.LinkedHashMap;
1919
import java.util.Map;
20-
import java.util.regex.Matcher;
21-
import java.util.regex.Pattern;
22-
import org.jruby.CompatVersion;
2320
import org.jruby.rack.logging.OutputStreamLogger;
2421
import org.jruby.rack.logging.StandardOutLogger;
2522
import org.jruby.util.SafePropertyAccessor;
26-
import static org.jruby.rack.RackLogger.Level.*;
2723

2824
/**
2925
* A base implementation of that retrieves settings from system properties.
@@ -77,28 +73,6 @@ public void setQuiet(boolean quiet) {
7773
this.quiet = quiet;
7874
}
7975

80-
@Override
81-
public CompatVersion getCompatVersion() {
82-
final String version = getProperty("jruby.compat.version");
83-
if ( version != null ) {
84-
// we handle 1.8, RUBY1_9, --2.0 1_9 2.1.0.dev etc :
85-
final Pattern pattern = Pattern.compile("([123])[._]([8901234567])");
86-
final Matcher matcher = pattern.matcher(version);
87-
if ( matcher.find() ) {
88-
final String name = "RUBY" +
89-
matcher.group(1) + '_' + matcher.group(2);
90-
try {
91-
return Enum.valueOf(CompatVersion.class, name);
92-
}
93-
catch (IllegalArgumentException e) {
94-
getLogger().log(WARN,
95-
"could not resolve compat version from '"+ version +"' will use default", e);
96-
}
97-
}
98-
}
99-
return null;
100-
}
101-
10276
@Override
10377
public String getRackup() {
10478
return getProperty("rackup");

src/main/java/org/jruby/rack/RackConfig.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77

88
package org.jruby.rack;
99

10-
import org.jruby.CompatVersion;
11-
1210
import java.io.PrintStream;
1311
import java.util.Map;
1412

@@ -32,12 +30,6 @@ public interface RackConfig {
3230
* @return <code>STDERR</code>
3331
*/
3432
PrintStream getErr();
35-
36-
/**
37-
* Return the Ruby version that JRuby should run.
38-
* @return <code>RUBY_VERSION</code> (e.g. 1.8, 1.9)
39-
*/
40-
CompatVersion getCompatVersion();
4133

4234
/**
4335
* Return the rackup Ruby script to be used to launch the application.

src/main/java/org/jruby/rack/embed/Config.java

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import java.io.PrintStream;
2828
import java.util.Map;
2929

30-
import org.jruby.CompatVersion;
3130
import org.jruby.Ruby;
3231
import org.jruby.rack.DefaultRackConfig;
3332
import org.jruby.rack.RackConfig;
@@ -44,7 +43,6 @@ public class Config implements RackConfig {
4443

4544
private RackLogger logger;
4645
private Map<String, String> rubyENV;
47-
private CompatVersion compatVersion;
4846

4947
public Config() {
5048
delegate = new DefaultRackConfig() {
@@ -61,31 +59,11 @@ public String getProperty(String key, String defaultValue) {
6159
};
6260
}
6361

64-
/*
65-
Config(final RackConfig config) {
66-
delegate = new DefaultRackConfig() {
67-
68-
@Override
69-
public String getProperty(String key, String defaultValue) {
70-
String value = config.getProperty(key, null);
71-
if ( value != null ) return value;
72-
73-
value = Config.this.resolveProperty(key);
74-
return value != null ? value : super.getProperty(key, defaultValue);
75-
}
76-
77-
@Override
78-
public RackLogger defaultLogger() { return null; }
79-
80-
};
81-
} */
82-
8362
@SuppressWarnings("unchecked")
8463
public void doInitialize(final Ruby runtime) {
8564
setOut( runtime.getOut() );
8665
setErr( runtime.getErr() );
8766
rubyENV = runtime.getENV();
88-
compatVersion = runtime.getInstanceConfig().getCompatVersion();
8967
}
9068

9169

@@ -119,10 +97,6 @@ public final Number getNumberProperty(String key, Number defaultValue) {
11997
return delegate.getNumberProperty(key, defaultValue);
12098
}
12199

122-
public CompatVersion getCompatVersion() {
123-
return compatVersion;
124-
}
125-
126100
public RackLogger getLogger() {
127101
if (logger == null) {
128102
logger = delegate.getLogger();

src/spec/ruby/jruby/rack/error_app_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ def in_tmpdir_with_files(files = {})
161161
end
162162
yield path
163163
ensure
164-
FileUtils.rm_rf(path) if path && File.exists?(path)
164+
FileUtils.rm_rf(path) if path && File.exist?(path)
165165
end
166166

167167
end

src/spec/ruby/jruby/rack/integration_spec.rb

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,11 @@
1515

1616
before(:all) { require 'fileutils' }
1717

18-
#after(:all) { JRuby::Rack.context = nil }
19-
2018
describe 'rack (lambda)' do
2119

2220
before do
2321
@servlet_context = org.jruby.rack.mock.RackLoggingMockServletContext.new "file://#{STUB_DIR}/rack"
2422
@servlet_context.logger = raise_logger
25-
# make sure we always boot runtimes in the same mode as specs :
26-
set_compat_version @servlet_context
2723
end
2824

2925
it "initializes" do
@@ -136,7 +132,6 @@ def base_path; "file://#{STUB_DIR}/rails30" end
136132
before :all do
137133
initialize_rails nil, base_path
138134
end
139-
after(:all) { restore_rails }
140135

141136
it "loaded rack ~> 1.2" do
142137
@runtime = @rack_factory.getApplication.getRuntime
@@ -435,27 +430,12 @@ def initialize_rails(env = nil, servlet_context = @servlet_context)
435430
@servlet_context ||= servlet_context
436431
end
437432

438-
def restore_rails
439-
#ENV['RACK_ENV'] = ENV_COPY['RACK_ENV'] if ENV.key?('RACK_ENV')
440-
#ENV['RAILS_ENV'] = ENV_COPY['RAILS_ENV'] if ENV.key?('RAILS_ENV')
441-
end
442-
443433
def new_servlet_context(base_path = nil)
444434
servlet_context = org.jruby.rack.mock.RackLoggingMockServletContext.new base_path
445435
servlet_context.logger = raise_logger
446-
prepare_servlet_context servlet_context
447436
servlet_context
448437
end
449438

450-
def prepare_servlet_context(servlet_context)
451-
set_compat_version servlet_context
452-
end
453-
454-
def set_compat_version(servlet_context = @servlet_context); require 'jruby'
455-
compat_version = JRuby.runtime.getInstanceConfig.getCompatVersion # RUBY1_9
456-
servlet_context.addInitParameter("jruby.compat.version", compat_version.to_s)
457-
end
458-
459439
private
460440

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

src/spec/ruby/rack/application_spec.rb

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -390,13 +390,6 @@ def newRuntime() # use the current runtime instead of creating new
390390
should_eval_as_eql_to "require 'yaml'", true # -ryaml not processed
391391
end
392392

393-
it "handles jruby.compat.version == '1.9' and starts in 1.9 mode" do
394-
set_config 'jruby.compat.version', '1.9'
395-
#@rack_config.stub(:getCompatVersion).and_return org.jruby.CompatVersion::RUBY1_9
396-
@runtime = app_factory.new_runtime
397-
@runtime.is1_9.should be_truthy
398-
end
399-
400393
it "handles jruby.runtime.arguments == '-X+O -Ke' and start with object space enabled and KCode EUC" do
401394
set_config 'jruby.runtime.arguments', '-X+O -Ke'
402395
#@rack_config.stub(:getRuntimeArguments).and_return ['-X+O', '-Ke'].to_java(:String)

src/spec/ruby/rack/config_spec.rb

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -184,56 +184,6 @@ def expect_empty_env(env)
184184

185185
end
186186

187-
it "sets compat version from init parameter" do
188-
@servlet_context.should_receive(:getInitParameter).with("jruby.compat.version").
189-
and_return "RUBY1_9"
190-
expect( config.getCompatVersion ).to be org.jruby.CompatVersion::RUBY1_9
191-
end
192-
193-
it "sets compat version from init parameter (dot syntax)" do
194-
@servlet_context.should_receive(:getInitParameter).with("jruby.compat.version").
195-
and_return "1.8"
196-
expect( config.getCompatVersion ).to be org.jruby.CompatVersion::RUBY1_8
197-
end
198-
199-
it "leaves compat version nil if not specified" do
200-
@servlet_context.should_receive(:getInitParameter).with("jruby.compat.version").
201-
and_return nil
202-
expect( config.getCompatVersion ).to be nil
203-
end
204-
205-
it "leaves compat version nil if invalid value specified" do
206-
@servlet_context.should_receive(:getInitParameter).with("jruby.compat.version").
207-
and_return "4.2"
208-
expect( config.getCompatVersion ).to be nil
209-
end
210-
211-
it "sets compat version from init parameter (head-syntax)" do
212-
@servlet_context.should_receive(:getInitParameter).with("jruby.compat.version").
213-
and_return "1.9.3-SNAPSHOT"
214-
expect( config.getCompatVersion ).to be org.jruby.CompatVersion::RUBY1_9
215-
end
216-
217-
if JRUBY_VERSION >= '1.7.0'
218-
it "sets compat version 2.0 from init parameter" do
219-
@servlet_context.should_receive(:getInitParameter).with("jruby.compat.version").
220-
and_return "RUBY2_0"
221-
expect( config.getCompatVersion ).to be org.jruby.CompatVersion::RUBY2_0
222-
end
223-
224-
it "sets compat version 2.0 from init parameter (dot syntax)" do
225-
@servlet_context.should_receive(:getInitParameter).with("jruby.compat.version").
226-
and_return "2_0"
227-
expect( config.getCompatVersion ).to be org.jruby.CompatVersion::RUBY2_0
228-
end
229-
230-
it "sets compat version 2.0 from init parameter (head-syntax)" do
231-
@servlet_context.should_receive(:getInitParameter).with("jruby.compat.version").
232-
and_return "2.0.0.dev"
233-
expect( config.getCompatVersion ).to be org.jruby.CompatVersion::RUBY2_0
234-
end
235-
end
236-
237187
describe "custom-properties" do
238188

239189
it "parser an int property" do

src/spec/ruby/rack/embed/config_spec.rb

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,6 @@
8383
end
8484
end
8585

86-
it "sets compat version from runtime" do
87-
require 'jruby'
88-
compat_version = JRuby.runtime.instance_config.compat_version
89-
expect( @config.compat_version ).to eql compat_version
90-
end
91-
9286
it "sets out/err streams from runtime" do
9387
out = java.io.ByteArrayOutputStream.new
9488
err = java.io.ByteArrayOutputStream.new

0 commit comments

Comments
 (0)