-
Notifications
You must be signed in to change notification settings - Fork 68
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
Make workflow-support compatible with Guava 21.0 and newer #114
Changes from 2 commits
6ba5df6
335977a
3a32092
b416720
902967c
b0ce2e0
f7a4a16
aa4aba8
2ff560a
f274d5d
c5ecc11
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 |
---|---|---|
|
@@ -65,7 +65,7 @@ public abstract class Futures { | |
* });}</pre> | ||
* | ||
* <p>Note: This overload of {@code addCallback} is designed for cases in | ||
* which the callack is fast and lightweight, as the method does not accept | ||
* which the callback is fast and lightweight, as the method does not accept | ||
* an {@code Executor} in which to perform the the work. For heavier | ||
* callbacks, this overload carries some caveats: First, the thread that the | ||
* callback runs in depends on whether the input {@code Future} is done at the | ||
|
@@ -74,7 +74,7 @@ public abstract class Futures { | |
* callback in the thread that calls {@code addCallback} or {@code | ||
* Future.cancel}. Second, callbacks may run in an internal thread of the | ||
* system responsible for the input {@code Future}, such as an RPC network | ||
* thread. Finally, during the execution of a {@code sameThreadExecutor} | ||
* thread. Finally, during the execution of a {@code newDirectExecutorService} | ||
* callback, all other registered but unexecuted listeners are prevented from | ||
* running, even if those listeners are to run in other executors. | ||
* | ||
|
@@ -87,7 +87,7 @@ public abstract class Futures { | |
*/ | ||
public static <V> void addCallback(ListenableFuture<V> future, | ||
FutureCallback<? super V> callback) { | ||
addCallback(future, callback, MoreExecutors.sameThreadExecutor()); | ||
addCallback(future, callback, MoreExecutors.newDirectExecutorService()); | ||
} | ||
|
||
/** | ||
|
@@ -115,16 +115,16 @@ public static <V> void addCallback(ListenableFuture<V> future, | |
* | ||
* When the callback is fast and lightweight consider {@linkplain | ||
* Futures#addCallback(ListenableFuture, FutureCallback) the other overload} | ||
* or explicit use of {@link MoreExecutors#sameThreadExecutor | ||
* sameThreadExecutor}. For heavier callbacks, this choice carries some | ||
* or explicit use of {@link MoreExecutors#newDirectExecutorService | ||
* newDirectExecutorService}. For heavier callbacks, this choice carries some | ||
* caveats: First, the thread that the callback runs in depends on whether | ||
* the input {@code Future} is done at the time {@code addCallback} is called | ||
* and on whether the input {@code Future} is ever cancelled. In particular, | ||
* {@code addCallback} may execute the callback in the thread that calls | ||
* {@code addCallback} or {@code Future.cancel}. Second, callbacks may run in | ||
* an internal thread of the system responsible for the input {@code Future}, | ||
* such as an RPC network thread. Finally, during the execution of a {@code | ||
* sameThreadExecutor} callback, all other registered but unexecuted | ||
* newDirectExecutorService} callback, all other registered but unexecuted | ||
* listeners are prevented from running, even if those listeners are to run | ||
* in other executors. | ||
* | ||
|
@@ -218,7 +218,7 @@ public static <V> ListenableFuture<V> immediateFailedFuture( | |
* thread that called {@code transform}. Second, transformations may run in | ||
* an internal thread of the system responsible for the input {@code Future}, | ||
* such as an RPC network thread. Finally, during the execution of a {@code | ||
* sameThreadExecutor} transformation, all other registered but unexecuted | ||
* newDirectExecutorService} transformation, all other registered but unexecuted | ||
* listeners are prevented from running, even if those listeners are to run | ||
* in other executors. | ||
* | ||
|
@@ -240,7 +240,7 @@ public static <V> ListenableFuture<V> immediateFailedFuture( | |
*/ | ||
public static <I, O> ListenableFuture<O> transform(ListenableFuture<I> future, | ||
final Function<? super I, ? extends O> function) { | ||
return Futures.<I, O>transform(future, function, MoreExecutors.sameThreadExecutor()); | ||
return Futures.<I, O>transform(future, function, MoreExecutors.newDirectExecutorService()); | ||
} | ||
|
||
/** | ||
|
@@ -272,15 +272,15 @@ public static <I, O> ListenableFuture<O> transform(ListenableFuture<I> future, | |
* <p>Note: For cases in which the transformation is fast and lightweight, | ||
* consider {@linkplain Futures#transform(ListenableFuture, Function) the | ||
* other overload} or explicit use of {@link | ||
* MoreExecutors#sameThreadExecutor}. For heavier transformations, this | ||
* MoreExecutors#newDirectExecutorService}. For heavier transformations, this | ||
* choice carries some caveats: First, the thread that the transformation | ||
* runs in depends on whether the input {@code Future} is done at the time | ||
* {@code transform} is called. In particular, if called late, {@code | ||
* transform} will perform the transformation in the thread that called | ||
* {@code transform}. Second, transformations may run in an internal thread | ||
* of the system responsible for the input {@code Future}, such as an RPC | ||
* network thread. Finally, during the execution of a {@code | ||
* sameThreadExecutor} transformation, all other registered but unexecuted | ||
* newDirectExecutorService} transformation, all other registered but unexecuted | ||
* listeners are prevented from running, even if those listeners are to run | ||
* in other executors. | ||
* | ||
|
@@ -324,7 +324,7 @@ public static <I, O> ListenableFuture<O> transform(ListenableFuture<I> future, | |
public static <V> ListenableFuture<List<V>> allAsList( | ||
ListenableFuture<? extends V>... futures) { | ||
return new ListFuture<V>(ImmutableList.copyOf(futures), true, | ||
MoreExecutors.sameThreadExecutor()); | ||
MoreExecutors.newDirectExecutorService()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since this is since Guava 18, maybe we could use reflection to try Or copy the impl into this plugin, keeping the Apache license header. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nice idea, when I was working on it (and plan to get back to it, although others are welcome to take it up) I was trying to get a green bom PCT build and then look at what's required and see where changes like your suggestion could be applied. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have this change ready to push. Is it ok if I push to your branch @timja? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. absolutely go for it There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also see jenkinsci/workflow-api-plugin#135 and jenkinsci/bom#423 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Errr, I don't have push permission here, so I've filed a PR to your forked branch: timja#1 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I'll have a look. Meanwhile, isn't this PR mergeable as is? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. looks good to me |
||
} | ||
|
||
/** | ||
|
@@ -347,7 +347,7 @@ public static <V> ListenableFuture<List<V>> allAsList( | |
public static <V> ListenableFuture<List<V>> allAsList( | ||
Iterable<? extends ListenableFuture<? extends V>> futures) { | ||
return new ListFuture<V>(ImmutableList.copyOf(futures), true, | ||
MoreExecutors.sameThreadExecutor()); | ||
MoreExecutors.newDirectExecutorService()); | ||
} | ||
|
||
/** | ||
|
@@ -379,14 +379,14 @@ public static <V> ListenableFuture<List<V>> allAsList( | |
* <p>Note: For cases in which the work of creating the derived future is | ||
* fast and lightweight, consider {@linkplain Futures#chain(ListenableFuture, | ||
* Function) the other overload} or explicit use of {@code | ||
* sameThreadExecutor}. For heavier derivations, this choice carries some | ||
* newDirectExecutorService}. For heavier derivations, this choice carries some | ||
* caveats: First, the thread that the derivation runs in depends on whether | ||
* the input {@code Future} is done at the time {@code chain} is called. In | ||
* particular, if called late, {@code chain} will run the derivation in the | ||
* thread that called {@code chain}. Second, derivations may run in an | ||
* internal thread of the system responsible for the input {@code Future}, | ||
* such as an RPC network thread. Finally, during the execution of a {@code | ||
* sameThreadExecutor} {@code chain} function, all other registered but | ||
* newDirectExecutorService} {@code chain} function, all other registered but | ||
* unexecuted listeners are prevented from running, even if those listeners | ||
* are to run in other executors. | ||
* | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please link to whatever Jenkins core PR produced this incremental so reviewers have more context about the proposed change? Thanks!