This is an automated email from the ASF dual-hosted git repository.
neilcsmith pushed a commit to branch delivery
in repository https://gitbox.apache.org/repos/asf/netbeans.git
The following commit(s) were added to refs/heads/delivery by this push:
new e75a76521f JDK Downloader: fix current GA/EA values
new 9eb9def620 Merge pull request #6590 from
mbien/jdk-downloader-current-version-fix_delivery
e75a76521f is described below
commit e75a76521f57590ffd87931563510991151a0790
Author: Michael Bien <[email protected]>
AuthorDate: Thu Oct 19 13:19:21 2023 +0200
JDK Downloader: fix current GA/EA values
use better caching to avoid per-call latency overhead
---
.../org/netbeans/modules/java/disco/Client.java | 70 ++++++++++++----------
.../modules/java/disco/SelectPackagePanel.java | 6 +-
2 files changed, 41 insertions(+), 35 deletions(-)
diff --git a/java/java.disco/src/org/netbeans/modules/java/disco/Client.java
b/java/java.disco/src/org/netbeans/modules/java/disco/Client.java
index e6f027d66f..539627f69c 100644
--- a/java/java.disco/src/org/netbeans/modules/java/disco/Client.java
+++ b/java/java.disco/src/org/netbeans/modules/java/disco/Client.java
@@ -38,13 +38,13 @@ import io.foojay.api.discoclient.pkg.MajorVersion;
import io.foojay.api.discoclient.pkg.Pkg;
import io.foojay.api.discoclient.pkg.Scope;
import io.foojay.api.discoclient.util.PkgInfo;
+import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.Future;
import java.util.stream.Collectors;
-
-import static java.util.Arrays.asList;
+import java.util.stream.Stream;
public class Client {
@@ -54,6 +54,8 @@ public class Client {
private List<MajorVersion> majorVersions;
private List<Distribution> distributions;
+ private Client() {}
+
public static Client getInstance() {
return INSTANCE;
}
@@ -65,35 +67,51 @@ public class Client {
return client;
}
- private Client() {
+ public synchronized List<MajorVersion> getAllMajorVersions() {
+ if (majorVersions == null) {
+ majorVersions = Collections.unmodifiableList(new
ArrayList<>(getDisco().getAllMajorVersions(true)));
+ }
+ return majorVersions;
+ }
+
+ public synchronized List<Distribution> getDistributions() {
+ if (distributions == null) {
+ distributions = Collections.unmodifiableList(
+ getDisco().getDistributions().stream()
+ .filter(distribution ->
distribution.getScopes().contains(Scope.BUILD_OF_OPEN_JDK))
+ .filter(distribution ->
distribution.getScopes().contains(Scope.PUBLIC))
+ .collect(Collectors.toList())
+ );
+ }
+ return distributions;
}
/**
* Returns all major versions which are still maintained (excludes EA
releases).
*/
- public synchronized final List<MajorVersion>
getAllMaintainedMajorVersions() {
- if (majorVersions == null) {
- majorVersions = getDisco().getAllMajorVersions(
- Optional.of(true), // maintained
- Optional.of(false), // EA
- Optional.of(true), // GA
- Optional.of(false)); // build
- }
- return majorVersions;
+ public Stream<MajorVersion> getAllMaintainedMajorVersions() {
+ return getAllMajorVersions().stream()
+ .filter(v -> v.isEarlyAccessOnly() != null &&
!v.isEarlyAccessOnly())
+ .filter(MajorVersion::isMaintained);
}
- public synchronized MajorVersion getLatestLts(boolean includeEA) {
- return getDisco().getLatestLts(includeEA);
+ public MajorVersion getLatestGAVersion() {
+ return getAllMaintainedMajorVersions()
+ .findFirst()
+ .orElse(new MajorVersion(21));
}
- public synchronized MajorVersion getLatestSts(boolean includeEA) {
- return getDisco().getLatestSts(includeEA);
+ public MajorVersion getLatestEAVersion() {
+ return getAllMajorVersions().stream()
+ .filter(v -> v.isEarlyAccessOnly() != null &&
v.isEarlyAccessOnly())
+ .findFirst()
+ .orElse(new MajorVersion(21));
}
public synchronized List<Pkg> getPkgs(final Distribution distribution,
final VersionNumber versionNumber, final Latest latest, final OperatingSystem
operatingSystem,
final Architecture architecture, final ArchiveType archiveType,
final PackageType packageType,
final boolean ea, final boolean javafxBundled) {
- return getDisco().getPkgs(asList(distribution),
+ return getDisco().getPkgs(List.of(distribution),
versionNumber,
latest,
operatingSystem,
@@ -104,26 +122,14 @@ public class Client {
packageType,
javafxBundled,
/*directlyDownloadable*/ true,
- ea ? asList(ReleaseStatus.GA, ReleaseStatus.EA) :
asList(ReleaseStatus.GA),
+ ea ? List.of(ReleaseStatus.GA, ReleaseStatus.EA) :
List.of(ReleaseStatus.GA),
TermOfSupport.NONE,
- asList(Scope.PUBLIC),
+ List.of(Scope.PUBLIC),
null
);
}
- public synchronized List<Distribution> getDistributions() {
- if (distributions == null) {
- distributions =
Collections.unmodifiableList(getDisco().getDistributions()
- .stream()
- .filter(distribution ->
distribution.getScopes().contains(Scope.BUILD_OF_OPEN_JDK))
- .filter(distribution ->
distribution.getScopes().contains(Scope.PUBLIC))
- .collect(Collectors.toList())
- );
- }
- return distributions;
- }
-
- public synchronized Optional<Distribution> getDistribution(String text) {
+ public Optional<Distribution> getDistribution(String text) {
return getDistributions().stream()
.filter(d -> d.getSynonyms().contains(text))
.findFirst();
diff --git
a/java/java.disco/src/org/netbeans/modules/java/disco/SelectPackagePanel.java
b/java/java.disco/src/org/netbeans/modules/java/disco/SelectPackagePanel.java
index e0083d38ce..8d861e5411 100644
---
a/java/java.disco/src/org/netbeans/modules/java/disco/SelectPackagePanel.java
+++
b/java/java.disco/src/org/netbeans/modules/java/disco/SelectPackagePanel.java
@@ -128,11 +128,11 @@ public class SelectPackagePanel extends FirstPanel {
//loading stuff when ui shown
submit(() -> {
int minVersion = 6;
- int maxVersion = discoClient.getLatestSts(true).getAsInt();
- int current = discoClient.getLatestSts(false).getAsInt();
+ int maxVersion = discoClient.getLatestEAVersion().getAsInt();
+ int current = discoClient.getLatestGAVersion().getAsInt();
// limit to LTS + current
- Map<Integer, TermOfSupport> maintainedVersions =
discoClient.getAllMaintainedMajorVersions().stream()
+ Map<Integer, TermOfSupport> maintainedVersions =
discoClient.getAllMaintainedMajorVersions()
.filter(v -> v.getAsInt() >= minVersion && v.getAsInt() <=
current) // defensive filter, the API returned an EA JDK as released
.filter(v -> v.getAsInt() == current ||
v.getTermOfSupport() == TermOfSupport.LTS)
.collect(Collectors.toMap(MajorVersion::getAsInt,
MajorVersion::getTermOfSupport));
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists