Skip to content
This repository has been archived by the owner on Dec 2, 2020. It is now read-only.

Commit

Permalink
Merge pull request #63 from boxen/error-handling
Browse files Browse the repository at this point in the history
java_*version: handle nil output better.
  • Loading branch information
MikeMcQuaid committed Aug 13, 2015
2 parents 8d209d0 + d2b9993 commit 48b4370
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion lib/facter/java_jre_version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 3 additions & 1 deletion lib/facter/java_version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 48b4370

Please sign in to comment.