Skip to content

Commit

Permalink
Fix Java-version parsing for openjdk
Browse files Browse the repository at this point in the history
  • Loading branch information
rtyley committed Apr 7, 2015
1 parent 37f60f4 commit b9949fe
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions bfg-benchmark/src/main/scala/JavaVersion.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import scala.sys.process.{ProcessLogger, Process}
import ExecutionContext.Implicits.global

object JavaVersion {
val VersionRegex = """java version "(.*?)"""".r
val VersionRegex = """(?:java|openjdk) version "(.*?)"""".r

def version(javaCmd: String): Future[String] = {
val resultPromise = Promise[String]()

future {
Future {
val exitCode = Process(s"$javaCmd -version")!ProcessLogger(
s => for (v <-versionFrom(s)) resultPromise.success(v)
)
Expand Down
3 changes: 3 additions & 0 deletions bfg-benchmark/src/test/scala/JavaVersionSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,8 @@ object JavaVersionSpec extends Specification {
"parse an example line" in {
JavaVersion.versionFrom("""java version "1.7.0_51"""") should beSome("1.7.0_51")
}
"parse openjdk weirdness" in {
JavaVersion.versionFrom("""openjdk version "1.8.0_40-internal"""") should beSome("1.8.0_40-internal")
}
}
}

0 comments on commit b9949fe

Please sign in to comment.