diff options
author | Quentin Le Menez | 2019-06-14 12:54:36 +0000 |
---|---|---|
committer | Quentin Le Menez | 2019-08-06 13:24:07 +0000 |
commit | 1d290819592299eb05c29550075cfb631f5043c5 (patch) | |
tree | b16f259b2102d2501dde9930ebf19c7fd7b86d08 /plugins/infra/core/org.eclipse.papyrus.infra.tools | |
parent | fa1f3e5c6fbd3dd4b65e11fa85e8ff78a9a959b0 (diff) | |
download | org.eclipse.papyrus-1d290819592299eb05c29550075cfb631f5043c5.tar.gz org.eclipse.papyrus-1d290819592299eb05c29550075cfb631f5043c5.tar.xz org.eclipse.papyrus-1d290819592299eb05c29550075cfb631f5043c5.zip |
Bug 549266 - [Releng] Guava 27.1 compatibility patch
- Add guava Futures compilation corrections (addCallback, transform, transformAsync)
Change-Id: I236e3ba5cf9f4068168f5203688e99ac00fde4e8
Signed-off-by: Quentin Le Menez <quentin.lemenez@cea.fr>
Diffstat (limited to 'plugins/infra/core/org.eclipse.papyrus.infra.tools')
2 files changed, 15 insertions, 10 deletions
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.tools/src/org/eclipse/papyrus/infra/tools/Activator.java b/plugins/infra/core/org.eclipse.papyrus.infra.tools/src/org/eclipse/papyrus/infra/tools/Activator.java index b04b7dec9d2..6ee032a350a 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.tools/src/org/eclipse/papyrus/infra/tools/Activator.java +++ b/plugins/infra/core/org.eclipse.papyrus.infra.tools/src/org/eclipse/papyrus/infra/tools/Activator.java @@ -11,7 +11,7 @@ * Contributors: * CEA LIST - Initial API and implementation * Christian W. Damus = bug 485220 - * + * *****************************************************************************/ package org.eclipse.papyrus.infra.tools; @@ -24,7 +24,7 @@ import org.osgi.util.tracker.ServiceTracker; /** * The activator class controls the plug-in life cycle - * + * * @since 2.0 */ public class Activator extends Plugin { diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.tools/src/org/eclipse/papyrus/infra/tools/util/Suppliers2.java b/plugins/infra/core/org.eclipse.papyrus.infra.tools/src/org/eclipse/papyrus/infra/tools/util/Suppliers2.java index ec802230c36..9c315809a54 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.tools/src/org/eclipse/papyrus/infra/tools/util/Suppliers2.java +++ b/plugins/infra/core/org.eclipse.papyrus.infra.tools/src/org/eclipse/papyrus/infra/tools/util/Suppliers2.java @@ -1,6 +1,6 @@ /***************************************************************************** * Copyright (c) 2015 Christian W. Damus and others. - * + * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at @@ -10,7 +10,7 @@ * * Contributors: * Christian W. Damus - Initial API and implementation - * + * *****************************************************************************/ package org.eclipse.papyrus.infra.tools.util; @@ -26,6 +26,7 @@ import com.google.common.base.Suppliers; 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; /** * Utilities for working with suppliers that are not provided by {@linkplain Suppliers Guava}. @@ -44,7 +45,7 @@ public class Suppliers2 { * available, after which it returns that value. If the future completes with an * exception, then the supplier will always provide {@code null} and the exception * will not be accessible. - * + * * @param future * a future result * @return a supplier of the eventual value of the {@code future} @@ -59,7 +60,7 @@ public class Suppliers2 { * available, after which it returns that value. If the future completes with an * exception, then the supplier will always provide the default and the exception * will not be accessible. - * + * * @param future * a future result * @param defaultValue @@ -68,8 +69,8 @@ public class Suppliers2 { */ public static <V> Supplier<V> eventualSupplier(Future<V> future, V defaultValue) { return (future instanceof ListenableFuture<?>) - ? new ListenableFutureSupplier<V>((ListenableFuture<V>) future, defaultValue) - : new FutureSupplier<V>(future, defaultValue); + ? new ListenableFutureSupplier<>((ListenableFuture<V>) future, defaultValue) + : new FutureSupplier<>(future, defaultValue); } // @@ -85,6 +86,7 @@ public class Suppliers2 { this.value = defaultValue; } + @Override public V get() { if ((value == null) && (future != null) && future.isDone()) { try { @@ -112,20 +114,23 @@ public class Suppliers2 { private AtomicReference<V> value; ListenableFutureSupplier(ListenableFuture<V> future, V defaultValue) { - value = new AtomicReference<V>(defaultValue); + value = new AtomicReference<>(defaultValue); Futures.addCallback(future, new FutureCallback<V>() { + @Override public void onSuccess(V result) { value.set(result); } + @Override public void onFailure(Throwable t) { // Normal case. There will never be a value Activator.log.error("Future execution failed", t); } - }); + }, MoreExecutors.directExecutor()); // Added because of compilation error on the executor-less method call } + @Override public V get() { return value.get(); } |