Remove calls to deprecated Throwables.propagate() method
Change-Id: Id48a8f1d4fb02560cfb77108f554556a3cad9b16
diff --git a/apps/test/distributed-primitives/src/main/java/org/onosproject/distributedprimitives/cli/WorkQueueTestCommand.java b/apps/test/distributed-primitives/src/main/java/org/onosproject/distributedprimitives/cli/WorkQueueTestCommand.java
index 668a359..dfaeafc 100644
--- a/apps/test/distributed-primitives/src/main/java/org/onosproject/distributedprimitives/cli/WorkQueueTestCommand.java
+++ b/apps/test/distributed-primitives/src/main/java/org/onosproject/distributedprimitives/cli/WorkQueueTestCommand.java
@@ -15,11 +15,6 @@
*/
package org.onosproject.distributedprimitives.cli;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.TimeUnit;
-
import org.apache.karaf.shell.commands.Argument;
import org.apache.karaf.shell.commands.Command;
import org.onosproject.cli.AbstractShellCommand;
@@ -31,7 +26,10 @@
import org.onosproject.store.service.WorkQueue;
import org.onosproject.store.service.WorkQueueStats;
-import com.google.common.base.Throwables;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.TimeUnit;
/**
* CLI command to test a distributed work queue.
@@ -108,7 +106,7 @@
try {
return future.get(DistributedPrimitive.DEFAULT_OPERATION_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
} catch (Exception e) {
- throw Throwables.propagate(e);
+ throw new IllegalStateException(e);
}
}
}
diff --git a/core/api/src/main/java/org/onosproject/net/config/BaseConfig.java b/core/api/src/main/java/org/onosproject/net/config/BaseConfig.java
index 0098c43..86687c5 100644
--- a/core/api/src/main/java/org/onosproject/net/config/BaseConfig.java
+++ b/core/api/src/main/java/org/onosproject/net/config/BaseConfig.java
@@ -15,18 +15,17 @@
*/
package org.onosproject.net.config;
-import static org.slf4j.LoggerFactory.getLogger;
-
-import java.io.IOException;
-
+import com.fasterxml.jackson.databind.ObjectMapper;
import org.onlab.osgi.DefaultServiceDirectory;
import org.onlab.osgi.ServiceDirectory;
import org.onosproject.codec.CodecContext;
import org.onosproject.codec.CodecService;
import org.onosproject.codec.JsonCodec;
import org.slf4j.Logger;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.google.common.base.Throwables;
+
+import java.io.IOException;
+
+import static org.slf4j.LoggerFactory.getLogger;
/**
* {@link Config} with access to {@link CodecService}.
@@ -69,7 +68,7 @@
return decode(mapper().readTree(json), entityClass);
} catch (IOException e) {
log.error("Exception caught.", e);
- throw Throwables.propagate(e);
+ throw new IllegalArgumentException(e);
}
}
diff --git a/core/api/src/main/java/org/onosproject/store/primitives/DefaultAtomicCounterMap.java b/core/api/src/main/java/org/onosproject/store/primitives/DefaultAtomicCounterMap.java
index 7fdc2df..b79effc 100644
--- a/core/api/src/main/java/org/onosproject/store/primitives/DefaultAtomicCounterMap.java
+++ b/core/api/src/main/java/org/onosproject/store/primitives/DefaultAtomicCounterMap.java
@@ -126,7 +126,7 @@
} catch (TimeoutException e) {
throw new ConsistentMapException.Timeout(name());
} catch (ExecutionException e) {
- Throwables.propagateIfPossible(e.getCause());
+ Throwables.throwIfUnchecked(e.getCause());
throw new ConsistentMapException(e.getCause());
}
}
diff --git a/core/api/src/main/java/org/onosproject/store/primitives/DefaultConsistentMap.java b/core/api/src/main/java/org/onosproject/store/primitives/DefaultConsistentMap.java
index b22bb7d..1bc62b3 100644
--- a/core/api/src/main/java/org/onosproject/store/primitives/DefaultConsistentMap.java
+++ b/core/api/src/main/java/org/onosproject/store/primitives/DefaultConsistentMap.java
@@ -232,7 +232,7 @@
} catch (TimeoutException e) {
throw new ConsistentMapException.Timeout(name());
} catch (ExecutionException e) {
- Throwables.propagateIfPossible(e.getCause());
+ Throwables.throwIfUnchecked(e.getCause());
throw new ConsistentMapException(e.getCause());
}
}
diff --git a/core/api/src/main/java/org/onosproject/store/primitives/DefaultConsistentMultimap.java b/core/api/src/main/java/org/onosproject/store/primitives/DefaultConsistentMultimap.java
index 1230e7a..8725c61 100644
--- a/core/api/src/main/java/org/onosproject/store/primitives/DefaultConsistentMultimap.java
+++ b/core/api/src/main/java/org/onosproject/store/primitives/DefaultConsistentMultimap.java
@@ -165,7 +165,7 @@
} catch (TimeoutException e) {
throw new ConsistentMapException.Timeout();
} catch (ExecutionException e) {
- Throwables.propagateIfPossible(e.getCause());
+ Throwables.throwIfUnchecked(e.getCause());
throw new ConsistentMapException(e.getCause());
}
}
diff --git a/core/api/src/main/java/org/onosproject/store/primitives/DefaultConsistentTreeMap.java b/core/api/src/main/java/org/onosproject/store/primitives/DefaultConsistentTreeMap.java
index 30a8d67..c9dd5df 100644
--- a/core/api/src/main/java/org/onosproject/store/primitives/DefaultConsistentTreeMap.java
+++ b/core/api/src/main/java/org/onosproject/store/primitives/DefaultConsistentTreeMap.java
@@ -17,12 +17,11 @@
package org.onosproject.store.primitives;
import com.google.common.base.Throwables;
-
-import org.onosproject.store.service.ConsistentMapException;
import org.onosproject.store.service.AsyncConsistentTreeMap;
+import org.onosproject.store.service.ConsistentMapException;
+import org.onosproject.store.service.ConsistentTreeMap;
import org.onosproject.store.service.MapEventListener;
import org.onosproject.store.service.Synchronous;
-import org.onosproject.store.service.ConsistentTreeMap;
import org.onosproject.store.service.Versioned;
import java.util.Collection;
@@ -63,7 +62,7 @@
Thread.currentThread().interrupt();
throw new ConsistentMapException.Interrupted();
} catch (ExecutionException e) {
- Throwables.propagateIfPossible(e.getCause());
+ Throwables.throwIfUnchecked(e.getCause());
throw new ConsistentMapException(e.getCause());
} catch (TimeoutException e) {
throw new ConsistentMapException.Timeout();
diff --git a/core/api/src/main/java/org/onosproject/store/primitives/DefaultDocumentTree.java b/core/api/src/main/java/org/onosproject/store/primitives/DefaultDocumentTree.java
index 42142cc..ae2f640 100644
--- a/core/api/src/main/java/org/onosproject/store/primitives/DefaultDocumentTree.java
+++ b/core/api/src/main/java/org/onosproject/store/primitives/DefaultDocumentTree.java
@@ -119,7 +119,7 @@
} catch (TimeoutException e) {
throw new DocumentException.Timeout(name());
} catch (ExecutionException e) {
- Throwables.propagateIfPossible(e.getCause());
+ Throwables.throwIfUnchecked(e.getCause());
throw new ConsistentMapException(e.getCause());
}
}
diff --git a/core/net/src/main/java/org/onosproject/cluster/impl/ConfigFileBasedClusterMetadataProvider.java b/core/net/src/main/java/org/onosproject/cluster/impl/ConfigFileBasedClusterMetadataProvider.java
index 1773154..c1b5de1 100644
--- a/core/net/src/main/java/org/onosproject/cluster/impl/ConfigFileBasedClusterMetadataProvider.java
+++ b/core/net/src/main/java/org/onosproject/cluster/impl/ConfigFileBasedClusterMetadataProvider.java
@@ -15,19 +15,18 @@
*/
package org.onosproject.cluster.impl;
-import static org.onlab.util.Tools.groupedThreads;
-import static org.slf4j.LoggerFactory.getLogger;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.net.HttpURLConnection;
-import java.net.URL;
-import java.util.Set;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicReference;
-
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.DeserializationContext;
+import com.fasterxml.jackson.databind.JsonDeserializer;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.JsonSerializer;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.SerializerProvider;
+import com.fasterxml.jackson.databind.module.SimpleModule;
+import com.google.common.collect.Sets;
+import com.google.common.io.Files;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
@@ -48,22 +47,20 @@
import org.onosproject.store.service.Versioned;
import org.slf4j.Logger;
-import com.fasterxml.jackson.core.JsonGenerator;
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.DeserializationContext;
-import com.fasterxml.jackson.databind.JsonDeserializer;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.JsonSerializer;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.SerializerProvider;
-import com.fasterxml.jackson.databind.module.SimpleModule;
-import com.google.common.base.Throwables;
-import com.google.common.collect.Sets;
-import com.google.common.io.Files;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.util.Set;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicReference;
import static com.google.common.base.Preconditions.checkState;
import static java.util.concurrent.Executors.newSingleThreadScheduledExecutor;
+import static org.onlab.util.Tools.groupedThreads;
+import static org.slf4j.LoggerFactory.getLogger;
/**
* Provider of {@link ClusterMetadata cluster metadata} sourced from a local config file.
@@ -145,7 +142,7 @@
cachedMetadata.set(fetchMetadata(metadataUrl));
providerService.clusterMetadataChanged(new Versioned<>(metadata, configFile.lastModified()));
} catch (IOException e) {
- Throwables.propagate(e);
+ throw new IllegalArgumentException(e);
}
}
@@ -197,7 +194,7 @@
Thread.sleep((int) Math.pow(2, iterations < 7 ? ++iterations : iterations) * 10L);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
- throw Throwables.propagate(e);
+ throw new IllegalStateException(e);
}
}
}
@@ -248,7 +245,7 @@
Sets.newHashSet(metadata.getPartitions())),
version);
} catch (IOException e) {
- throw Throwables.propagate(e);
+ throw new IllegalArgumentException(e);
}
}
diff --git a/core/store/dist/src/main/java/org/onosproject/store/cluster/messaging/impl/ClusterCommunicationManager.java b/core/store/dist/src/main/java/org/onosproject/store/cluster/messaging/impl/ClusterCommunicationManager.java
index 868006b..f605289 100644
--- a/core/store/dist/src/main/java/org/onosproject/store/cluster/messaging/impl/ClusterCommunicationManager.java
+++ b/core/store/dist/src/main/java/org/onosproject/store/cluster/messaging/impl/ClusterCommunicationManager.java
@@ -15,16 +15,6 @@
*/
package org.onosproject.store.cluster.messaging.impl;
-import java.util.Set;
-import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.Executor;
-import java.util.concurrent.ExecutorService;
-import java.util.function.BiConsumer;
-import java.util.function.BiFunction;
-import java.util.function.Consumer;
-import java.util.function.Function;
-import java.util.stream.Collectors;
-
import com.google.common.base.Objects;
import com.google.common.base.Throwables;
import org.apache.felix.scr.annotations.Activate;
@@ -47,6 +37,16 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.util.Set;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.Executor;
+import java.util.concurrent.ExecutorService;
+import java.util.function.BiConsumer;
+import java.util.function.BiFunction;
+import java.util.function.Consumer;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static org.onosproject.security.AppGuard.checkPermission;
@@ -278,8 +278,8 @@
return result;
} catch (Exception e) {
context.stop(e);
- Throwables.propagate(e);
- return null;
+ Throwables.throwIfUnchecked(e.getCause());
+ throw new IllegalStateException(e.getCause());
}
}
};
diff --git a/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/DefaultAsyncAtomicValue.java b/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/DefaultAsyncAtomicValue.java
index 37092f2..33af601 100644
--- a/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/DefaultAsyncAtomicValue.java
+++ b/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/DefaultAsyncAtomicValue.java
@@ -16,11 +16,7 @@
package org.onosproject.store.primitives.impl;
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.Map;
-import java.util.concurrent.CompletableFuture;
-
+import com.google.common.collect.Maps;
import org.onosproject.store.service.AsyncAtomicValue;
import org.onosproject.store.service.AsyncConsistentMap;
import org.onosproject.store.service.AtomicValueEvent;
@@ -31,8 +27,10 @@
import org.onosproject.store.service.Versioned;
import org.onosproject.utils.MeteringAgent;
-import com.google.common.base.Throwables;
-import com.google.common.collect.Maps;
+import java.util.Map;
+import java.util.concurrent.CompletableFuture;
+
+import static com.google.common.base.Preconditions.checkNotNull;
/**
* Default implementation of a {@code AsyncAtomicValue}.
@@ -170,14 +168,15 @@
final MeteringAgent.Context newTimer = monitor.startTimer(NOTIFY_LISTENER);
byte[] rawNewValue = Versioned.valueOrNull(event.newValue());
byte[] rawOldValue = Versioned.valueOrNull(event.oldValue());
+
try {
listener.event(new AtomicValueEvent<>(name,
rawNewValue == null ? null : serializer.decode(rawNewValue),
- rawOldValue == null ? null : serializer.decode(rawOldValue)));
+ rawOldValue == null ? null : serializer.decode(rawOldValue)));
newTimer.stop(null);
} catch (Exception e) {
newTimer.stop(e);
- Throwables.propagate(e);
+ throw new IllegalStateException(e.getCause());
}
}
}
diff --git a/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/MeteredAsyncConsistentMap.java b/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/MeteredAsyncConsistentMap.java
index ac41e84..de53121 100644
--- a/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/MeteredAsyncConsistentMap.java
+++ b/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/MeteredAsyncConsistentMap.java
@@ -16,6 +16,17 @@
package org.onosproject.store.primitives.impl;
+import com.google.common.collect.Maps;
+import org.onosproject.store.primitives.MapUpdate;
+import org.onosproject.store.primitives.TransactionId;
+import org.onosproject.store.service.AsyncConsistentMap;
+import org.onosproject.store.service.MapEvent;
+import org.onosproject.store.service.MapEventListener;
+import org.onosproject.store.service.TransactionLog;
+import org.onosproject.store.service.Version;
+import org.onosproject.store.service.Versioned;
+import org.onosproject.utils.MeteringAgent;
+
import java.util.Collection;
import java.util.Map;
import java.util.Map.Entry;
@@ -26,20 +37,6 @@
import java.util.function.Function;
import java.util.function.Predicate;
-import org.onosproject.store.primitives.MapUpdate;
-import org.onosproject.store.primitives.TransactionId;
-import org.onosproject.store.service.AsyncConsistentMap;
-import org.onosproject.store.service.MapEvent;
-import org.onosproject.store.service.MapEventListener;
-import org.onosproject.store.service.TransactionLog;
-import org.onosproject.store.service.Version;
-import org.onosproject.store.service.Versioned;
-
-import com.google.common.base.Throwables;
-import com.google.common.collect.Maps;
-
-import org.onosproject.utils.MeteringAgent;
-
/**
* {@link AsyncConsistentMap} that meters all its operations.
*
@@ -310,7 +307,7 @@
timer.stop(null);
} catch (Exception e) {
timer.stop(e);
- Throwables.propagate(e);
+ throw new IllegalStateException(e);
}
}
}
diff --git a/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/TransactionalMapParticipant.java b/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/TransactionalMapParticipant.java
index 55f4e24..8837b49 100644
--- a/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/TransactionalMapParticipant.java
+++ b/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/TransactionalMapParticipant.java
@@ -16,16 +16,6 @@
package org.onosproject.store.primitives.impl;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-
import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
import com.google.common.base.Throwables;
@@ -38,6 +28,16 @@
import org.onosproject.store.service.TransactionalMap;
import org.onosproject.store.service.Version;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;
@@ -87,7 +87,7 @@
} catch (TimeoutException e) {
throw new TransactionException.Timeout();
} catch (ExecutionException e) {
- Throwables.propagateIfPossible(e.getCause());
+ Throwables.throwIfUnchecked(e);
throw new TransactionException(e.getCause());
}
}
diff --git a/core/store/primitives/src/main/java/org/onosproject/store/primitives/resources/impl/AtomixConsistentMapService.java b/core/store/primitives/src/main/java/org/onosproject/store/primitives/resources/impl/AtomixConsistentMapService.java
index 22f59f3..d25d475 100644
--- a/core/store/primitives/src/main/java/org/onosproject/store/primitives/resources/impl/AtomixConsistentMapService.java
+++ b/core/store/primitives/src/main/java/org/onosproject/store/primitives/resources/impl/AtomixConsistentMapService.java
@@ -26,7 +26,6 @@
import java.util.function.Predicate;
import java.util.stream.Collectors;
-import com.google.common.base.Throwables;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
@@ -731,7 +730,7 @@
}
} catch (Exception e) {
logger().warn("Failure applying {}", commit, e);
- throw Throwables.propagate(e);
+ throw new IllegalStateException(e);
}
}
@@ -753,7 +752,7 @@
return commitTransaction(transactionScope);
} catch (Exception e) {
logger().warn("Failure applying {}", commit, e);
- throw Throwables.propagate(e);
+ throw new IllegalStateException(e);
} finally {
discardTombstones();
}
diff --git a/core/store/primitives/src/main/java/org/onosproject/store/primitives/resources/impl/AtomixDocumentTreeService.java b/core/store/primitives/src/main/java/org/onosproject/store/primitives/resources/impl/AtomixDocumentTreeService.java
index 2633bf1..41a1a9f 100644
--- a/core/store/primitives/src/main/java/org/onosproject/store/primitives/resources/impl/AtomixDocumentTreeService.java
+++ b/core/store/primitives/src/main/java/org/onosproject/store/primitives/resources/impl/AtomixDocumentTreeService.java
@@ -32,7 +32,6 @@
import com.esotericsoftware.kryo.Kryo;
import com.esotericsoftware.kryo.io.Input;
import com.esotericsoftware.kryo.io.Output;
-import com.google.common.base.Throwables;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Queues;
@@ -274,7 +273,7 @@
result = DocumentTreeResult.invalidPath();
} catch (Exception e) {
logger().error("Failed to apply {} to state machine", commit.value(), e);
- throw Throwables.propagate(e);
+ throw new IllegalStateException(e);
}
return result;
}
@@ -366,7 +365,7 @@
}
} catch (Exception e) {
logger().warn("Failure applying {}", commit, e);
- throw Throwables.propagate(e);
+ throw new IllegalStateException(e);
}
}
@@ -457,7 +456,7 @@
return commitTransaction(transactionScope);
} catch (Exception e) {
logger().warn("Failure applying {}", commit, e);
- throw Throwables.propagate(e);
+ throw new IllegalStateException(e);
}
}
diff --git a/core/store/primitives/src/main/java/org/onosproject/store/primitives/resources/impl/AtomixLeaderElectorService.java b/core/store/primitives/src/main/java/org/onosproject/store/primitives/resources/impl/AtomixLeaderElectorService.java
index b259cd1..542c375 100644
--- a/core/store/primitives/src/main/java/org/onosproject/store/primitives/resources/impl/AtomixLeaderElectorService.java
+++ b/core/store/primitives/src/main/java/org/onosproject/store/primitives/resources/impl/AtomixLeaderElectorService.java
@@ -29,7 +29,6 @@
import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
-import com.google.common.base.Throwables;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
@@ -177,7 +176,7 @@
return newLeadership;
} catch (Exception e) {
logger().error("State machine operation failed", e);
- throw Throwables.propagate(e);
+ throw new IllegalStateException(e);
}
}
@@ -197,7 +196,7 @@
}
} catch (Exception e) {
logger().error("State machine operation failed", e);
- throw Throwables.propagate(e);
+ throw new IllegalStateException(e);
}
}
@@ -222,7 +221,7 @@
commit.value().nodeId().equals(electionState.leader().nodeId()));
} catch (Exception e) {
logger().error("State machine operation failed", e);
- throw Throwables.propagate(e);
+ throw new IllegalStateException(e);
}
}
@@ -247,7 +246,7 @@
return true;
} catch (Exception e) {
logger().error("State machine operation failed", e);
- throw Throwables.propagate(e);
+ throw new IllegalStateException(e);
}
}
@@ -271,7 +270,7 @@
notifyLeadershipChanges(changes);
} catch (Exception e) {
logger().error("State machine operation failed", e);
- throw Throwables.propagate(e);
+ throw new IllegalStateException(e);
}
}
@@ -286,7 +285,7 @@
return leadership(topic);
} catch (Exception e) {
logger().error("State machine operation failed", e);
- throw Throwables.propagate(e);
+ throw new IllegalStateException(e);
}
}
@@ -304,7 +303,7 @@
}).keySet());
} catch (Exception e) {
logger().error("State machine operation failed", e);
- throw Throwables.propagate(e);
+ throw new IllegalStateException(e);
}
}
@@ -320,7 +319,7 @@
return result;
} catch (Exception e) {
logger().error("State machine operation failed", e);
- throw Throwables.propagate(e);
+ throw new IllegalStateException(e);
}
}
diff --git a/core/store/primitives/src/main/java/org/onosproject/store/primitives/resources/impl/AtomixWorkQueueService.java b/core/store/primitives/src/main/java/org/onosproject/store/primitives/resources/impl/AtomixWorkQueueService.java
index b1d6698..4540aa5 100644
--- a/core/store/primitives/src/main/java/org/onosproject/store/primitives/resources/impl/AtomixWorkQueueService.java
+++ b/core/store/primitives/src/main/java/org/onosproject/store/primitives/resources/impl/AtomixWorkQueueService.java
@@ -29,7 +29,6 @@
import java.util.stream.IntStream;
import com.google.common.base.MoreObjects;
-import com.google.common.base.Throwables;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Maps;
import com.google.common.collect.Queues;
@@ -169,7 +168,7 @@
.collect(Collectors.toCollection(ArrayList::new));
} catch (Exception e) {
logger().warn("State machine update failed", e);
- throw Throwables.propagate(e);
+ throw new IllegalStateException(e);
}
}
@@ -186,7 +185,7 @@
});
} catch (Exception e) {
logger().warn("State machine update failed", e);
- throw Throwables.propagate(e);
+ throw new IllegalStateException(e);
}
}
diff --git a/core/store/primitives/src/test/java/org/onosproject/store/primitives/resources/impl/AtomixConsistentMapTest.java b/core/store/primitives/src/test/java/org/onosproject/store/primitives/resources/impl/AtomixConsistentMapTest.java
index d08495a..23f9a1f 100644
--- a/core/store/primitives/src/test/java/org/onosproject/store/primitives/resources/impl/AtomixConsistentMapTest.java
+++ b/core/store/primitives/src/test/java/org/onosproject/store/primitives/resources/impl/AtomixConsistentMapTest.java
@@ -15,15 +15,6 @@
*/
package org.onosproject.store.primitives.resources.impl;
-import java.util.Arrays;
-import java.util.ConcurrentModificationException;
-import java.util.List;
-import java.util.concurrent.ArrayBlockingQueue;
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.CompletionException;
-import java.util.stream.Collectors;
-
-import com.google.common.base.Throwables;
import com.google.common.collect.Sets;
import io.atomix.protocols.raft.proxy.RaftProxy;
import io.atomix.protocols.raft.service.RaftService;
@@ -37,6 +28,14 @@
import org.onosproject.store.service.Version;
import org.onosproject.store.service.Versioned;
+import java.util.Arrays;
+import java.util.ConcurrentModificationException;
+import java.util.List;
+import java.util.concurrent.ArrayBlockingQueue;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.CompletionException;
+import java.util.stream.Collectors;
+
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
@@ -594,7 +593,8 @@
try {
queue.put(event);
} catch (InterruptedException e) {
- Throwables.propagate(e);
+ Thread.currentThread().interrupt();
+ throw new IllegalStateException(e);
}
}
diff --git a/core/store/primitives/src/test/java/org/onosproject/store/primitives/resources/impl/AtomixConsistentTreeMapTest.java b/core/store/primitives/src/test/java/org/onosproject/store/primitives/resources/impl/AtomixConsistentTreeMapTest.java
index acb7925..57bf60c 100644
--- a/core/store/primitives/src/test/java/org/onosproject/store/primitives/resources/impl/AtomixConsistentTreeMapTest.java
+++ b/core/store/primitives/src/test/java/org/onosproject/store/primitives/resources/impl/AtomixConsistentTreeMapTest.java
@@ -15,14 +15,6 @@
*/
package org.onosproject.store.primitives.resources.impl;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.List;
-import java.util.concurrent.ArrayBlockingQueue;
-import java.util.concurrent.BlockingQueue;
-import java.util.stream.Collectors;
-
-import com.google.common.base.Throwables;
import com.google.common.collect.Lists;
import io.atomix.protocols.raft.proxy.RaftProxy;
import io.atomix.protocols.raft.service.RaftService;
@@ -31,6 +23,13 @@
import org.onosproject.store.service.MapEvent;
import org.onosproject.store.service.MapEventListener;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+import java.util.concurrent.ArrayBlockingQueue;
+import java.util.concurrent.BlockingQueue;
+import java.util.stream.Collectors;
+
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -500,7 +499,8 @@
try {
queue.put(event);
} catch (InterruptedException e) {
- Throwables.propagate(e);
+ Thread.interrupted();
+ throw new IllegalStateException(e);
}
}
diff --git a/core/store/primitives/src/test/java/org/onosproject/store/primitives/resources/impl/AtomixDocumentTreeTest.java b/core/store/primitives/src/test/java/org/onosproject/store/primitives/resources/impl/AtomixDocumentTreeTest.java
index 7a41395..6abe84f 100644
--- a/core/store/primitives/src/test/java/org/onosproject/store/primitives/resources/impl/AtomixDocumentTreeTest.java
+++ b/core/store/primitives/src/test/java/org/onosproject/store/primitives/resources/impl/AtomixDocumentTreeTest.java
@@ -16,18 +16,9 @@
package org.onosproject.store.primitives.resources.impl;
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-import java.util.concurrent.ArrayBlockingQueue;
-import java.util.concurrent.BlockingQueue;
-
import com.google.common.base.Throwables;
import io.atomix.protocols.raft.proxy.RaftProxy;
import io.atomix.protocols.raft.service.RaftService;
-
import org.junit.Test;
import org.onosproject.store.primitives.NodeUpdate;
import org.onosproject.store.primitives.TransactionId;
@@ -41,6 +32,14 @@
import org.onosproject.store.service.Version;
import org.onosproject.store.service.Versioned;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import java.util.concurrent.ArrayBlockingQueue;
+import java.util.concurrent.BlockingQueue;
+
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -482,7 +481,8 @@
try {
queue.put(event);
} catch (InterruptedException e) {
- Throwables.propagate(e);
+ Thread.currentThread().interrupt();
+ throw new IllegalStateException(e);
}
}
diff --git a/tools/build/conf/src/main/resources/onos/checkstyle.xml b/tools/build/conf/src/main/resources/onos/checkstyle.xml
index d2727f0..c0fbca7 100644
--- a/tools/build/conf/src/main/resources/onos/checkstyle.xml
+++ b/tools/build/conf/src/main/resources/onos/checkstyle.xml
@@ -99,6 +99,14 @@
<property name="message" value="Line has windows line endings."/>
</module>
+ <!-- Don't allow usage of deprecated Throwables propagate methods -->
+ <module name="RegexpSingleline">
+ <property name="format" value="Throwables.propagate.*\("/>
+ <property name="minimum" value="0"/>
+ <property name="maximum" value="0"/>
+ <property name="message" value="Throwables propagate methods have been deprecated."/>
+ </module>
+
<!-- Checks for Headers -->
<!-- See http://checkstyle.sf.net/config_header.html -->
<!-- <module name="Header"> -->
diff --git a/utils/misc/src/main/java/org/onlab/util/RetriesExceededException.java b/utils/misc/src/main/java/org/onlab/util/RetriesExceededException.java
new file mode 100644
index 0000000..d815353
--- /dev/null
+++ b/utils/misc/src/main/java/org/onlab/util/RetriesExceededException.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onlab.util;
+
+/**
+ * Exception that indicates the retry threshold has been exceeded.
+ */
+public class RetriesExceededException extends RuntimeException {
+
+ /**
+ * Create a retries exceeded exception.
+ *
+ * @param t Throwable that cased the last iteration to fail
+ */
+ RetriesExceededException(Throwable t) {
+ super(t);
+ }
+}
diff --git a/utils/misc/src/main/java/org/onlab/util/RetryingFunction.java b/utils/misc/src/main/java/org/onlab/util/RetryingFunction.java
index 0221e63..dc82047 100644
--- a/utils/misc/src/main/java/org/onlab/util/RetryingFunction.java
+++ b/utils/misc/src/main/java/org/onlab/util/RetryingFunction.java
@@ -15,10 +15,10 @@
*/
package org.onlab.util;
-import java.util.function.Function;
-
import com.google.common.base.Throwables;
+import java.util.function.Function;
+
/**
* Function that retries execution on failure.
*
@@ -52,7 +52,8 @@
return baseFunction.apply(input);
} catch (Throwable t) {
if (!exceptionClass.isAssignableFrom(t.getClass()) || retryAttempts == maxRetries) {
- Throwables.propagate(t);
+ Throwables.throwIfUnchecked(t);
+ throw new RetriesExceededException(t);
}
Tools.randomDelay(maxDelayBetweenRetries);
retryAttempts++;
diff --git a/utils/misc/src/main/java/org/onlab/util/SharedExecutorService.java b/utils/misc/src/main/java/org/onlab/util/SharedExecutorService.java
index 79a0baf..d12ba17 100644
--- a/utils/misc/src/main/java/org/onlab/util/SharedExecutorService.java
+++ b/utils/misc/src/main/java/org/onlab/util/SharedExecutorService.java
@@ -16,7 +16,6 @@
package org.onlab.util;
import com.codahale.metrics.Timer;
-import com.google.common.base.Throwables;
import org.onlab.metrics.MetricsComponent;
import org.onlab.metrics.MetricsFeature;
import org.onlab.metrics.MetricsService;
@@ -222,7 +221,7 @@
runnable.run();
} catch (Exception e) {
log.error("Uncaught exception on " + runnable.getClass().getSimpleName(), e);
- throw Throwables.propagate(e);
+ throw new IllegalStateException(e);
}
}
}
diff --git a/utils/misc/src/main/java/org/onlab/util/SharedScheduledExecutorService.java b/utils/misc/src/main/java/org/onlab/util/SharedScheduledExecutorService.java
index be6baa6..1bdd6c5 100644
--- a/utils/misc/src/main/java/org/onlab/util/SharedScheduledExecutorService.java
+++ b/utils/misc/src/main/java/org/onlab/util/SharedScheduledExecutorService.java
@@ -16,7 +16,6 @@
package org.onlab.util;
-import com.google.common.base.Throwables;
import org.slf4j.Logger;
import java.util.Collection;
@@ -280,7 +279,7 @@
// if repeat flag set as false, we simply throw an exception to
// terminate this task
if (!repeatFlag) {
- throw Throwables.propagate(e);
+ throw new IllegalStateException(e);
}
}
}