mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Valery Kharseko
11 hours ago 4c7057e45ba8a2f3bc1f0b02b3edf14886fd1956
opendj-cli/src/main/java/com/forgerock/opendj/cli/Utils.java
@@ -384,7 +384,7 @@
     */
    public static void checkJavaVersion() throws ClientException {
        final String version = System.getProperty("java.specification.version");
        if (Float.valueOf(version) < CliConstants.MINIMUM_JAVA_VERSION) {
        if (getJavaSpecificationVersion(version) < CliConstants.MINIMUM_JAVA_VERSION) {
            final String javaBin = System.getProperty("java.home") + File.separator + "bin" + File.separator + "java";
            throw new ClientException(ReturnCode.JAVA_VERSION_INCOMPATIBLE,
                    ERR_INCOMPATIBLE_JAVA_VERSION.get(CliConstants.MINIMUM_JAVA_VERSION, version, javaBin), null);
@@ -392,6 +392,22 @@
    }
    /**
     * Returns the provided java specification version as a number, or zero if it does not hold one,
     * in which case the java version is reported as incompatible rather than failing the check with
     * a runtime exception.
     */
    private static float getJavaSpecificationVersion(final String version) {
        if (version == null) {
            return 0;
        }
        try {
            return Float.parseFloat(version);
        } catch (final NumberFormatException e) {
            return 0;
        }
    }
    /**
     * Returns the default host name.
     *
     * @return The default host name or empty string if the host name cannot be resolved.