diff --git a/core/src/main/java/hudson/model/AbstractProject.java b/core/src/main/java/hudson/model/AbstractProject.java index 099d0d190ded3..cceff9c42b19d 100644 --- a/core/src/main/java/hudson/model/AbstractProject.java +++ b/core/src/main/java/hudson/model/AbstractProject.java @@ -351,7 +351,10 @@ public EnvVars getEnvironment(@CheckForNull Node node, @NonNull TaskListener lis @Override protected void performDelete() throws IOException, InterruptedException { // prevent a new build while a delete operation is in progress - makeDisabled(true); + if (supportsMakeDisabled()) { + setDisabled(true); + Jenkins.get().getQueue().cancel(this); + } FilePath ws = getWorkspace(); if (ws != null) { Node on = getLastBuiltOn(); diff --git a/core/src/main/java/hudson/util/XStream2.java b/core/src/main/java/hudson/util/XStream2.java index 5c6ebc566731d..cf1b5e9bcaabe 100644 --- a/core/src/main/java/hudson/util/XStream2.java +++ b/core/src/main/java/hudson/util/XStream2.java @@ -475,12 +475,8 @@ protected Class computeValue(Class type) { return computeConverterClass(type); } }; - private final ClassValue cache = new ClassValue() { - @Override - protected Converter computeValue(Class type) { - return computeConverter(type); - } - }; + private final ConcurrentHashMap, Converter> cache = + new ConcurrentHashMap<>(); private AssociatedConverterImpl(XStream xstream) { this.xstream = xstream; @@ -491,7 +487,9 @@ private Converter findConverter(@CheckForNull Class t) { if (t == null) { return null; } - return cache.get(t); + Converter result = cache.computeIfAbsent(t, unused -> computeConverter(t)); + // ConcurrentHashMap does not allow null, so use this object to represent null + return result == this ? null : result; } @CheckForNull @@ -515,7 +513,8 @@ private static Class computeConverterClass(@NonNull private Converter computeConverter(@NonNull Class t) { Class cl = classCache.get(t); if (cl == null) { - return null; + // See above.. this object in cache represents null + return this; } try { Constructor c = cl.getConstructors()[0]; diff --git a/core/src/main/java/jenkins/monitor/JavaVersionRecommendationAdminMonitor.java b/core/src/main/java/jenkins/monitor/JavaVersionRecommendationAdminMonitor.java index 133ea2b377313..9d32eb45a771a 100644 --- a/core/src/main/java/jenkins/monitor/JavaVersionRecommendationAdminMonitor.java +++ b/core/src/main/java/jenkins/monitor/JavaVersionRecommendationAdminMonitor.java @@ -24,13 +24,21 @@ package jenkins.monitor; +import edu.umd.cs.findbugs.annotations.NonNull; import hudson.Extension; import hudson.model.AdministrativeMonitor; import hudson.security.Permission; import java.io.IOException; +import java.time.LocalDate; +import java.time.Period; +import java.time.ZoneId; +import java.util.Collections; +import java.util.Date; +import java.util.Locale; +import java.util.NavigableMap; +import java.util.TreeMap; import jenkins.model.Jenkins; import jenkins.util.SystemProperties; -import jenkins.util.java.JavaUtils; import org.jenkinsci.Symbol; import org.kohsuke.accmod.Restricted; import org.kohsuke.accmod.restrictions.DoNotUse; @@ -46,15 +54,68 @@ @Symbol("javaVersionRecommendation") public class JavaVersionRecommendationAdminMonitor extends AdministrativeMonitor { + /** + * The list of supported Java long-term support (LTS) releases. The key is the {@link + * Runtime.Version#feature() feature-release counter}. The value is the date the Jenkins project + * drops support for that release, which must be before the date the Eclipse Temurin project + * drops support for that release. This list must remain synchronized with the one in {@code + * executable.Main}. + * + *

To add support for a Java version: + * + *

    + *
  • Update {@link #SUPPORTED_JAVA_VERSIONS} + *
  • Update {@code executable.Main#SUPPORTED_JAVA_VERSIONS} + *
  • Update the {@code Jenkinsfile} for core and core components + *
  • Update the {@code Jenkinsfile} for PCT + *
  • Update the {@code Jenkinsfile} for ATH + *
  • Update the archetype and the {@code Jenkinsfile} for critical plugins + *
+ * + * @see Eclipse Temurin End of Life + */ + private static final NavigableMap SUPPORTED_JAVA_VERSIONS; + + static { + NavigableMap supportedVersions = new TreeMap<>(); + supportedVersions.put(11, LocalDate.of(2024, 9, 30)); // Temurin: 2024-10-31 + supportedVersions.put(17, LocalDate.of(2026, 3, 31)); // Temurin: 2027-10-31 + supportedVersions.put(21, LocalDate.of(2027, 9, 30)); // Temurin: 2029-09-30 + SUPPORTED_JAVA_VERSIONS = Collections.unmodifiableNavigableMap(supportedVersions); + } + public JavaVersionRecommendationAdminMonitor() { - super(JavaVersionRecommendationAdminMonitor.class.getName() + "-3"); + super(getId()); + } + + /** + * Compute the ID for the administrative monitor. The ID includes the Java version, EOL date, + * and severity so that changes to the EOL date for a given Java version will invalidate + * previous dismissals of the administrative monitor and so that users who decline to upgrade + * after the first warning get a second warning when they are closer to the deadline. + * + * @return The computed ID. + */ + private static String getId() { + StringBuilder id = new StringBuilder(); + id.append(JavaVersionRecommendationAdminMonitor.class.getName()); + LocalDate endOfLife = getEndOfLife(); + if (endOfLife.isBefore(LocalDate.MAX)) { + id.append('-'); + id.append(Runtime.version().feature()); + id.append('-'); + id.append(endOfLife); + id.append('-'); + id.append(getSeverity()); + } + return id.toString(); } private static Boolean disabled = SystemProperties.getBoolean(JavaVersionRecommendationAdminMonitor.class.getName() + ".disabled", false); @Override public boolean isActivated() { - return !disabled && JavaUtils.isRunningWithJava8OrBelow(); + return !disabled && getDeprecationPeriod().getYears() < 2; } @Override @@ -78,8 +139,55 @@ public HttpResponse doAct(@QueryParameter String no) throws IOException { disable(true); return HttpResponses.forwardToPreviousPage(); } else { - return new HttpRedirect("https://www.jenkins.io/redirect/upgrading-jenkins-java-version-8-to-11"); + return new HttpRedirect("https://jenkins.io/redirect/java-support/"); } } + @NonNull + private static LocalDate getEndOfLife() { + LocalDate endOfLife = SUPPORTED_JAVA_VERSIONS.get(Runtime.version().feature()); + return endOfLife != null ? endOfLife : LocalDate.MAX; + } + + @NonNull + private static Period getDeprecationPeriod() { + return Period.between(LocalDate.now(), getEndOfLife()); + } + + @NonNull + private static Severity getSeverity() { + return getDeprecationPeriod().getYears() < 1 ? Severity.DANGER : Severity.WARNING; + } + + /** + * @return The current feature-release counter. + * @see Runtime#version() + */ + @Restricted(DoNotUse.class) + public int getJavaVersion() { + return Runtime.version().feature(); + } + + /** + * @return The end of life date for the current Java version in the system default time zone. + */ + @Restricted(DoNotUse.class) + public Date getEndOfLifeAsDate() { + return Date.from(getEndOfLife().atStartOfDay(ZoneId.systemDefault()).toInstant()); + } + + /** + * @return The severity of the administrative monitor, used to set the background color of the alert. + */ + @Restricted(DoNotUse.class) + public String getSeverityAsString() { + return getSeverity().toString().toLowerCase(Locale.US); + } + + private enum Severity { + SUCCESS, + INFO, + WARNING, + DANGER + } } diff --git a/core/src/main/resources/jenkins/monitor/JavaVersionRecommendationAdminMonitor/description.jelly b/core/src/main/resources/jenkins/monitor/JavaVersionRecommendationAdminMonitor/description.jelly index bb405e931933b..f8a1ffe016830 100644 --- a/core/src/main/resources/jenkins/monitor/JavaVersionRecommendationAdminMonitor/description.jelly +++ b/core/src/main/resources/jenkins/monitor/JavaVersionRecommendationAdminMonitor/description.jelly @@ -1,4 +1,4 @@ - ${%blurb} + ${%blurb(it.javaVersion)} diff --git a/core/src/main/resources/jenkins/monitor/JavaVersionRecommendationAdminMonitor/description.properties b/core/src/main/resources/jenkins/monitor/JavaVersionRecommendationAdminMonitor/description.properties index 543b42b1caef7..202d256764d82 100644 --- a/core/src/main/resources/jenkins/monitor/JavaVersionRecommendationAdminMonitor/description.properties +++ b/core/src/main/resources/jenkins/monitor/JavaVersionRecommendationAdminMonitor/description.properties @@ -1 +1 @@ -blurb = Recommends Java 11 for running Jenkins if an older version is used. +blurb = Recommends Java {0,number} for running Jenkins if an older version is used. diff --git a/core/src/main/resources/jenkins/monitor/JavaVersionRecommendationAdminMonitor/description_pt_BR.properties b/core/src/main/resources/jenkins/monitor/JavaVersionRecommendationAdminMonitor/description_pt_BR.properties index 1a1e3f070d5a1..5f7de25760275 100644 --- a/core/src/main/resources/jenkins/monitor/JavaVersionRecommendationAdminMonitor/description_pt_BR.properties +++ b/core/src/main/resources/jenkins/monitor/JavaVersionRecommendationAdminMonitor/description_pt_BR.properties @@ -20,4 +20,4 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -blurb=Recomenda o Java 11 para executar o Jenkins se uma versão anterior está em uso. +blurb=Recomenda o Java {0,number} para executar o Jenkins se uma versão anterior está em uso. diff --git a/core/src/main/resources/jenkins/monitor/JavaVersionRecommendationAdminMonitor/description_ru.properties b/core/src/main/resources/jenkins/monitor/JavaVersionRecommendationAdminMonitor/description_ru.properties index 22cb725072945..58ae2d6173f49 100644 --- a/core/src/main/resources/jenkins/monitor/JavaVersionRecommendationAdminMonitor/description_ru.properties +++ b/core/src/main/resources/jenkins/monitor/JavaVersionRecommendationAdminMonitor/description_ru.properties @@ -1 +1 @@ -blurb = Рекомендует запускать Jenkins на Java 11, если используется более старая версия. \ No newline at end of file +blurb = Рекомендует запускать Jenkins на Java {0,number}, если используется более старая версия. diff --git a/core/src/main/resources/jenkins/monitor/JavaVersionRecommendationAdminMonitor/description_zh_TW.properties b/core/src/main/resources/jenkins/monitor/JavaVersionRecommendationAdminMonitor/description_zh_TW.properties index 2ed16e322ce48..ae4e29dcf6ecc 100644 --- a/core/src/main/resources/jenkins/monitor/JavaVersionRecommendationAdminMonitor/description_zh_TW.properties +++ b/core/src/main/resources/jenkins/monitor/JavaVersionRecommendationAdminMonitor/description_zh_TW.properties @@ -1 +1 @@ -blurb=若您使用的 Java 版本低於 11,推薦您改用 Java 11 來執行 Jenkins。 +blurb=若您使用的 Java 版本低於 {0,number},推薦您改用 Java {0,number} 來執行 Jenkins。 diff --git a/core/src/main/resources/jenkins/monitor/JavaVersionRecommendationAdminMonitor/message.jelly b/core/src/main/resources/jenkins/monitor/JavaVersionRecommendationAdminMonitor/message.jelly index d11f46a6b5409..0265cf145a723 100644 --- a/core/src/main/resources/jenkins/monitor/JavaVersionRecommendationAdminMonitor/message.jelly +++ b/core/src/main/resources/jenkins/monitor/JavaVersionRecommendationAdminMonitor/message.jelly @@ -24,15 +24,14 @@ THE SOFTWARE. - -
+
-

${%Recommended_Java_Version_Heading(currentRuntimeJavaVersion)}

- ${%Recommended_Java_Version(currentRuntimeJavaVersion)} +

${%Recommended_Java_Version_Heading(it.javaVersion)}

+ ${%Recommended_Java_Version(it.javaVersion, it.endOfLifeAsDate)}
diff --git a/core/src/main/resources/jenkins/monitor/JavaVersionRecommendationAdminMonitor/message.properties b/core/src/main/resources/jenkins/monitor/JavaVersionRecommendationAdminMonitor/message.properties index e3b0c4fe5f832..a2bb300c7843b 100644 --- a/core/src/main/resources/jenkins/monitor/JavaVersionRecommendationAdminMonitor/message.properties +++ b/core/src/main/resources/jenkins/monitor/JavaVersionRecommendationAdminMonitor/message.properties @@ -1,5 +1,3 @@ -Recommended_Java_Version_Heading=Java {0} end of life in Jenkins -Recommended_Java_Version=

You are running Jenkins on Java {0}, support for which will end on or after June 21, 2022. \ - This is earlier than a previously announced date.

\ -

The Long Term Support (LTS) line of Jenkins will continue support till September 2022.

\ -

Please refer to the documentation for details on upgrading to Java 11.

+Recommended_Java_Version_Heading=Java {0,number} end of life in Jenkins +Recommended_Java_Version=You are running Jenkins on Java {0,number}, support for which will end on or after {1,date}. \ + Refer to the documentation for more details. diff --git a/core/src/main/resources/jenkins/monitor/JavaVersionRecommendationAdminMonitor/message_pt_BR.properties b/core/src/main/resources/jenkins/monitor/JavaVersionRecommendationAdminMonitor/message_pt_BR.properties index 25c54f9c654ad..0c6a0bc82ea59 100644 --- a/core/src/main/resources/jenkins/monitor/JavaVersionRecommendationAdminMonitor/message_pt_BR.properties +++ b/core/src/main/resources/jenkins/monitor/JavaVersionRecommendationAdminMonitor/message_pt_BR.properties @@ -22,10 +22,6 @@ More\ Info=Mais informação Dismiss=Dispensar -Recommended_Java_Version=

Você está executando o Jenkins com o Java {0}, cujo \ - suporte será encerrado em 21 de junho de 2022. Isto é antes do que a data previamente anunciada.

\ -

A linha de suporte de longo período (LTS) do Jenkins continuará a suportar esta \ - versão até setembro de 2022.

Por favor se refira a \ - \ - a documentação para maiores detalhes sobre atualizar para o Java versão 11.

-Recommended_Java_Version_Heading=Fim de suporte ao Java {0} pelo Jenkins +Recommended_Java_Version=Você está executando o Jenkins com o Java {0,number}, cujo suporte será encerrado em {1,date}. \ + Se refira a a documentação para maiores detalhes. +Recommended_Java_Version_Heading=Fim de suporte ao Java {0,number} pelo Jenkins diff --git a/core/src/main/resources/jenkins/monitor/JavaVersionRecommendationAdminMonitor/message_ru.properties b/core/src/main/resources/jenkins/monitor/JavaVersionRecommendationAdminMonitor/message_ru.properties index b07389f4627b6..75d24bd456782 100644 --- a/core/src/main/resources/jenkins/monitor/JavaVersionRecommendationAdminMonitor/message_ru.properties +++ b/core/src/main/resources/jenkins/monitor/JavaVersionRecommendationAdminMonitor/message_ru.properties @@ -1,11 +1,5 @@ -Recommended_Java_Version_Heading=Конец поддержки Java {0} в Jenkins -Recommended_Java_Version=

Вы запустили Jenkins на Java {0}. Её поддержка будет \ - остановлена 21 июня 2022. \ - Это раньше, чем дата, объявленная ранее.

\ -

Долгосрочно поддерживаемые (LTS) релизы Jenkins будут поддерживать её до сентября \ - 2022.

\ -

Пожалуйста, смотрите детали об обновлении до Java 11 в \ - документации.

+Recommended_Java_Version_Heading=Конец поддержки Java {0,number} в Jenkins +Recommended_Java_Version=Вы запустили Jenkins на Java {0,number}. Её поддержка будет остановлена {1,date}. \ + Смотрите детали в документации. More\ Info=Подробнее Dismiss=Убрать diff --git a/test/pom.xml b/test/pom.xml index eef40eacece43..bf19f24a94bcf 100644 --- a/test/pom.xml +++ b/test/pom.xml @@ -121,7 +121,7 @@ THE SOFTWARE. ${project.groupId} jenkins-test-harness - 2064.vcd3b_b_8f3f2b_a_ + 2085.va_c531db_287b_d test diff --git a/war/src/main/java/executable/Main.java b/war/src/main/java/executable/Main.java index 1a537e46825ee..9812f3d5b9e1d 100644 --- a/war/src/main/java/executable/Main.java +++ b/war/src/main/java/executable/Main.java @@ -72,6 +72,10 @@ */ public class Main { + /** + * This list must remain synchronized with the one in {@code + * JavaVersionRecommendationAdminMonitor}. + */ private static final NavigableSet SUPPORTED_JAVA_VERSIONS = new TreeSet<>(Arrays.asList(11, 17, 21));