Handle non-hotspot javas in version check

Fixes #3685
This commit is contained in:
Andrew Cholakian 2015-08-03 16:10:44 -05:00 committed by Jordan Sissel
parent 8fa55f5877
commit 9e88c90b28
2 changed files with 11 additions and 0 deletions

View file

@ -30,6 +30,9 @@ module LogStash::Util::JavaVersion
# The regex below parses this all correctly http://rubular.com/r/sInQc3Nc7f
match = version_string.match(/\A(\d+)\.(\d+)\.(\d+)(_(\d+))?(-(.+))?\Z/)
return nil unless match
major, minor, patch, ufull, update, bfull, build = match.captures
{

View file

@ -31,6 +31,14 @@ describe "LogStash::Util::JavaVersion" do
expect(mod.parse_java_version(nil)).to be_nil
end
it "should return nil on non-hotspot javas" do
# Not sure this is what is being returned, but it doesn't match the
# regex, which is the point
expect(mod.parse_java_version("JCL - 20140103_01 based on Oracle 7u51-b11
")).to be_nil
end
shared_examples("version parsing") do |desc, string, major, minor, patch, update, build|
context("#{desc} with version #{string}") do
subject(:parsed) { LogStash::Util::JavaVersion.parse_java_version(string) }