Search in sources :

Example 6 with CompositeException

use of rx.exceptions.CompositeException in project azure-sdk-for-java by Azure.

the class LoadBalancerImpl method afterCreating.

@Override
protected void afterCreating() {
    List<Exception> nicExceptions = new ArrayList<>();
    // Update the NICs to point to the backend pool
    for (Entry<String, String> nicInBackend : this.nicsInBackends.entrySet()) {
        String nicId = nicInBackend.getKey();
        String backendName = nicInBackend.getValue();
        try {
            NetworkInterface nic = this.manager().networkInterfaces().getById(nicId);
            NicIPConfiguration nicIP = nic.primaryIPConfiguration();
            nic.update().updateIPConfiguration(nicIP.name()).withExistingLoadBalancerBackend(this, backendName).parent().apply();
        } catch (Exception e) {
            nicExceptions.add(e);
        }
    }
    if (!nicExceptions.isEmpty()) {
        throw new CompositeException(nicExceptions);
    }
    this.nicsInBackends.clear();
    this.refresh();
}
Also used : CompositeException(rx.exceptions.CompositeException) ArrayList(java.util.ArrayList) NetworkInterface(com.microsoft.azure.management.network.NetworkInterface) NicIPConfiguration(com.microsoft.azure.management.network.NicIPConfiguration) CompositeException(rx.exceptions.CompositeException)

Example 7 with CompositeException

use of rx.exceptions.CompositeException in project azure-sdk-for-java by Azure.

the class ExternalChildResourceTests method shouldEmitErrorAfterAllSuccessfulCommit.

@Test
public void shouldEmitErrorAfterAllSuccessfulCommit() throws InterruptedException {
    // Parent resource
    ChickenImpl chicken = new ChickenImpl();
    chicken.defineNewPullet("alice").withAge(1).withFailFlag(PulletImpl.FailFlag.OnCreate).attach().updatePullet("Clover").withAge(2).parent().updatePullet("Goldilocks").withAge(2).withFailFlag(PulletImpl.FailFlag.OnUpdate).parent().withoutPullet("Pinky");
    final List<PulletImpl> changedPuppets = new ArrayList<>();
    final List<Throwable> throwables = new ArrayList<>();
    final CountDownLatch monitor = new CountDownLatch(1);
    PulletsImpl pullets = chicken.pullets();
    pullets.commitAsync().subscribe(new Observer<PulletImpl>() {

        @Override
        public void onCompleted() {
            monitor.countDown();
            Assert.assertTrue("onCompleted should not be invoked", false);
        }

        @Override
        public void onError(Throwable throwable) {
            try {
                CompositeException exception = (CompositeException) throwable;
                Assert.assertNotNull(exception);
                for (Throwable innerThrowable : exception.getExceptions()) {
                    throwables.add(innerThrowable);
                }
            } finally {
                monitor.countDown();
            }
        }

        @Override
        public void onNext(PulletImpl pullet) {
            changedPuppets.add(pullet);
        }
    });
    monitor.await();
    Assert.assertTrue(throwables.size() == 2);
    Assert.assertTrue(changedPuppets.size() == 2);
}
Also used : CompositeException(rx.exceptions.CompositeException) ArrayList(java.util.ArrayList) CountDownLatch(java.util.concurrent.CountDownLatch) Test(org.junit.Test)

Example 8 with CompositeException

use of rx.exceptions.CompositeException in project retrofit by square.

the class CallArbiter method deliverResponse.

private void deliverResponse(Response<T> response) {
    try {
        if (!isUnsubscribed()) {
            subscriber.onNext(response);
        }
    } catch (Throwable t) {
        Exceptions.throwIfFatal(t);
        try {
            subscriber.onError(t);
        } catch (Throwable inner) {
            Exceptions.throwIfFatal(inner);
            CompositeException composite = new CompositeException(t, inner);
            RxJavaPlugins.getInstance().getErrorHandler().handleError(composite);
        }
        return;
    }
    try {
        subscriber.onCompleted();
    } catch (Throwable t) {
        Exceptions.throwIfFatal(t);
        RxJavaPlugins.getInstance().getErrorHandler().handleError(t);
    }
}
Also used : CompositeException(rx.exceptions.CompositeException)

Aggregations

CompositeException (rx.exceptions.CompositeException)8 ArrayList (java.util.ArrayList)4 Test (org.junit.Test)3 CountDownLatch (java.util.concurrent.CountDownLatch)2 Observable (rx.Observable)2 Func1 (rx.functions.Func1)2 TestSubscriber (rx.observers.TestSubscriber)2 GenericDebuggerRunner (com.intellij.debugger.impl.GenericDebuggerRunner)1 GenericDebuggerRunnerSettings (com.intellij.debugger.impl.GenericDebuggerRunnerSettings)1 ExecutionException (com.intellij.execution.ExecutionException)1 Executor (com.intellij.execution.Executor)1 ConfigurationInfoProvider (com.intellij.execution.configurations.ConfigurationInfoProvider)1 RemoteConnection (com.intellij.execution.configurations.RemoteConnection)1 RunProfile (com.intellij.execution.configurations.RunProfile)1 RunProfileState (com.intellij.execution.configurations.RunProfileState)1 DefaultDebugExecutor (com.intellij.execution.executors.DefaultDebugExecutor)1 ExecutionEnvironment (com.intellij.execution.runners.ExecutionEnvironment)1 JSchException (com.jcraft.jsch.JSchException)1 HDInsightUtil (com.microsoft.azure.hdinsight.common.HDInsightUtil)1 IClusterDetail (com.microsoft.azure.hdinsight.sdk.cluster.IClusterDetail)1