rx.exceptions.CompositeException Java Examples
The following examples show how to use
rx.exceptions.CompositeException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WaitForHealthCheck.java From sfs with Apache License 2.0 | 6 votes |
@Override public Observable<Void> call(Void aVoid) { Func0<Observable<Void>> func0 = () -> { StringBuilder urlBuilder = new StringBuilder(); urlBuilder = urlBuilder.append("/admin/001/healthcheck"); ObservableFuture<HttpClientResponse> httpHandler = RxHelper.observableFuture(); HttpClientRequest httpClientRequest = httpClient.get(urlBuilder.toString(), httpHandler::complete) .exceptionHandler(httpHandler::fail) .setTimeout(5000); httpClientRequest.end(); return httpHandler.flatMap(new HttpClientResponseBodyBuffer()) .map(new ToVoid<>()); }; List<Throwable> errors = new ArrayList<>(); return Observable.just((Void) null) .flatMap(aVoid1 -> RxHelper.onErrorResumeNext(20, func0)) .onErrorResumeNext(throwable -> { LOGGER.warn("Handling connect failure to health check", throwable); errors.add(throwable); return Observable.error(new CompositeException(errors)); }); }
Example #2
Source File: BodyOnSubscribe.java From okhttp-OkGo with Apache License 2.0 | 6 votes |
@Override public void onNext(Response<R> response) { if (response.isSuccessful()) { subscriber.onNext(response.body()); } else { subscriberTerminated = true; Throwable t = new HttpException(response); try { subscriber.onError(t); } catch (OnCompletedFailedException | OnErrorFailedException | OnErrorNotImplementedException e) { RxJavaHooks.getOnError().call(e); } catch (Throwable inner) { Exceptions.throwIfFatal(inner); RxJavaHooks.getOnError().call(new CompositeException(t, inner)); } } }
Example #3
Source File: ResultOnSubscribe.java From okhttp-OkGo with Apache License 2.0 | 6 votes |
@Override public void onError(Throwable throwable) { try { subscriber.onNext(Result.<R>error(throwable)); } catch (Throwable t) { try { subscriber.onError(t); } catch (OnCompletedFailedException | OnErrorFailedException | OnErrorNotImplementedException e) { RxJavaHooks.getOnError().call(e); } catch (Throwable inner) { Exceptions.throwIfFatal(inner); RxJavaHooks.getOnError().call(new CompositeException(t, inner)); } return; } subscriber.onCompleted(); }
Example #4
Source File: ParserException.java From base_app_android with Apache License 2.0 | 6 votes |
@Override public Observable<String> react() { String message = throwable.getMessage(); if (throwable instanceof CompositeException) { message += System.getProperty("line.separator"); CompositeException compositeException = (CompositeException) throwable; for (Throwable exception : compositeException.getExceptions()) { String exceptionName = exception.getClass().getSimpleName(); String exceptionMessage = exception.getMessage() != null ? exception.getMessage() : ""; message += exceptionName + " -> " + exceptionMessage + System.getProperty("line.separator"); } } return Observable.just(message); }
Example #5
Source File: OperatorParallelMerge.java From RxJavaParallel with Apache License 2.0 | 6 votes |
private void drainAndComplete() { drainQueuesIfNeeded(); // TODO need to confirm whether this is needed or not if (delayErrors) { Queue<Throwable> es = null; synchronized (this) { es = exceptions; } if (es != null) { if (es.isEmpty()) { actual.onCompleted(); } else if (es.size() == 1) { actual.onError(es.poll()); } else { actual.onError(new CompositeException(es)); } } else { actual.onCompleted(); } } else { actual.onCompleted(); } }
Example #6
Source File: LoadBalancerImpl.java From azure-libraries-for-java with MIT License | 5 votes |
@Override protected void afterCreating() { if (this.nicsInBackends != null) { 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(); } }
Example #7
Source File: ErrorResponses.java From titus-control-plane with Apache License 2.0 | 5 votes |
private static Throwable unwrap(Throwable throwable) { if (throwable instanceof CompositeException) { CompositeException composite = (CompositeException) throwable; if (composite.getExceptions().size() == 1) { return composite.getExceptions().get(0); } } return throwable; }
Example #8
Source File: GrpcExceptionMapper.java From titus-control-plane with Apache License 2.0 | 5 votes |
private static Throwable unwrap(Throwable throwable) { if (throwable instanceof CompositeException) { CompositeException composite = (CompositeException) throwable; if (composite.getExceptions().size() == 1) { return composite.getExceptions().get(0); } } return throwable; }
Example #9
Source File: KeepAliveHttpServerResponse.java From sfs with Apache License 2.0 | 5 votes |
public KeepAliveHttpServerResponse(VertxContext<Server> vertxContext, long timeout, TimeUnit timeUnit, HttpServerResponse delegate) { this.vertxContext = vertxContext; this.delegate = delegate; this.timeout = timeUnit.toMillis(timeout); delegate.setChunked(true); delegate.exceptionHandler(exception -> { ObservableFuture<Void> handler = RxHelper.observableFuture(); stopKeepAlive(handler); handler.subscribe(new Subscriber<Void>() { @Override public void onCompleted() { handleThrowable(exception); } @Override public void onError(Throwable e) { handleThrowable(new CompositeException(exception, e)); } @Override public void onNext(Void aVoid) { } }); }); startKeepAlive(); }
Example #10
Source File: CallArbiter.java From okhttp-OkGo with Apache License 2.0 | 5 votes |
void emitError(Throwable t) { set(STATE_TERMINATED); if (!isUnsubscribed()) { try { subscriber.onError(t); } catch (OnCompletedFailedException | OnErrorFailedException | OnErrorNotImplementedException e) { RxJavaHooks.getOnError().call(e); } catch (Throwable inner) { Exceptions.throwIfFatal(inner); RxJavaHooks.getOnError().call(new CompositeException(t, inner)); } } }
Example #11
Source File: OrderedMerge.java From rxjava-extras with Apache License 2.0 | 5 votes |
void reportErrorOrComplete(Subscriber<? super T> child) { if (delayErrors && !errors.isEmpty()) { if (errors.size() == 1) { child.onError(errors.poll()); } else { child.onError(new CompositeException(errors)); } } else { child.onCompleted(); } }
Example #12
Source File: SortedMerge.java From hawkular-metrics with Apache License 2.0 | 5 votes |
protected void reportErrorOrComplete(Subscriber<? super T> child) { if (delayErrors && !errors.isEmpty()) { if (errors.size() == 1) { child.onError(errors.poll()); } else { child.onError(new CompositeException(errors)); } } else { child.onCompleted(); } }
Example #13
Source File: ExternalChildResourceTests.java From azure-libraries-for-java with MIT License | 4 votes |
@Test public void shouldEmitErrorAfterAllSuccessfulCommit() throws InterruptedException { ChickenImpl chicken = new ChickenImpl(); // Parent resource 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); }
Example #14
Source File: JournalFile.java From sfs with Apache License 2.0 | 4 votes |
public Observable<Void> open(SfsVertx vertx) { return aVoid() .flatMap(aVoid -> { // do some funcky stuff here to read the existing super block so that // we have enough information to access the journal entries BlobFile internalBlobFile = new BlobFile(path, SUPER_BLOCK_SIZE, DEFAULT_WRITE_STREAM_TIMEOUT); return internalBlobFile.open(vertx, CREATE_NEW, READ, WRITE) .flatMap(aVoid1 -> internalBlobFile.enableWrites(vertx)) .flatMap(aVoid1 -> { Super superBlock = newBuilder() .setBlockSize(DEFAULT_BLOCK_SIZE) .build(); return setSuperBlock(vertx, internalBlobFile, superBlock) .map(aVoid11 -> superBlock); }) .onErrorResumeNext(throwable -> { if (containsException(FileAlreadyExistsException.class, throwable)) { return internalBlobFile.close(vertx) .flatMap(aVoid1 -> internalBlobFile.open(vertx, CREATE, READ, WRITE)) .flatMap(aVoid1 -> internalBlobFile.enableWrites(vertx)) .flatMap(aVoid1 -> getSuperBlock(vertx, internalBlobFile)); } else { return error(throwable); } }) .doOnNext(superBlock -> { blockSize = superBlock.getBlockSize(); logStartPosition = up(SUPER_BLOCK_RESERVED, blockSize); }) .map(new ToVoid<>()) .flatMap(aVoid1 -> internalBlobFile.disableWrites(vertx)) .flatMap(aVoid1 -> internalBlobFile.force(vertx, true)) .onErrorResumeNext(throwable -> { if (!STOPPED.equals(blobFile.getStatus())) { return internalBlobFile.close(vertx) .onErrorResumeNext(throwable1 -> { return error(new CompositeException(throwable, throwable1)); }); } else { return error(throwable); } }) .flatMap(aVoid1 -> internalBlobFile.close(vertx)); }) .flatMap(aVoid -> { blobFile = new BlobFile(path, blockSize, DEFAULT_WRITE_STREAM_TIMEOUT); return blobFile.open(vertx, CREATE, READ, WRITE); }); }