com.microsoft.azure.servicebus.Utils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of azure-servicebus Show documentation
Show all versions of azure-servicebus Show documentation
Java library for Azure Service Bus
The newest version!
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
package com.microsoft.azure.servicebus;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import com.microsoft.azure.servicebus.primitives.ServiceBusException;
public final class Utils {
public static T completeFuture(CompletableFuture future) throws InterruptedException, ServiceBusException {
try {
return future.get();
} catch (InterruptedException ie) {
// Rare instance
throw ie;
} catch (ExecutionException ee) {
Throwable cause = ee.getCause();
if (cause instanceof RuntimeException) {
throw (RuntimeException) cause;
} else if (cause instanceof Error) {
throw (Error) cause;
} else if (cause instanceof ServiceBusException) {
throw (ServiceBusException) cause;
} else {
throw new ServiceBusException(true, cause);
}
}
}
static void assertNonNull(String argumentName, Object argument) {
if (argument == null) {
throw new IllegalArgumentException("Argument '" + argumentName + "' is null.");
}
}
static MessageBody fromSequence(List
© 2015 - 2024 Weber Informatics LLC | Privacy Policy