From 65656c1630cef620895aa9763323b476ed9c1ffa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20Gond=C5=BEa?= Date: Wed, 1 Mar 2017 19:20:54 +0100 Subject: [PATCH 01/14] Towards 2.46.1 --- cli/pom.xml | 2 +- core/pom.xml | 2 +- pom.xml | 4 ++-- test/pom.xml | 2 +- war/pom.xml | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cli/pom.xml b/cli/pom.xml index 91c4cd86b9..5e08491262 100644 --- a/cli/pom.xml +++ b/cli/pom.xml @@ -5,7 +5,7 @@ org.jenkins-ci.main pom - 2.46 + 2.46.1-SNAPSHOT cli diff --git a/core/pom.xml b/core/pom.xml index d054e545f0..46c07ae68d 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -29,7 +29,7 @@ THE SOFTWARE. org.jenkins-ci.main pom - 2.46 + 2.46.1-SNAPSHOT jenkins-core diff --git a/pom.xml b/pom.xml index e7473ff8ed..249afc7bef 100644 --- a/pom.xml +++ b/pom.xml @@ -33,7 +33,7 @@ THE SOFTWARE. org.jenkins-ci.main pom - 2.46 + 2.46.1-SNAPSHOT pom Jenkins main module @@ -58,7 +58,7 @@ THE SOFTWARE. scm:git:git://github.com/jenkinsci/jenkins.git scm:git:ssh://git@github.com/jenkinsci/jenkins.git https://github.com/jenkinsci/jenkins - jenkins-2.46 + HEAD diff --git a/test/pom.xml b/test/pom.xml index d5f8d599ef..53cdb1bdd8 100644 --- a/test/pom.xml +++ b/test/pom.xml @@ -28,7 +28,7 @@ THE SOFTWARE. org.jenkins-ci.main pom - 2.46 + 2.46.1-SNAPSHOT test diff --git a/war/pom.xml b/war/pom.xml index d6643ccddc..1c6614e045 100644 --- a/war/pom.xml +++ b/war/pom.xml @@ -28,7 +28,7 @@ THE SOFTWARE. org.jenkins-ci.main pom - 2.46 + 2.46.1-SNAPSHOT jenkins-war From a6672a3bbb263eae99e7505c7d9957c55e294301 Mon Sep 17 00:00:00 2001 From: Vincent Latombe Date: Tue, 21 Feb 2017 15:39:09 +0100 Subject: [PATCH 02/14] [FIXED JENKINS-41128] createItem in View not working when posting xml (cherry picked from commit 84d9244520b917629e82b762eb7b7548cf5f6b9f) --- core/src/main/java/hudson/model/ListView.java | 16 ++++- .../test/java/hudson/model/ListViewTest.java | 59 +++++++++++++++++++ .../ListViewTest/addJobUsingAPI/config.xml | 16 +++++ 3 files changed, 88 insertions(+), 3 deletions(-) create mode 100644 test/src/test/resources/hudson/model/ListViewTest/addJobUsingAPI/config.xml diff --git a/core/src/main/java/hudson/model/ListView.java b/core/src/main/java/hudson/model/ListView.java index 32e3779e30..be1483df66 100644 --- a/core/src/main/java/hudson/model/ListView.java +++ b/core/src/main/java/hudson/model/ListView.java @@ -319,16 +319,26 @@ public class ListView extends View implements DirectlyModifiableView { } } + private boolean needToAddToCurrentView(StaplerRequest req) throws ServletException { + String json = req.getParameter("json"); + if (json != null && json.length() > 0) { + // Submitted via UI + JSONObject form = req.getSubmittedForm(); + return form.has("addToCurrentView") && form.getBoolean("addToCurrentView"); + } else { + // Submitted via API + return true; + } + } + @Override @RequirePOST public Item doCreateItem(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException { - JSONObject form = req.getSubmittedForm(); - boolean addToCurrentView = form.has("addToCurrentView") && form.getBoolean("addToCurrentView"); ItemGroup ig = getOwnerItemGroup(); if (ig instanceof ModifiableItemGroup) { TopLevelItem item = ((ModifiableItemGroup)ig).doCreateItem(req, rsp); if (item!=null) { - if (addToCurrentView) { + if (needToAddToCurrentView(req)) { synchronized (this) { jobNames.add(item.getRelativeNameFrom(getOwnerItemGroup())); } diff --git a/test/src/test/java/hudson/model/ListViewTest.java b/test/src/test/java/hudson/model/ListViewTest.java index b2dd439b0b..589a83daa2 100644 --- a/test/src/test/java/hudson/model/ListViewTest.java +++ b/test/src/test/java/hudson/model/ListViewTest.java @@ -37,27 +37,41 @@ import hudson.security.AuthorizationStrategy; import hudson.security.Permission; import java.io.IOException; +import java.io.InputStream; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.HashSet; +import java.util.List; + import org.acegisecurity.Authentication; import static org.junit.Assert.*; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; +import javax.servlet.ReadListener; +import javax.servlet.ServletInputStream; + +import org.apache.commons.io.IOUtils; import org.junit.Rule; import org.junit.Test; +import org.junit.rules.TestName; import org.jvnet.hudson.test.Issue; import org.jvnet.hudson.test.JenkinsRule; import org.jvnet.hudson.test.JenkinsRule.WebClient; import org.jvnet.hudson.test.MockFolder; import org.jvnet.hudson.test.recipes.LocalData; +import org.kohsuke.stapler.StaplerRequest; +import org.kohsuke.stapler.StaplerResponse; import org.xml.sax.SAXException; public class ListViewTest { @Rule public JenkinsRule j = new JenkinsRule(); + @Rule public TestName testName = new TestName(); + @Issue("JENKINS-15309") @LocalData @Test public void nullJobNames() throws Exception { @@ -225,6 +239,26 @@ public class ListViewTest { } assertEquals(Collections.singletonList(p), v.getItems()); } + + @Issue("JENKINS-41128") + @Test public void addJobUsingAPI() throws Exception { + ListView v = new ListView("view", j.jenkins); + j.jenkins.addView(v); + StaplerRequest req = mock(StaplerRequest.class); + StaplerResponse rsp = mock(StaplerResponse.class); + + String configXml = IOUtils.toString(getClass().getResourceAsStream(String.format("%s/%s/config.xml", getClass().getSimpleName(), testName.getMethodName())), "UTF-8"); + + when(req.getMethod()).thenReturn("POST"); + when(req.getParameter("name")).thenReturn("job1"); + when(req.getInputStream()).thenReturn(new Stream(IOUtils.toInputStream(configXml))); + when(req.getContentType()).thenReturn("application/xml"); + v.doCreateItem(req, rsp); + List items = v.getItems(); + assertEquals(1, items.size()); + assertEquals("job1", items.get(0).getName()); + } + private static class AllButViewsAuthorizationStrategy extends AuthorizationStrategy { @Override public ACL getRootACL() { return UNSECURED.getRootACL(); @@ -241,4 +275,29 @@ public class ListViewTest { } } + private static class Stream extends ServletInputStream { + private final InputStream inner; + + public Stream(final InputStream inner) { + this.inner = inner; + } + + @Override + public int read() throws IOException { + return inner.read(); + } + @Override + public boolean isFinished() { + throw new UnsupportedOperationException(); + } + @Override + public boolean isReady() { + throw new UnsupportedOperationException(); + } + @Override + public void setReadListener(ReadListener readListener) { + throw new UnsupportedOperationException(); + } + } + } diff --git a/test/src/test/resources/hudson/model/ListViewTest/addJobUsingAPI/config.xml b/test/src/test/resources/hudson/model/ListViewTest/addJobUsingAPI/config.xml new file mode 100644 index 0000000000..ff565b6b94 --- /dev/null +++ b/test/src/test/resources/hudson/model/ListViewTest/addJobUsingAPI/config.xml @@ -0,0 +1,16 @@ + + + + false + + + true + false + false + false + + false + + + + From 08c5da35d3fafd5cf90143181e07f0d22f4f5d60 Mon Sep 17 00:00:00 2001 From: Oleg Nenashev Date: Fri, 17 Feb 2017 10:17:44 +0300 Subject: [PATCH 03/14] Update remoting to 3.5 https://github.com/jenkinsci/remoting/edit/master/CHANGELOG.md Fixed issues: * [JENKINS-40710](https://issues.jenkins-ci.org/browse/JENKINS-40710) - Match headers case-insensitively in `JnlpAgentEndpointResolver` in order to be compliant with HTTP2 lower-case headers. ([PR #139](https://github.com/jenkinsci/remoting/pull/139), [PR #140](https://github.com/jenkinsci/remoting/pull/140)) * [JENKINS-41513](https://issues.jenkins-ci.org/browse/JENKINS-41513) - Prevent `NullPointerException` in `JnlpAgentEndpointResolver` when receiving a header with `null` name. ([PR #140](https://github.com/jenkinsci/remoting/pull/140)) * [JENKINS-41852](https://issues.jenkins-ci.org/browse/JENKINS-41852) - Fix exported object pinning logic to prevent release due to the integer overflow. ([PR #148](https://github.com/jenkinsci/remoting/pull/148)) Improvements: * [JENKINS-41730](https://issues.jenkins-ci.org/browse/JENKINS-41730) - Add the new `org.jenkinsci.remoting.engine.JnlpAgentEndpointResolver.ignoreJenkinsAgentProtocolsHeader` property, which allows specifying a custom list of supported protocols instead of the one returned by the Jenkins master. ([PR #146](https://github.com/jenkinsci/remoting/pull/146)) * Print the Filesystem Jar Cache directory location in the error message when this cache directory is not writable. ([PR #143](https://github.com/jenkinsci/remoting/pull/143)) * Replace `MimicException` with the older `ProxyException` when serializing non-serializable exceptions thrown by the remote code. ([PR #141](https://github.com/jenkinsci/remoting/pull/141)) * Use OID of the `ClassLoaderProxy` in error message when the proxy cannot be located in the export table. ([PR #147](https://github.com/jenkinsci/remoting/pull/147)) (cherry picked from commit 815da8aa732baa699481828dda67dd5835ba4992) --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 249afc7bef..c19d727c93 100644 --- a/pom.xml +++ b/pom.xml @@ -181,7 +181,7 @@ THE SOFTWARE. org.jenkins-ci.main remoting - 3.4.1 + 3.5 From 3e3806ae1db1b96968631e27ce230637fd469fa7 Mon Sep 17 00:00:00 2001 From: Oleg Nenashev Date: Wed, 8 Mar 2017 16:19:58 +0100 Subject: [PATCH 04/14] [FIXES JENKINS-42371] - Update remoting from 3.5 to 3.7 (#2773) * [FIXES JENKINS-42371] - Update remoting to 3.6 Fixed issues: * [JENKINS-42371](https://issues.jenkins-ci.org/browse/JENKINS-42371) - Properly close the `URLConnection` when parsing connection arguments from the JNLP file. It was causing a descriptor leak in the case of multiple connection attempts. ([PR #152](https://github.com/jenkinsci/remoting/pull/152)) * Remoting 3.6 has been burned (cherry picked from commit b6e4fb4b821eb623993914ecd3c24f8d934802f3) --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c19d727c93..d4d9c7734c 100644 --- a/pom.xml +++ b/pom.xml @@ -181,7 +181,7 @@ THE SOFTWARE. org.jenkins-ci.main remoting - 3.5 + 3.7 From 7e9015d3ea6c7444278a4a71d124eddf7d6b3e04 Mon Sep 17 00:00:00 2001 From: Jesse Glick Date: Mon, 13 Feb 2017 10:44:17 -0500 Subject: [PATCH 05/14] Check for null return values from InstanceIdentityProvider methods. (cherry picked from commit d3791e9a8437127abad1722b9a5c45d82e587498) --- .../main/java/jenkins/slaves/JnlpSlaveAgentProtocol4.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/core/src/main/java/jenkins/slaves/JnlpSlaveAgentProtocol4.java b/core/src/main/java/jenkins/slaves/JnlpSlaveAgentProtocol4.java index 976f44d346..2794382889 100644 --- a/core/src/main/java/jenkins/slaves/JnlpSlaveAgentProtocol4.java +++ b/core/src/main/java/jenkins/slaves/JnlpSlaveAgentProtocol4.java @@ -101,7 +101,13 @@ public class JnlpSlaveAgentProtocol4 extends AgentProtocol { public JnlpSlaveAgentProtocol4() throws KeyStoreException, KeyManagementException, IOException { // prepare our local identity and certificate X509Certificate identityCertificate = InstanceIdentityProvider.RSA.getCertificate(); + if (identityCertificate == null) { + throw new KeyStoreException("no X509Certificate found; perhaps instance-identity is missing or too old"); + } RSAPrivateKey privateKey = InstanceIdentityProvider.RSA.getPrivateKey(); + if (privateKey == null) { + throw new KeyStoreException("no RSAPrivateKey found; perhaps instance-identity is missing or too old"); + } // prepare our keyStore so we can provide our authentication keyStore = KeyStore.getInstance("JKS"); From e2a8c0efd149b4e08bf1c61768f2010fa9dfe8bc Mon Sep 17 00:00:00 2001 From: Jesse Glick Date: Mon, 13 Feb 2017 11:03:44 -0500 Subject: [PATCH 06/14] [JENKINS-41987] Improved message. (cherry picked from commit dbf5efa6ae60c30d00afca61d3fd24f56f2c860c) --- .../src/main/java/jenkins/slaves/JnlpSlaveAgentProtocol4.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/jenkins/slaves/JnlpSlaveAgentProtocol4.java b/core/src/main/java/jenkins/slaves/JnlpSlaveAgentProtocol4.java index 2794382889..cfa4ac8de7 100644 --- a/core/src/main/java/jenkins/slaves/JnlpSlaveAgentProtocol4.java +++ b/core/src/main/java/jenkins/slaves/JnlpSlaveAgentProtocol4.java @@ -102,11 +102,11 @@ public class JnlpSlaveAgentProtocol4 extends AgentProtocol { // prepare our local identity and certificate X509Certificate identityCertificate = InstanceIdentityProvider.RSA.getCertificate(); if (identityCertificate == null) { - throw new KeyStoreException("no X509Certificate found; perhaps instance-identity is missing or too old"); + throw new KeyStoreException("JENKINS-41987: no X509Certificate found; perhaps instance-identity module is missing or too old"); } RSAPrivateKey privateKey = InstanceIdentityProvider.RSA.getPrivateKey(); if (privateKey == null) { - throw new KeyStoreException("no RSAPrivateKey found; perhaps instance-identity is missing or too old"); + throw new KeyStoreException("JENKINS-41987: no RSAPrivateKey found; perhaps instance-identity module is missing or too old"); } // prepare our keyStore so we can provide our authentication From 5f655a59b6d263061d6c5c1d05ac8d5d1d1d391f Mon Sep 17 00:00:00 2001 From: Oleg Nenashev Date: Sat, 18 Feb 2017 23:54:38 +0300 Subject: [PATCH 07/14] Merge pull request #2746 from oleg-nenashev/bug/JENKINS-32820 [JENKINS-32820, JENKINS-42164] - Windows service restart does not retain the build queue (cherry picked from commit 4ab693846ca7a4aa112959a2e92688c3fb9122c3) --- core/src/main/java/hudson/WebAppMain.java | 12 +++++++++--- .../hudson/lifecycle/SolarisSMFLifecycle.java | 15 ++++++++++++--- .../main/java/hudson/lifecycle/UnixLifecycle.java | 15 ++++++++++++--- .../hudson/lifecycle/WindowsServiceLifecycle.java | 9 +++++++++ 4 files changed, 42 insertions(+), 9 deletions(-) diff --git a/core/src/main/java/hudson/WebAppMain.java b/core/src/main/java/hudson/WebAppMain.java index dedd43c890..2e087e0348 100644 --- a/core/src/main/java/hudson/WebAppMain.java +++ b/core/src/main/java/hudson/WebAppMain.java @@ -375,10 +375,16 @@ public class WebAppMain implements ServletContextListener { public void contextDestroyed(ServletContextEvent event) { try (ACLContext old = ACL.as(ACL.SYSTEM)) { - terminated = true; Jenkins instance = Jenkins.getInstanceOrNull(); - if (instance != null) - instance.cleanUp(); + try { + if (instance != null) { + instance.cleanUp(); + } + } catch (Exception e) { + LOGGER.log(Level.SEVERE, "Failed to clean up. Restart will continue.", e); + } + + terminated = true; Thread t = initThread; if (t != null && t.isAlive()) { LOGGER.log(Level.INFO, "Shutting down a Jenkins instance that was still starting up", new Throwable("reason")); diff --git a/core/src/main/java/hudson/lifecycle/SolarisSMFLifecycle.java b/core/src/main/java/hudson/lifecycle/SolarisSMFLifecycle.java index ca90fb83d4..54e3d6c743 100644 --- a/core/src/main/java/hudson/lifecycle/SolarisSMFLifecycle.java +++ b/core/src/main/java/hudson/lifecycle/SolarisSMFLifecycle.java @@ -26,6 +26,8 @@ package hudson.lifecycle; import jenkins.model.Jenkins; import java.io.IOException; +import java.util.logging.Level; +import java.util.logging.Logger; /** * {@link Lifecycle} for Hudson installed as SMF service. @@ -38,9 +40,16 @@ public class SolarisSMFLifecycle extends Lifecycle { */ @Override public void restart() throws IOException, InterruptedException { - Jenkins h = Jenkins.getInstanceOrNull(); // guard against repeated concurrent calls to restart - if (h != null) - h.cleanUp(); + Jenkins jenkins = Jenkins.getInstanceOrNull(); // guard against repeated concurrent calls to restart + try { + if (jenkins != null) { + jenkins.cleanUp(); + } + } catch (Exception e) { + LOGGER.log(Level.SEVERE, "Failed to clean up. Restart will continue.", e); + } System.exit(0); } + + private static final Logger LOGGER = Logger.getLogger(SolarisSMFLifecycle.class.getName()); } diff --git a/core/src/main/java/hudson/lifecycle/UnixLifecycle.java b/core/src/main/java/hudson/lifecycle/UnixLifecycle.java index 5d545a4fe4..1af9c13155 100644 --- a/core/src/main/java/hudson/lifecycle/UnixLifecycle.java +++ b/core/src/main/java/hudson/lifecycle/UnixLifecycle.java @@ -28,6 +28,8 @@ import com.sun.jna.Native; import com.sun.jna.StringArray; import java.io.IOException; +import java.util.logging.Level; +import java.util.logging.Logger; import static hudson.util.jna.GNUCLibrary.*; @@ -65,9 +67,14 @@ public class UnixLifecycle extends Lifecycle { @Override public void restart() throws IOException, InterruptedException { - Jenkins h = Jenkins.getInstanceOrNull(); // guard against repeated concurrent calls to restart - if (h != null) - h.cleanUp(); + Jenkins jenkins = Jenkins.getInstanceOrNull(); // guard against repeated concurrent calls to restart + try { + if (jenkins != null) { + jenkins.cleanUp(); + } + } catch (Exception e) { + LOGGER.log(Level.SEVERE, "Failed to clean up. Restart will continue.", e); + } // close all files upon exec, except stdin, stdout, and stderr int sz = LIBC.getdtablesize(); @@ -96,4 +103,6 @@ public class UnixLifecycle extends Lifecycle { if (args==null) throw new RestartNotSupportedException("Failed to obtain the command line arguments of the process",failedToObtainArgs); } + + private static final Logger LOGGER = Logger.getLogger(UnixLifecycle.class.getName()); } diff --git a/core/src/main/java/hudson/lifecycle/WindowsServiceLifecycle.java b/core/src/main/java/hudson/lifecycle/WindowsServiceLifecycle.java index 4a7e8d2fa9..94066417b0 100644 --- a/core/src/main/java/hudson/lifecycle/WindowsServiceLifecycle.java +++ b/core/src/main/java/hudson/lifecycle/WindowsServiceLifecycle.java @@ -117,6 +117,15 @@ public class WindowsServiceLifecycle extends Lifecycle { @Override public void restart() throws IOException, InterruptedException { + Jenkins jenkins = Jenkins.getInstanceOrNull(); + try { + if (jenkins != null) { + jenkins.cleanUp(); + } + } catch (Exception e) { + LOGGER.log(Level.SEVERE, "Failed to clean up. Restart will continue.", e); + } + File me = getHudsonWar(); File home = me.getParentFile(); From 933a4785afa03354055c6d12a8bb1ce3b8e43b0a Mon Sep 17 00:00:00 2001 From: Daniel Beck Date: Mon, 20 Feb 2017 17:24:31 +0100 Subject: [PATCH 08/14] [FIX JENKINS-41864] Add warning for rare dates Previously, impossible dates caused 100% CPU while Jenkins was trying to find the previous/next occurrence of the date. (cherry picked from commit 6e5225c06b45a3e196c8647dd30275234e57a54c) --- .../main/java/hudson/scheduler/CronTab.java | 13 ++++++++ .../RareOrImpossibleDateException.java | 31 +++++++++++++++++++ .../java/hudson/triggers/TimerTrigger.java | 19 +++++++----- .../hudson/triggers/Messages.properties | 2 ++ 4 files changed, 58 insertions(+), 7 deletions(-) create mode 100644 core/src/main/java/hudson/scheduler/RareOrImpossibleDateException.java diff --git a/core/src/main/java/hudson/scheduler/CronTab.java b/core/src/main/java/hudson/scheduler/CronTab.java index d289dc32ef..9c17bb40e6 100644 --- a/core/src/main/java/hudson/scheduler/CronTab.java +++ b/core/src/main/java/hudson/scheduler/CronTab.java @@ -328,8 +328,14 @@ public final class CronTab { * This method modifies the given calendar and returns the same object. */ public Calendar ceil(Calendar cal) { + Calendar twoYearsFuture = (Calendar) cal.clone(); + twoYearsFuture.add(Calendar.YEAR, 2); OUTER: while (true) { + if (cal.compareTo(twoYearsFuture) > 0) { + // we went at least two years into the future + throw new RareOrImpossibleDateException(); + } for (CalendarField f : CalendarField.ADJUST_ORDER) { int cur = f.valueOf(cal); int next = f.ceil(this,cur); @@ -380,8 +386,15 @@ public final class CronTab { * This method modifies the given calendar and returns the same object. */ public Calendar floor(Calendar cal) { + Calendar twoYearsAgo = (Calendar) cal.clone(); + twoYearsAgo.add(Calendar.YEAR, -2); + OUTER: while (true) { + if (cal.compareTo(twoYearsAgo) < 0) { + // we went at least two years into the past + throw new RareOrImpossibleDateException(); + } for (CalendarField f : CalendarField.ADJUST_ORDER) { int cur = f.valueOf(cal); int next = f.floor(this,cur); diff --git a/core/src/main/java/hudson/scheduler/RareOrImpossibleDateException.java b/core/src/main/java/hudson/scheduler/RareOrImpossibleDateException.java new file mode 100644 index 0000000000..c45d18f808 --- /dev/null +++ b/core/src/main/java/hudson/scheduler/RareOrImpossibleDateException.java @@ -0,0 +1,31 @@ +/* + * The MIT License + * + * Copyright (c) 2017 CloudBees, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package hudson.scheduler; + +import org.kohsuke.accmod.Restricted; +import org.kohsuke.accmod.restrictions.NoExternalUse; + +@Restricted(NoExternalUse.class) +public class RareOrImpossibleDateException extends RuntimeException { +} diff --git a/core/src/main/java/hudson/triggers/TimerTrigger.java b/core/src/main/java/hudson/triggers/TimerTrigger.java index 4380c0797c..da844fa6b6 100644 --- a/core/src/main/java/hudson/triggers/TimerTrigger.java +++ b/core/src/main/java/hudson/triggers/TimerTrigger.java @@ -32,6 +32,7 @@ import hudson.model.Cause; import hudson.model.Item; import hudson.scheduler.CronTabList; import hudson.scheduler.Hash; +import hudson.scheduler.RareOrImpossibleDateException; import hudson.util.FormValidation; import java.text.DateFormat; import java.util.ArrayList; @@ -104,13 +105,17 @@ public class TimerTrigger extends Trigger { } private void updateValidationsForNextRun(Collection validations, CronTabList ctl) { - Calendar prev = ctl.previous(); - Calendar next = ctl.next(); - if (prev != null && next != null) { - DateFormat fmt = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL); - validations.add(FormValidation.ok(Messages.TimerTrigger_would_last_have_run_at_would_next_run_at(fmt.format(prev.getTime()), fmt.format(next.getTime())))); - } else { - validations.add(FormValidation.warning(Messages.TimerTrigger_no_schedules_so_will_never_run())); + try { + Calendar prev = ctl.previous(); + Calendar next = ctl.next(); + if (prev != null && next != null) { + DateFormat fmt = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL); + validations.add(FormValidation.ok(Messages.TimerTrigger_would_last_have_run_at_would_next_run_at(fmt.format(prev.getTime()), fmt.format(next.getTime())))); + } else { + validations.add(FormValidation.warning(Messages.TimerTrigger_no_schedules_so_will_never_run())); + } + } catch (RareOrImpossibleDateException ex) { + validations.add(FormValidation.warning(Messages.TimerTrigger_the_specified_cron_tab_is_rare_or_impossible())); } } } diff --git a/core/src/main/resources/hudson/triggers/Messages.properties b/core/src/main/resources/hudson/triggers/Messages.properties index d01e59aec9..c82efebf15 100644 --- a/core/src/main/resources/hudson/triggers/Messages.properties +++ b/core/src/main/resources/hudson/triggers/Messages.properties @@ -29,5 +29,7 @@ TimerTrigger.MissingWhitespace=You appear to be missing whitespace between * and TimerTrigger.no_schedules_so_will_never_run=No schedules so will never run TimerTrigger.TimerTriggerCause.ShortDescription=Started by timer TimerTrigger.would_last_have_run_at_would_next_run_at=Would last have run at {0}; would next run at {1}. +TimerTrigger.the_specified_cron_tab_is_rare_or_impossible=This cron tab will match dates only rarely (e.g. February 29) or \ + never (e.g. June 31), so this job may be triggered very rarely, if at all. Trigger.init=Initializing timer for triggers SCMTrigger.AdministrativeMonitorImpl.DisplayName=Too Many SCM Polling Threads From e025dc942000fdbe04a1b091f164ed8f2bd9fd04 Mon Sep 17 00:00:00 2001 From: Daniel Beck Date: Sat, 25 Feb 2017 20:56:25 +0100 Subject: [PATCH 09/14] [JENKINS-41864] More Javadoc, rephrase warning message (cherry picked from commit d1c21484c3658b93bffa4de51749ab60b2c4ff11) --- .../main/java/hudson/scheduler/CronTab.java | 10 +++++++-- .../RareOrImpossibleDateException.java | 22 +++++++++++++++++++ .../hudson/triggers/Messages.properties | 2 +- 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/hudson/scheduler/CronTab.java b/core/src/main/java/hudson/scheduler/CronTab.java index 9c17bb40e6..81fa5075c9 100644 --- a/core/src/main/java/hudson/scheduler/CronTab.java +++ b/core/src/main/java/hudson/scheduler/CronTab.java @@ -326,6 +326,9 @@ public final class CronTab { * See {@link #ceil(long)}. * * This method modifies the given calendar and returns the same object. + * + * @throws RareOrImpossibleDateException if the date isn't hit in the 2 years after it indicates an impossible + * (e.g. Jun 31) date, or at least a date too rare to be useful. This addresses JENKINS-41864 and was added in TODO */ public Calendar ceil(Calendar cal) { Calendar twoYearsFuture = (Calendar) cal.clone(); @@ -333,7 +336,7 @@ public final class CronTab { OUTER: while (true) { if (cal.compareTo(twoYearsFuture) > 0) { - // we went at least two years into the future + // we went too far into the future throw new RareOrImpossibleDateException(); } for (CalendarField f : CalendarField.ADJUST_ORDER) { @@ -384,6 +387,9 @@ public final class CronTab { * See {@link #floor(long)} * * This method modifies the given calendar and returns the same object. + * + * @throws RareOrImpossibleDateException if the date isn't hit in the 2 years before it indicates an impossible + * (e.g. Jun 31) date, or at least a date too rare to be useful. This addresses JENKINS-41864 and was added in TODO */ public Calendar floor(Calendar cal) { Calendar twoYearsAgo = (Calendar) cal.clone(); @@ -392,7 +398,7 @@ public final class CronTab { OUTER: while (true) { if (cal.compareTo(twoYearsAgo) < 0) { - // we went at least two years into the past + // we went too far into the past throw new RareOrImpossibleDateException(); } for (CalendarField f : CalendarField.ADJUST_ORDER) { diff --git a/core/src/main/java/hudson/scheduler/RareOrImpossibleDateException.java b/core/src/main/java/hudson/scheduler/RareOrImpossibleDateException.java index c45d18f808..7bd9d2562f 100644 --- a/core/src/main/java/hudson/scheduler/RareOrImpossibleDateException.java +++ b/core/src/main/java/hudson/scheduler/RareOrImpossibleDateException.java @@ -26,6 +26,28 @@ package hudson.scheduler; import org.kohsuke.accmod.Restricted; import org.kohsuke.accmod.restrictions.NoExternalUse; +import java.util.Calendar; + +/** + * This exception is thrown when trying to determine the previous or next occurrence of a given date determines + * that it's not happened, or going to happen, within some time period (e.g. within the next year). + * + *

