Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/infra/core/org.eclipse.papyrus.infra.tools')
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.tools/src/org/eclipse/papyrus/infra/tools/Activator.java4
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.tools/src/org/eclipse/papyrus/infra/tools/util/Suppliers2.java21
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();
}

Back to the top