Skip to content

Commit f22cf31

Browse files
committed
Do not sort JAVA_OPTS
Previously, the gremlins in my head drove me to sort the JAVA_OPTS before they were used during the startup of an application. As indicated in cloudfoundry#41, not only wasn't this needed, it actually prevented certain use-cases. This change removes the sorting of the JAVA_OPTS and updates the associated tests (the much larger bit of work). [#67684882][resolves cloudfoundry#41]
1 parent 885f6ed commit f22cf31

8 files changed

Lines changed: 8 additions & 8 deletions

File tree

lib/java_buildpack/component/java_opts.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def add_option(key, value)
7171
#
7272
# @return [String] the contents as an environment variable
7373
def as_env_var
74-
"JAVA_OPTS=\"#{sort.join(' ')}\""
74+
"JAVA_OPTS=\"#{join(' ')}\""
7575
end
7676

7777
private

lib/java_buildpack/container/java_main.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def release
4444
[
4545
"#{@droplet.java_home.root}/bin/java",
4646
@droplet.additional_libraries.as_classpath,
47-
@droplet.java_opts.sort.join(' '),
47+
@droplet.java_opts.join(' '),
4848
main_class,
4949
arguments,
5050
port

spec/java_buildpack/component/java_opts_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
opts.add_option 'test-key-2', 'test-value-2'
5858
opts.add_system_property 'test-key-1', 'test-value-1'
5959

60-
expect(opts.as_env_var).to eq('JAVA_OPTS="-Dtest-key-1=test-value-1 test-key-2=test-value-2"')
60+
expect(opts.as_env_var).to eq('JAVA_OPTS="test-key-2=test-value-2 -Dtest-key-1=test-value-1"')
6161
end
6262

6363
end

spec/java_buildpack/container/groovy_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@
107107
end
108108

109109
def java_opts_str
110-
"\"#{java_opts.sort.join(' ')}\""
110+
"\"#{java_opts.join(' ')}\""
111111
end
112112

113113
end

spec/java_buildpack/container/java_main_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@
140140
end
141141

142142
def java_opts_str
143-
java_opts.sort.join(' ')
143+
java_opts.join(' ')
144144
end
145145

146146
end

spec/java_buildpack/container/ratpack_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
it 'should return command',
6161
app_fixture: 'container_ratpack_staged' do
6262

63-
expect(component.release).to eq("#{java_home.as_env_var} JAVA_OPTS=\"-Dratpack.port=$PORT test-opt-1 test-opt-2\" " \
63+
expect(component.release).to eq("#{java_home.as_env_var} JAVA_OPTS=\"test-opt-2 test-opt-1 -Dratpack.port=$PORT\" " \
6464
'$PWD/bin/application')
6565
end
6666

spec/java_buildpack/container/spring_boot_cli_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@
112112
end
113113

114114
def java_opts_str
115-
"\"#{java_opts.sort.join(' ')}\""
115+
"\"#{java_opts.join(' ')}\""
116116
end
117117

118118
end

spec/java_buildpack/container/tomcat_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878

7979
it 'should return command' do
8080

81-
expect(component.command).to eq("#{java_home.as_env_var} JAVA_OPTS=\"-Dhttp.port=$PORT test-opt-1 test-opt-2\" " \
81+
expect(component.command).to eq("#{java_home.as_env_var} JAVA_OPTS=\"test-opt-2 test-opt-1 -Dhttp.port=$PORT\" " \
8282
'$PWD/.java-buildpack/tomcat/bin/catalina.sh run')
8383
end
8484

0 commit comments

Comments
 (0)