Skip to content

Commit

Permalink
Merge pull request #77 from jglick/SynchronousResumeNotSupportedExcep…
Browse files Browse the repository at this point in the history
…tion-JENKINS-30383

`SynchronousResumeNotSupportedException` as a marker for lack of JENKINS-30383
  • Loading branch information
car-roll authored Dec 16, 2021
2 parents 375732a + e03eed7 commit b09dac3
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public void stop(Throwable cause) throws Exception {

@Override
public void onResume() {
getContext().onFailure(new Exception("Resume after a restart not supported for non-blocking synchronous steps"));
getContext().onFailure(new SynchronousResumeNotSupportedException());
}

@Override public @Nonnull String getStatus() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public void stop(Throwable cause) throws Exception {
@Override
public void onResume() {
if (threadName != null) {
getContext().onFailure(new Exception("Resume after a restart not supported while running background code"));
getContext().onFailure(new SynchronousResumeNotSupportedException());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ public void stop(@Nonnull Throwable cause) throws Exception {
/**
* Called when {@link StepExecution} is brought back into memory after restart.
* Convenient for re-establishing the polling.
* <p>Currently not permitted to throw exceptions, but may report errors via {@link StepContext#onFailure}.
* @see SynchronousResumeNotSupportedException
*/
public void onResume() {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public void stop(Throwable cause) throws Exception {

@Override
public void onResume() {
getContext().onFailure(new Exception("Resume after a restart not supported for non-blocking synchronous steps"));
getContext().onFailure(new SynchronousResumeNotSupportedException());
}

@Override public @Nonnull String getStatus() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* The MIT License
*
* Copyright 2021 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 org.jenkinsci.plugins.workflow.steps;

/**
* May be reported from {@link StepExecution#onResume} when the step does not support resumption.
* Thrown by default from {@link SynchronousNonBlockingStepExecution},
* as well as from {@link GeneralNonBlockingStepExecution} when running step code rather than a block.
* ({@link SynchronousStepExecution} does not even bother implementing this method
* since it should never be listed as in progress to begin with.)
*/
public class SynchronousResumeNotSupportedException extends Exception {

public SynchronousResumeNotSupportedException() {
super("Resume after a restart not supported for non-blocking synchronous steps");
}

}

0 comments on commit b09dac3

Please sign in to comment.