-
-
Notifications
You must be signed in to change notification settings - Fork 80
Make workflow-api compatible with Guava 21.0 and newer #135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 9 commits
b7bf0d8
ec8ea59
564ca43
37e412d
284918f
31acbee
8d974b8
c363cc8
d6bfed6
d0626eb
c8e40e3
1051efe
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -44,9 +44,9 @@ | |
| </license> | ||
| </licenses> | ||
| <scm> | ||
| <connection>scm:git:git://github.com/jenkinsci/${project.artifactId}-plugin.git</connection> | ||
| <developerConnection>scm:git:[email protected]:jenkinsci/${project.artifactId}-plugin.git</developerConnection> | ||
| <url>https://github.com/jenkinsci/${project.artifactId}-plugin</url> | ||
| <connection>scm:git:git://github.com/${gitHubRepo}.git</connection> | ||
| <developerConnection>scm:git:[email protected]:${gitHubRepo}.git</developerConnection> | ||
| <url>https://github.com/${gitHubRepo}</url> | ||
| <tag>${scmTag}</tag> | ||
| </scm> | ||
| <repositories> | ||
|
|
@@ -64,17 +64,18 @@ | |
| <properties> | ||
| <revision>2.42</revision> | ||
| <changelist>-SNAPSHOT</changelist> | ||
| <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> | ||
| <gitHubRepo>jenkinsci/${project.artifactId}-plugin</gitHubRepo> | ||
| </properties> | ||
| <dependencyManagement> | ||
| <dependencies> | ||
| <dependency> | ||
| <groupId>io.jenkins.tools.bom</groupId> | ||
| <artifactId>bom-2.176.x</artifactId> | ||
| <version>16</version> | ||
| <artifactId>bom-2.222.x</artifactId> | ||
| <version>25</version> | ||
| <scope>import</scope> | ||
| <type>pom</type> | ||
| </dependency> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,7 @@ | |
| import com.google.common.util.concurrent.FutureCallback; | ||
| import com.google.common.util.concurrent.Futures; | ||
| import com.google.common.util.concurrent.ListenableFuture; | ||
| import com.google.common.util.concurrent.MoreExecutors; | ||
| import com.google.inject.Inject; | ||
| import hudson.Extension; | ||
| import hudson.ExtensionList; | ||
|
|
@@ -20,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; | ||
|
|
@@ -194,7 +198,7 @@ public void onFailure(Throwable t) { | |
| LOGGER.log(WARNING, "Failed to load " + e, t); | ||
| } | ||
| } | ||
| }); | ||
| }, newExecutorService()); | ||
|
||
| } | ||
| } | ||
| } | ||
|
|
@@ -230,7 +234,7 @@ public void onSuccess(List<StepExecution> result) { | |
| public void onFailure(Throwable t) { | ||
| LOGGER.log(Level.WARNING, null, t); | ||
| } | ||
| }); | ||
| }, newExecutorService()); | ||
| } | ||
|
|
||
| return Futures.allAsList(all); | ||
|
|
@@ -254,4 +258,25 @@ 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#sameThreadExecutor} or falls back to {@code MoreExecutors#newDirectExecutorService} | ||
| * for compatibility with newer (> 18.0) versions of guava. | ||
| */ | ||
| private static ExecutorService newExecutorService() { | ||
| try { | ||
| try { | ||
| // guava older than 18 | ||
| Method method = MoreExecutors.class.getMethod("sameThreadExecutor"); | ||
| return (ExecutorService) method.invoke(null); | ||
| } catch (NoSuchMethodException e) { | ||
| // TODO invert this to prefer the newer guava method once guava is upgraded in Jenkins core | ||
timja marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
timja marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| Method method = MoreExecutors.class.getMethod("newDirectExecutorService"); | ||
| return (ExecutorService) method.invoke(null); | ||
| } | ||
| } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e ) { | ||
| throw new RuntimeException(e); | ||
| } | ||
| } | ||
|
|
||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.