Skip to content
Merged
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
21 changes: 1 addition & 20 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
<properties>
<revision>2.42</revision>
<changelist>-SNAPSHOT</changelist>
<jenkins.version>2.273-rc30689.09147672b85b</jenkins.version>
<jenkins.version>2.176.4</jenkins.version>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we use a supported one at least, most of the others were recently bumped to 2.222.4

Suggested change
<jenkins.version>2.176.4</jenkins.version>
<jenkins.version>2.222.4</jenkins.version>

<java.level>8</java.level>
<no-test-jar>false</no-test-jar>
<useBeta>true</useBeta>
Expand Down Expand Up @@ -105,11 +105,6 @@
<artifactId>workflow-basic-steps</artifactId>
<scope>test</scope>
</dependency>
<dependency>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

may need to re-add on newer core depending on why this was in here

<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>trilead-api</artifactId>
<scope>test</scope>
</dependency>
<!-- For Semaphore step -->
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
Expand Down Expand Up @@ -139,18 +134,4 @@
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<!-- TODO the tests depend on workflow-support and cps which both need api published first... -->
<!-- need to run at least one flag or the pipeline fails -->
<test>InjectedTest</test>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,13 @@

import java.io.File;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.CancellationException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
Expand Down Expand Up @@ -181,11 +184,9 @@ public void onLoaded() {
Futures.addCallback(e.getCurrentExecutions(false), new FutureCallback<List<StepExecution>>() {
@Override
public void onSuccess(List<StepExecution> result) {
if (result != null) {
LOGGER.log(FINE, "Will resume {0}", result);
for (StepExecution se : result) {
se.onResume();
}
LOGGER.log(FINE, "Will resume {0}", result);
for (StepExecution se : result) {
se.onResume();
}
}

Expand All @@ -197,7 +198,7 @@ public void onFailure(Throwable t) {
LOGGER.log(WARNING, "Failed to load " + e, t);
}
}
}, MoreExecutors.newDirectExecutorService());
}, newExecutorService());
}
}
}
Expand All @@ -220,13 +221,11 @@ public ListenableFuture<?> apply(final Function<StepExecution, Void> f) {
Futures.addCallback(execs,new FutureCallback<List<StepExecution>>() {
@Override
public void onSuccess(List<StepExecution> result) {
if (result != null) {
for (StepExecution e : result) {
try {
f.apply(e);
} catch (RuntimeException x) {
LOGGER.log(Level.WARNING, null, x);
}
for (StepExecution e : result) {
try {
f.apply(e);
} catch (RuntimeException x) {
LOGGER.log(Level.WARNING, null, x);
}
}
}
Expand All @@ -235,7 +234,7 @@ public void onSuccess(List<StepExecution> result) {
public void onFailure(Throwable t) {
LOGGER.log(Level.WARNING, null, t);
}
}, MoreExecutors.newDirectExecutorService());
}, newExecutorService());
}

return Futures.allAsList(all);
Expand All @@ -259,4 +258,24 @@ public void onFailure(Throwable t) {
executor.awaitTermination(1, TimeUnit.MINUTES);
}

/**
* Returns an {@link ExecutorService} to be used as a parameter in other methods.
* It calls {@code MoreExecutors#newDirectExecutorService} or falls back to {@code MoreExecutors#sameThreadExecutor}
* for compatibility with older (< 18.0) versions of guava.
*/
private static ExecutorService newExecutorService() {
try {
try {
Method method = MoreExecutors.class.getMethod("newDirectExecutorService");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you invert this please as in c5ecc11 (#114) (was requested until core PR is merged)

return (ExecutorService) method.invoke(null);
} catch (NoSuchMethodException e) {
// guava older than 18, fallback to `sameThreadExecutor`
Method method = MoreExecutors.class.getMethod("sameThreadExecutor");
return (ExecutorService) method.invoke(null);
}
} catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e ) {
throw new RuntimeException(e);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

import com.google.common.base.Predicate;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.jenkinsci.plugins.workflow.actions.ThreadNameAction;
import org.jenkinsci.plugins.workflow.actions.TimingAction;
import org.jenkinsci.plugins.workflow.graph.BlockEndNode;
Expand All @@ -37,6 +36,7 @@

import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.annotation.concurrent.NotThreadSafe;
import java.util.ArrayDeque;
import java.util.ArrayList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@
package org.jenkinsci.plugins.workflow.graphanalysis;

import com.google.common.base.Predicate;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.jenkinsci.plugins.workflow.graph.FlowEndNode;
import org.jenkinsci.plugins.workflow.graph.FlowNode;
import org.jenkinsci.plugins.workflow.graph.FlowStartNode;
import org.jenkinsci.plugins.workflow.graph.StepNode;
import org.jenkinsci.plugins.workflow.steps.StepDescriptor;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@
package org.jenkinsci.plugins.workflow.graphanalysis;

import com.google.common.base.Predicate;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.jenkinsci.plugins.workflow.graph.FlowEndNode;
import org.jenkinsci.plugins.workflow.graph.FlowNode;
import org.jenkinsci.plugins.workflow.graph.FlowStartNode;
import org.jenkinsci.plugins.workflow.graph.StepNode;
import org.jenkinsci.plugins.workflow.steps.StepDescriptor;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

Expand Down