Return-Path: X-Original-To: apmail-brooklyn-dev-archive@minotaur.apache.org Delivered-To: apmail-brooklyn-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 738C517DEF for ; Thu, 30 Apr 2015 16:16:56 +0000 (UTC) Received: (qmail 45494 invoked by uid 500); 30 Apr 2015 16:16:56 -0000 Delivered-To: apmail-brooklyn-dev-archive@brooklyn.apache.org Received: (qmail 45463 invoked by uid 500); 30 Apr 2015 16:16:56 -0000 Mailing-List: contact dev-help@brooklyn.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@brooklyn.incubator.apache.org Delivered-To: mailing list dev@brooklyn.incubator.apache.org Received: (qmail 45451 invoked by uid 99); 30 Apr 2015 16:16:56 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 30 Apr 2015 16:16:56 +0000 X-ASF-Spam-Status: No, hits=0.0 required=5.0 tests= X-Spam-Check-By: apache.org Received-SPF: error (nike.apache.org: local policy) Received: from [54.76.25.247] (HELO mx1-eu-west.apache.org) (54.76.25.247) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 30 Apr 2015 16:16:30 +0000 Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-eu-west.apache.org (ASF Mail Server at mx1-eu-west.apache.org) with SMTP id 5AB042D1A0 for ; Thu, 30 Apr 2015 16:16:08 +0000 (UTC) Received: (qmail 39309 invoked by uid 99); 30 Apr 2015 16:16:07 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 30 Apr 2015 16:16:07 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 400C8E0061; Thu, 30 Apr 2015 16:16:07 +0000 (UTC) From: neykov To: dev@brooklyn.incubator.apache.org Reply-To: dev@brooklyn.incubator.apache.org References: In-Reply-To: Subject: [GitHub] incubator-brooklyn pull request: add support to control java versi... Content-Type: text/plain Message-Id: <20150430161607.400C8E0061@git1-us-west.apache.org> Date: Thu, 30 Apr 2015 16:16:07 +0000 (UTC) X-Virus-Checked: Checked by ClamAV on apache.org Github user neykov commented on a diff in the pull request: https://github.com/apache/incubator-brooklyn/pull/619#discussion_r29444340 --- Diff: software/base/src/main/java/brooklyn/entity/java/JavaSoftwareProcessSshDriver.java --- @@ -272,69 +273,24 @@ public String getJmxContext() { } /** - * Checks for the presence of Java 6 or 7 on the entity's location, installing if necessary. - * @return true if Java 6 or 7 was found on the machine or if it was installed correctly, otherwise false. + * Checks for the presence of Java on the entity's location, installing if necessary. + * @return true if the required version of Java was found on the machine or if it was installed correctly, + * otherwise false. */ - protected boolean checkForAndInstallJava6or7() { - Optional version = getCurrentJavaVersion(); - if (version.isPresent() && (version.get().startsWith("1.8") || version.get().startsWith("1.7") || version.get().startsWith("1.6"))) { - log.debug("Java version {} already installed at {}@{}", new Object[]{version.get(), getEntity(), getLocation()}); - return true; - } else { - // Let's hope not! - if (version.isPresent()) { - log.debug("Found old Java version {} on {}@{}. Going to install latest Java version.", - new Object[]{version.get(), getEntity(), getLocation()}); - } - return tryJavaInstall("latest", BashCommands.installJava7Or6OrFail()) == 0; - } - } - - /** - * Checks for the presence of Java 7 or 8 on the entity's location, installing if necessary. - * @return true if Java 7 or 8 was found on the machine or if it was installed correctly, otherwise false. - */ - protected boolean checkForAndInstallJava7or8() { - Optional version = getCurrentJavaVersion(); - if (version.isPresent() && (version.get().startsWith("1.8") || version.get().startsWith("1.7"))) { - log.debug("Java version {} already installed at {}@{}", new Object[]{version.get(), getEntity(), getLocation()}); - return true; - } else { - // Let's hope not! - if (version.isPresent()) { - log.debug("Found old Java version {} on {}@{}. Going to install latest Java version.", - new Object[]{version.get(), getEntity(), getLocation()}); + protected boolean checkForAndInstallJava(String requiredVersion) { + List requiredVersionParts = Splitter.on(".").splitToList(requiredVersion); + int requiredJavaMinor = Integer.valueOf(requiredVersionParts.get(1)); --- End diff -- Worth checking the length in case invalid format was supplied with more information exception message. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastructure@apache.org or file a JIRA ticket with INFRA. ---