This can typically have a few different reasons:

+ * + *
    + *
  • The date is impossible. For example, June 31 does never happen, so 0 0 31 6 * will never happen
  • + *
  • The date happens only rarely + *
      + *
    • February 29 being the obvious one
    • + *
    • Cron tab patterns specifying all of month, day of month, and day of week can also occur so rarely to trigger this exception
    • + *
    + *
  • + *
+ * + * @see CronTab#floor(Calendar) + * @see CronTab#ceil(Calendar) + * @since TODO + */ @Restricted(NoExternalUse.class) public class RareOrImpossibleDateException extends RuntimeException { } diff --git a/core/src/main/resources/hudson/triggers/Messages.properties b/core/src/main/resources/hudson/triggers/Messages.properties index c82efebf15..245b3c4de4 100644 --- a/core/src/main/resources/hudson/triggers/Messages.properties +++ b/core/src/main/resources/hudson/triggers/Messages.properties @@ -29,7 +29,7 @@ TimerTrigger.MissingWhitespace=You appear to be missing whitespace between * and TimerTrigger.no_schedules_so_will_never_run=No schedules so will never run TimerTrigger.TimerTriggerCause.ShortDescription=Started by timer TimerTrigger.would_last_have_run_at_would_next_run_at=Would last have run at {0}; would next run at {1}. -TimerTrigger.the_specified_cron_tab_is_rare_or_impossible=This cron tab will match dates only rarely (e.g. February 29) or \ +TimerTrigger.the_specified_cron_tab_is_rare_or_impossible=This schedule will match dates only rarely (e.g. February 29) or \ never (e.g. June 31), so this job may be triggered very rarely, if at all. Trigger.init=Initializing timer for triggers SCMTrigger.AdministrativeMonitorImpl.DisplayName=Too Many SCM Polling Threads From 3cbeb12349c6d470041fa4f84a08583b9e4c25e7 Mon Sep 17 00:00:00 2001 From: urkon Date: Thu, 2 Mar 2017 09:47:41 +0100 Subject: [PATCH 10/14] Fix JENKINS-41756 - Indecently translated items Removed false and indecently to slovene translated main menu items. (cherry picked from commit acaf91c585e0b97d2b3dc93ec26f327d0abd9319) --- .../main/resources/hudson/model/View/sidepanel_sl.properties | 2 -- 1 file changed, 2 deletions(-) diff --git a/core/src/main/resources/hudson/model/View/sidepanel_sl.properties b/core/src/main/resources/hudson/model/View/sidepanel_sl.properties index a0a85ee14c..c3342f4d67 100644 --- a/core/src/main/resources/hudson/model/View/sidepanel_sl.properties +++ b/core/src/main/resources/hudson/model/View/sidepanel_sl.properties @@ -21,9 +21,7 @@ # THE SOFTWARE. Build\ History=Zgodovina prevajanja -Check\ File\ Fingerprint=Otisci guza Delete\ View=Izbri\u0161i pogled Edit\ View=Uredi pogled NewJob=Nov People=Uporabniki -Project\ Relationship=With my ass From 7039abe7080562323563e376ed20bab7dc074ec6 Mon Sep 17 00:00:00 2001 From: Oleg Nenashev Date: Thu, 9 Mar 2017 15:46:49 +0100 Subject: [PATCH 11/14] [JENKINS-42670] - Fix the potential File descriptor leak in the Windows Service installer (cherry picked from commit e63774decd7b8a9986e89cf2c2da393ae689a35e) --- .../main/java/hudson/lifecycle/WindowsInstallerLink.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/hudson/lifecycle/WindowsInstallerLink.java b/core/src/main/java/hudson/lifecycle/WindowsInstallerLink.java index 978b3c7965..a9142adbc6 100644 --- a/core/src/main/java/hudson/lifecycle/WindowsInstallerLink.java +++ b/core/src/main/java/hudson/lifecycle/WindowsInstallerLink.java @@ -306,9 +306,9 @@ public class WindowsInstallerLink extends ManagementLink { try { return Kernel32Utils.waitForExitProcess(sei.hProcess); } finally { - FileInputStream fin = new FileInputStream(new File(pwd,"redirect.log")); - IOUtils.copy(fin, out.getLogger()); - fin.close(); + try (FileInputStream fin = new FileInputStream(new File(pwd,"redirect.log"))) { + IOUtils.copy(fin, out.getLogger()); + } } } From 6f243e49b3c7a155d37f3d5821be6050a69b8822 Mon Sep 17 00:00:00 2001 From: Stephen Connolly Date: Tue, 14 Feb 2017 15:23:56 +0000 Subject: [PATCH 12/14] [JENKINS-41899] Pick up fix (cherry picked from commit 5969b8da99cc5541e313cf343cd31ba3ad2e4843) --- core/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/pom.xml b/core/pom.xml index 46c07ae68d..bde46c6fcf 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -65,7 +65,7 @@ THE SOFTWARE. org.jenkins-ci version-number - 1.1 + 1.3 org.jenkins-ci From c6a23bdd264dff17b681765b08cf7f439f69d41e Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Wed, 29 Mar 2017 13:49:23 -0700 Subject: [PATCH 13/14] [maven-release-plugin] prepare release jenkins-2.46.1 --- cli/pom.xml | 2 +- core/pom.xml | 2 +- pom.xml | 4 ++-- test/pom.xml | 2 +- war/pom.xml | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cli/pom.xml b/cli/pom.xml index 5e08491262..48e171f624 100644 --- a/cli/pom.xml +++ b/cli/pom.xml @@ -5,7 +5,7 @@ org.jenkins-ci.main pom - 2.46.1-SNAPSHOT + 2.46.1 cli diff --git a/core/pom.xml b/core/pom.xml index bde46c6fcf..bf61d83c74 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -29,7 +29,7 @@ THE SOFTWARE. org.jenkins-ci.main pom - 2.46.1-SNAPSHOT + 2.46.1 jenkins-core diff --git a/pom.xml b/pom.xml index d4d9c7734c..de2f76e8df 100644 --- a/pom.xml +++ b/pom.xml @@ -33,7 +33,7 @@ THE SOFTWARE. org.jenkins-ci.main pom - 2.46.1-SNAPSHOT + 2.46.1 pom Jenkins main module @@ -58,7 +58,7 @@ THE SOFTWARE. scm:git:git://github.com/jenkinsci/jenkins.git scm:git:ssh://git@github.com/jenkinsci/jenkins.git https://github.com/jenkinsci/jenkins - HEAD + jenkins-2.46.1 diff --git a/test/pom.xml b/test/pom.xml index 53cdb1bdd8..4e38159462 100644 --- a/test/pom.xml +++ b/test/pom.xml @@ -28,7 +28,7 @@ THE SOFTWARE. org.jenkins-ci.main pom - 2.46.1-SNAPSHOT + 2.46.1 test diff --git a/war/pom.xml b/war/pom.xml index 1c6614e045..97eb88b678 100644 --- a/war/pom.xml +++ b/war/pom.xml @@ -28,7 +28,7 @@ THE SOFTWARE. org.jenkins-ci.main pom - 2.46.1-SNAPSHOT + 2.46.1 jenkins-war From b71b1fb43b4ff896420455251e8c21af90e08ad9 Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Wed, 29 Mar 2017 13:49:23 -0700 Subject: [PATCH 14/14] [maven-release-plugin] prepare for next development iteration --- cli/pom.xml | 2 +- core/pom.xml | 2 +- pom.xml | 4 ++-- test/pom.xml | 2 +- war/pom.xml | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cli/pom.xml b/cli/pom.xml index 48e171f624..22938200fe 100644 --- a/cli/pom.xml +++ b/cli/pom.xml @@ -5,7 +5,7 @@ org.jenkins-ci.main pom - 2.46.1 + 2.46.2-SNAPSHOT cli diff --git a/core/pom.xml b/core/pom.xml index bf61d83c74..d16eb70615 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -29,7 +29,7 @@ THE SOFTWARE. org.jenkins-ci.main pom - 2.46.1 + 2.46.2-SNAPSHOT jenkins-core diff --git a/pom.xml b/pom.xml index de2f76e8df..5ef6dbee19 100644 --- a/pom.xml +++ b/pom.xml @@ -33,7 +33,7 @@ THE SOFTWARE. org.jenkins-ci.main pom - 2.46.1 + 2.46.2-SNAPSHOT pom Jenkins main module @@ -58,7 +58,7 @@ THE SOFTWARE. scm:git:git://github.com/jenkinsci/jenkins.git scm:git:ssh://git@github.com/jenkinsci/jenkins.git https://github.com/jenkinsci/jenkins - jenkins-2.46.1 + HEAD diff --git a/test/pom.xml b/test/pom.xml index 4e38159462..06d28b54a3 100644 --- a/test/pom.xml +++ b/test/pom.xml @@ -28,7 +28,7 @@ THE SOFTWARE. org.jenkins-ci.main pom - 2.46.1 + 2.46.2-SNAPSHOT test diff --git a/war/pom.xml b/war/pom.xml index 97eb88b678..7a9eebff51 100644 --- a/war/pom.xml +++ b/war/pom.xml @@ -28,7 +28,7 @@ THE SOFTWARE. org.jenkins-ci.main pom - 2.46.1 + 2.46.2-SNAPSHOT jenkins-war