package com.github.otbproject.otbproject.util.version;

public class AppVersion {
    private static Version LATEST;
    private static final Version CURRENT = getCurrentVersion();

    private static String getVersionString() {
        return AppVersion.class.getPackage().getImplementationVersion();
    }

    public static Version current() {
        return CURRENT;
    }

    private static Version getCurrentVersion() {
        Version version;
        try {
            version = Version.parseVersion(getVersionString());
        } catch (Version.ParseException e) {
            e.printStackTrace(); // because logger not initialized, and should also never fail in actual execution
            version = Version.create(0, 0, 0, Version.Type.RELEASE);
        }
        return version;
    }

    public static Version latest() {
        if (LATEST == null) {
            getLatest();
        }
        return LATEST;
    }

    private static synchronized void getLatest() {
        if (LATEST == null) {
            LATEST = Version.parseAsOptional(Versions.lookupLatestGithubVersion("otbproject"))
                    .orElse(Version.create(0, 0, 0, Version.Type.RELEASE));
        }
    }
}

@@ -94,24 +94,30 @@
  static 
+final 
 Version 
 LATEST;%0A
@@ -112,79 +112,283 @@
 ion 
-LATEST;%0A    private static final Version CURRENT = getCurrentVersion();
+CURRENT = getCurrentVersion();%0A%0A    private static class LatestVersionHolder %7B%0A        private static final Version FIELD = Version.parseAsOptional(Versions.lookupLatestGithubVersion(%22otbproject%22))%0A                .orElse(Version.create(0, 0, 0, Version.Type.RELEASE));%0A    %7D
 %0A%0A  
@@ -1052,356 +1052,41 @@
     
-if (LATEST == null) %7B%0A            getLatest();%0A        %7D%0A        return LATEST;%0A    %7D%0A%0A    private static synchronized void getLatest() %7B%0A        if (LATEST == null) %7B%0A            LATEST = Version.parseAsOptional(Versions.lookupLatestGithubVersion(%22otbproject%22))%0A                    .orElse(Version.create(0, 0, 0, Version.Type.RELEASE));%0A        %7D
+return LatestVersionHolder.FIELD;
 %0A   

Fix concurrency issue with AppVersion.latest()