From a3dc585f4daddee85a8541bc1a75aef3258568c4 Mon Sep 17 00:00:00 2001 From: Chris Armstrong Date: Fri, 24 Jan 2014 14:12:24 -0800 Subject: [PATCH] Allow jdk_version to be a string or number Previously, the case statements checking the jdk_version failed because they were assuming jdk_version was a string. For users overriding this value and setting it to be a number, the case statement would never match. This commit ensures we are always using a string when comparing jdk_version. --- libraries/helpers.rb | 2 +- recipes/ibm.rb | 2 +- recipes/ibm_tar.rb | 2 +- recipes/openjdk.rb | 2 +- recipes/oracle.rb | 8 +------- recipes/oracle_i386.rb | 2 +- spec/libraries/helpers_spec.rb | 2 +- 7 files changed, 7 insertions(+), 13 deletions(-) diff --git a/libraries/helpers.rb b/libraries/helpers.rb index 5d31ec6f..761cc351 100644 --- a/libraries/helpers.rb +++ b/libraries/helpers.rb @@ -27,7 +27,7 @@ class OpenJDK def initialize(node) @node = node.to_hash @java_home = @node['java']['java_home'] || '/usr/lib/jvm/default-java' - @jdk_version = @node['java']['jdk_version'] || '6' + @jdk_version = @node['java']['jdk_version'].to_s || '6' end def java_location diff --git a/recipes/ibm.rb b/recipes/ibm.rb index 53a92f41..6d073136 100644 --- a/recipes/ibm.rb +++ b/recipes/ibm.rb @@ -52,7 +52,7 @@ java_alternatives 'set-java-alternatives' do java_location node['java']['java_home'] - case node['java']['jdk_version'] + case node['java']['jdk_version'].to_s when "6" bin_cmds node['java']['ibm']['6']['bin_cmds'] when "7" diff --git a/recipes/ibm_tar.rb b/recipes/ibm_tar.rb index 984ccaf0..4aa30a22 100644 --- a/recipes/ibm_tar.rb +++ b/recipes/ibm_tar.rb @@ -50,7 +50,7 @@ java_alternatives 'set-java-alternatives' do java_location node['java']['java_home'] - case node['java']['jdk_version'] + case node['java']['jdk_version'].to_s when "6" bin_cmds node['java']['ibm']['6']['bin_cmds'] when "7" diff --git a/recipes/openjdk.rb b/recipes/openjdk.rb index d4026b25..202affd7 100644 --- a/recipes/openjdk.rb +++ b/recipes/openjdk.rb @@ -50,7 +50,7 @@ java_alternatives 'set-java-alternatives' do java_location jdk.java_home priority jdk.alternatives_priority - case node['java']['jdk_version'] + case node['java']['jdk_version'].to_s when "6" bin_cmds node['java']['jdk']['6']['bin_cmds'] when "7" diff --git a/recipes/oracle.rb b/recipes/oracle.rb index 91c26746..0a2d1f78 100644 --- a/recipes/oracle.rb +++ b/recipes/oracle.rb @@ -28,14 +28,8 @@ java_home = node['java']["java_home"] arch = node['java']['arch'] -jdk_version = node['java']['jdk_version'] -#convert version number to a string if it isn't already -if jdk_version.instance_of? Fixnum - jdk_version = jdk_version.to_s -end - -case jdk_version +case node['java']['jdk_version'].to_s when "6" tarball_url = node['java']['jdk']['6'][arch]['url'] tarball_checksum = node['java']['jdk']['6'][arch]['checksum'] diff --git a/recipes/oracle_i386.rb b/recipes/oracle_i386.rb index 5b51c742..eb25c882 100644 --- a/recipes/oracle_i386.rb +++ b/recipes/oracle_i386.rb @@ -28,7 +28,7 @@ java_home = node['java']["java_home"] -case node['java']['jdk_version'] +case node['java']['jdk_version'].to_s when "6" tarball_url = node['java']['jdk']['6']['i586']['url'] tarball_checksum = node['java']['jdk']['6']['i586']['checksum'] diff --git a/spec/libraries/helpers_spec.rb b/spec/libraries/helpers_spec.rb index 0eb821c2..f1460187 100644 --- a/spec/libraries/helpers_spec.rb +++ b/spec/libraries/helpers_spec.rb @@ -23,7 +23,7 @@ { 'java' => { 'java_home' => '/usr/lib/jvm/default-java', - 'jdk_version' => 6 + 'jdk_version' => '6' }, 'kernel' => { 'machine' => 'x86_64'