Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/main/java/io/foojay/api/distribution/OracleOpenJDK.java
Original file line number Diff line number Diff line change
Expand Up @@ -972,12 +972,17 @@ private List<Pkg> extractPackagesFromHtml(final String html, final boolean isRel
ArchiveType archiveType = Helper.getFileEnding(filename);
TermOfSupport termOfSupport = Helper.getTermOfSupport(versionNumber);
ReleaseStatus releaseStatus = (href.contains("/GA/") || href.contains("/ga/")) ? ReleaseStatus.GA : ReleaseStatus.EA;
if (isReleaseCandidate) { releaseStatus = EA; }
if (isReleaseCandidate || Helper.isTooEarlyForGA(versionNumber.getFeature().getAsInt())) { releaseStatus = EA; }
String downloadLink = href.replaceAll("\"", "").replace("href=", "");
String checksumUri = Helper.isUriValid(downloadLink + ".sha256") ? downloadLink + ".sha256" : "";

// Oracle keeps filename and download link when a release candidate becomes GA, only the release status changes
if (onlyNewPkgs) {
if (CacheManager.INSTANCE.pkgCache.getPkgs().stream().filter(p -> p.getFilename().equals(filename)).filter(p -> p.getDirectDownloadUri().equals(downloadLink)).count() > 0) { continue; }
final ReleaseStatus statusFound = releaseStatus;
if (CacheManager.INSTANCE.pkgCache.getPkgs().stream()
.filter(p -> p.getFilename().equals(filename))
.filter(p -> p.getDirectDownloadUri().equals(downloadLink))
.anyMatch(p -> p.getReleaseStatus() == statusFound)) { continue; }
}

BUILD_NUMBER_MATCHER.reset(downloadLink);
Expand Down
17 changes: 9 additions & 8 deletions src/main/java/io/foojay/api/util/Helper.java
Original file line number Diff line number Diff line change
Expand Up @@ -857,15 +857,16 @@ public static final String getReleaseDetailsUrl(final Semver semver) {
return releaseDetailsUrl;
}

public static final boolean isTooEarlyForGA(final int featureVersion) {
final LocalDate gaDate = Constants.GA_RELEASE_DATES.get(featureVersion);
return null != gaDate && gaDate.isAfter(LocalDate.now());
}

public static final void checkPkgsForTooEarlyGA(final List<Pkg> pkgs) {
final LocalDate now = LocalDate.now();
Constants.GA_RELEASE_DATES.entrySet()
.stream()
.filter(entry -> entry.getValue().isAfter(now))
.forEach(entry -> pkgs.stream()
.filter(pkg -> pkg.getMajorVersion().getAsInt() == entry.getKey())
.filter(pkg -> pkg.getReleaseStatus() == ReleaseStatus.GA)
.forEach(pkg -> pkg.setReleaseStatus(ReleaseStatus.EA)));
pkgs.stream()
.filter(pkg -> pkg.getReleaseStatus() == ReleaseStatus.GA)
.filter(pkg -> isTooEarlyForGA(pkg.getMajorVersion().getAsInt()))
.forEach(pkg -> pkg.setReleaseStatus(ReleaseStatus.EA));
}

public static final Optional<Semver> getMaxVersionNumber(final BuildScope buildScope, final Integer jdkVersion, final boolean includeEa) {
Expand Down
18 changes: 18 additions & 0 deletions src/test/java/io/foojay/api/util/HelperTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import eu.hansolo.jdktools.PackageType;
import org.junit.jupiter.api.Test;

import java.time.LocalDate;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
Expand Down Expand Up @@ -170,4 +171,21 @@ public void isPositiveIntegerTest() {
final String numberString3 = "text";
assert !Helper.isPositiveInteger(numberString3);
}

@Test
public void tooEarlyForGATest() {
final int futureVersion = 9001;
final int pastVersion = 9002;
final int unknownVersion = 9003;
Constants.GA_RELEASE_DATES.put(futureVersion, LocalDate.now().plusDays(1));
Constants.GA_RELEASE_DATES.put(pastVersion, LocalDate.now());
try {
assert Helper.isTooEarlyForGA(futureVersion);
assert !Helper.isTooEarlyForGA(pastVersion);
assert !Helper.isTooEarlyForGA(unknownVersion);
} finally {
Constants.GA_RELEASE_DATES.remove(futureVersion);
Constants.GA_RELEASE_DATES.remove(pastVersion);
}
}
}