int ntfOk = 0;
int ntfError = 0;
ListenableFuture<?> lastOkFuture = null;
- for (int i = 0; i < this.iterations; i++) {
+ for (int i = 0; i < iterations; i++) {
try {
- final ListenableFuture<?> result = this.publishService.offerNotification(this.ntf);
+ final ListenableFuture<?> result = publishService.offerNotification(ntf);
if (NotificationPublishService.REJECTED == result) {
ntfError++;
} else {
try {
lastOkFuture.get();
} catch (InterruptedException | ExecutionException e) {
- throw new RuntimeException(e);
+ throw new IllegalStateException(e);
}
}
}
-
}
try {
return new MapState((Map<String, String>) SerializationUtils.deserialize(snapshotBytes.read()));
} catch (IOException e) {
- throw new RuntimeException(e);
+ throw new IllegalStateException(e);
}
}
try {
snapshotInputStream = snapshotBytes.openStream();
} catch (IOException e) {
- throw new RuntimeException(e);
+ throw new IllegalStateException(e);
}
}
import akka.actor.ActorRef;
import akka.util.Timeout;
+import com.google.common.base.Throwables;
import java.util.concurrent.TimeUnit;
import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.controller.cluster.access.client.AbstractClientActor;
try {
return (DataStoreClient) Await.result(ExplicitAsk.ask(actor, GET_CLIENT_FACTORY,
Timeout.apply(timeout, unit)), Duration.Inf());
- } catch (RuntimeException e) {
- throw e;
} catch (Exception e) {
- throw new RuntimeException(e);
+ Throwables.throwIfUnchecked(e);
+ throw new IllegalStateException(e);
}
}
}
try {
if (aborted != null) {
Throwables.throwIfUnchecked(aborted);
- throw new RuntimeException(aborted);
+ throw new IllegalStateException(aborted);
}
final ClientLocalHistory history = new ClientLocalHistory(this, historyId);
latch.await();
} catch (InterruptedException e) {
LOG.warn("Interrupted while waiting for latch of {}", successor);
- throw new RuntimeException(e);
+ throw new IllegalStateException(e);
}
return successor;
}
import static com.google.common.base.Verify.verifyNotNull;
import com.google.common.util.concurrent.FluentFuture;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.Optional;
import java.util.OptionalLong;
import java.util.function.BiConsumer;
final DataTreeSnapshot snapshot) {
super(parent, identifier, false);
- if (snapshot instanceof FailedDataTreeModification) {
- final var failed = (FailedDataTreeModification) snapshot;
+ if (snapshot instanceof FailedDataTreeModification failed) {
recordedFailure = failed.cause();
modification = failed;
} else {
closedException = this::abortedException;
}
+ @SuppressFBWarnings(value = "THROWS_METHOD_THROWS_RUNTIMEEXCEPTION", justification = "Replay of recorded failure")
private @NonNull CursorAwareDataTreeModification getModification() {
if (closedException != null) {
throw closedException.get();
LOG.error("Failed to get actor for {}", clientProps, e);
clientActor.tell(PoisonPill.getInstance(), ActorRef.noSender());
Throwables.throwIfUnchecked(e);
- throw new RuntimeException(e);
+ throw new IllegalStateException(e);
}
identifier = client.getIdentifier();
import akka.actor.ActorRef;
import com.google.common.primitives.UnsignedLong;
import com.google.common.util.concurrent.FutureCallback;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.List;
import java.util.Optional;
import java.util.SortedSet;
}
@SuppressWarnings("checkstyle:IllegalCatch")
+ @SuppressFBWarnings(value = "THROWS_METHOD_THROWS_RUNTIMEEXCEPTION", justification = "Re-thrown")
void applyModifications(final List<Modification> modifications) {
totalBatchedModificationsReceived++;
if (lastBatchedModificationsException == null) {
import com.google.common.annotations.VisibleForTesting;
import com.google.common.primitives.UnsignedLong;
import com.google.common.util.concurrent.FutureCallback;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collection;
* @param batched the BatchedModifications message to process
* @param sender the sender of the message
*/
+ @SuppressFBWarnings(value = "THROWS_METHOD_THROWS_RUNTIMEEXCEPTION", justification = "Replay of captured failure")
void handleBatchedModifications(final BatchedModifications batched, final ActorRef sender, final Shard shard) {
CohortEntry cohortEntry = cohortCache.get(batched.getTransactionId());
if (cohortEntry == null || cohortEntry.isSealed()) {
return stateCache.get();
} catch (Exception e) {
Throwables.throwIfUnchecked(e);
- throw new RuntimeException(e);
+ throw new IllegalStateException(e);
}
}
private static List<DataTreeListenerInfo> getListenerActorsInfo(final Collection<ActorSelection> actors) {
final Timeout timeout = new Timeout(20, TimeUnit.SECONDS);
final List<Future<Object>> futureList = new ArrayList<>(actors.size());
- for (ActorSelection actor: actors) {
+ for (ActorSelection actor : actors) {
futureList.add(Patterns.ask(actor, GetInfo.INSTANCE, timeout));
}
} catch (IOException e) {
// This should never happen
LOG.error("Failed to serialize {}", transactionId, e);
- throw new RuntimeException("Failed to serialized " + transactionId, e);
+ throw new IllegalStateException("Failed to serialized " + transactionId, e);
}
return new AbortTransactionPayload(transactionId, out.toByteArray());
}
} catch (IOException e) {
// This should never happen
LOG.error("Failed to serialize {}", historyId, e);
- throw new RuntimeException("Failed to serialize " + historyId, e);
+ throw new IllegalStateException("Failed to serialize " + historyId, e);
}
return new CloseLocalHistoryPayload(historyId, out.toByteArray());
}
} catch (IOException e) {
// This should never happen
LOG.error("Failed to serialize {}", historyId, e);
- throw new RuntimeException("Failed to serialize " + historyId, e);
+ throw new IllegalStateException("Failed to serialize " + historyId, e);
}
return new CreateLocalHistoryPayload(historyId, out.toByteArray());
}
} catch (IOException e) {
// This should never happen
LOG.error("Failed to serialize {}", clientId, e);
- throw new RuntimeException("Failed to serialize " + clientId, e);
+ throw new IllegalStateException("Failed to serialize " + clientId, e);
}
return new DisableTrackingPayload(clientId, out.toByteArray());
}
} catch (IOException e) {
// This should never happen
LOG.error("Failed to serialize {}", historyId, e);
- throw new RuntimeException("Failed to serialize " + historyId, e);
+ throw new IllegalStateException("Failed to serialize " + historyId, e);
}
return new PurgeLocalHistoryPayload(historyId, out.toByteArray());
}
} catch (IOException e) {
// This should never happen
LOG.error("Failed to serialize {}", transactionId, e);
- throw new RuntimeException("Failed to serialize " + transactionId, e);
+ throw new IllegalStateException("Failed to serialize " + transactionId, e);
}
return new PurgeTransactionPayload(transactionId, out.toByteArray());
}
} catch (IOException e) {
// This should never happen
LOG.error("Failed to serialize {} ids {}", historyId, transactionIds, e);
- throw new RuntimeException("Failed to serialize " + historyId + " ids " + transactionIds, e);
+ throw new IllegalStateException("Failed to serialize " + historyId + " ids " + transactionIds, e);
}
return new SkipTransactionsPayload(historyId, out.toByteArray(), transactionIds);
import akka.actor.ActorRef;
import akka.pattern.Patterns;
+import com.google.common.base.Throwables;
import java.util.List;
import org.opendaylight.controller.cluster.access.concepts.MemberName;
import org.opendaylight.controller.cluster.datastore.identifiers.ShardIdentifier;
try {
return (List<String>) Await.result(
Patterns.ask(shardManager, GetLocalShardIds.INSTANCE, ASK_TIMEOUT_MILLIS), Duration.Inf());
- } catch (RuntimeException e) {
- throw e;
} catch (Exception e) {
- throw new RuntimeException(e);
+ Throwables.throwIfUnchecked(e);
+ throw new IllegalStateException(e);
}
}
try {
Await.result(Patterns.ask(shardManager, new SwitchShardBehavior(shardId, state, term),
ASK_TIMEOUT_MILLIS), Duration.Inf());
- } catch (RuntimeException e) {
- throw e;
} catch (Exception e) {
- throw new RuntimeException(e);
+ Throwables.throwIfUnchecked(e);
+ throw new IllegalStateException(e);
}
break;
case Candidate:
output.write(current().node(child).toString().getBytes(StandardCharsets.UTF_8));
output.writeByte('\n');
} catch (IOException e) {
- throw new RuntimeException(e);
+ throw new IllegalStateException(e);
}
}
NormalizedNodeXMLOutput.toStream(output, data);
output.writeByte('\n');
} catch (IOException | XMLStreamException e) {
- throw new RuntimeException(e);
+ throw new IllegalStateException(e);
}
}
}
import akka.util.Timeout;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.Map;
+import java.util.concurrent.TimeoutException;
import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.controller.md.sal.common.util.jmx.AbstractMXBean;
import org.opendaylight.controller.remote.rpc.registry.AbstractRoutingTable;
registerMBean();
}
- @SuppressWarnings({"unchecked", "checkstyle:IllegalCatch", "rawtypes"})
+ @SuppressWarnings({"unchecked", "rawtypes"})
final T localData() {
try {
return (T) Await.result((Future) bucketAccess.getLocalData(), timeout);
- } catch (Exception e) {
- throw new RuntimeException("getLocalData failed", e);
+ } catch (InterruptedException | TimeoutException e) {
+ throw new IllegalStateException("getLocalData failed", e);
}
}
- @SuppressWarnings({"unchecked", "checkstyle:IllegalCatch", "rawtypes"})
+ @SuppressWarnings({"unchecked", "rawtypes"})
final Map<Address, Bucket<T>> remoteBuckets() {
try {
return (Map<Address, Bucket<T>>) Await.result((Future)bucketAccess.getRemoteBuckets(), timeout);
- } catch (Exception e) {
- throw new RuntimeException("getRemoteBuckets failed", e);
+ } catch (InterruptedException | TimeoutException e) {
+ throw new IllegalStateException("getRemoteBuckets failed", e);
}
}
- @SuppressWarnings({"unchecked", "checkstyle:IllegalCatch", "rawtypes"})
+ @SuppressWarnings({"unchecked", "rawtypes"})
final String bucketVersions() {
try {
return Await.result((Future)bucketAccess.getBucketVersions(), timeout).toString();
- } catch (Exception e) {
- throw new RuntimeException("getVersions failed", e);
+ } catch (InterruptedException | TimeoutException e) {
+ throw new IllegalStateException("getVersions failed", e);
}
}
}