diff --git a/lib/facter/java_jre_version.rb b/lib/facter/java_jre_version.rb index e6fa6f7..05529bf 100644 --- a/lib/facter/java_jre_version.rb +++ b/lib/facter/java_jre_version.rb @@ -16,6 +16,8 @@ java_jre = "/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java" next unless File.exist? java_jre t_java_jre = Facter::Util::Resolution.exec("'#{java_jre}' -version 2>&1") - java_jre_version = t_java_jre.to_s.lines.first.strip.split(/version/)[1].gsub(/"/, "").strip + next unless t_java_jre_line = t_java_jre.to_s.lines.first + next unless t_java_jre_version_section = t_java_jre_line.strip.split(/version/)[1] + java_jre_version = t_java_jre_version_section.gsub(/"/, "").strip end end diff --git a/lib/facter/java_version.rb b/lib/facter/java_version.rb index e9e6b01..08d99d2 100644 --- a/lib/facter/java_version.rb +++ b/lib/facter/java_version.rb @@ -16,6 +16,8 @@ # This will fail on OS X when Java hasn't been installed yet. next unless system "/usr/libexec/java_home --failfast &>/dev/null" t_java = Facter::Util::Resolution.exec("java -version 2>&1") - java_version = t_java.to_s.lines.first.strip.split(/version/)[1].gsub(/"/, "").strip + next unless t_java_line = t_java.to_s.lines.first.to_s + next unless t_java_version_section = t_java_line.strip.split(/version/)[1] + java_version = t_java_version_section.gsub(/"/, "").strip end end