@Override public void onError(Throwable t) { errorFuture.setException(t); }
@Override public void onError(Throwable throwable) { result.setException(throwable); }
@Override protected void onErrorImpl(Throwable t) { done.setException(t); }
@Override public void onError(Throwable t) { completionFuture.setException(t); }
@Override public void onFailure(Throwable t) { try { for (OutstandingPublish outstandingPublish : outstandingBatch.outstandingPublishes) { outstandingPublish.publishResult.setException(t); } } finally { messagesWaiter.incrementPendingMessages(-outstandingBatch.size()); } } });
@Override public void onError(Throwable throwable) { tracer.getCurrentSpan().addAnnotation("Firestore.BatchGet: Error"); futureList.setException(throwable); }
@Override public void run() { try { if (ackHandler .totalExpiration .plusSeconds(messageDeadlineSeconds.get()) .isBefore(now())) { // Message expired while waiting. We don't extend these messages anymore, // so it was probably sent to someone else. Don't work on it. // Don't nack it either, because we'd be nacking someone else's message. ackHandler.forget(); return; } receiver.receiveMessage(message, consumer); } catch (Exception e) { response.setException(e); } } });
@Override public void onSuccess(PublishResponse result) { try { if (result.getMessageIdsCount() != outstandingBatch.size()) { Throwable t = new IllegalStateException( String.format( "The publish result count %s does not match " + "the expected %s results. Please contact Cloud Pub/Sub support " + "if this frequently occurs", result.getMessageIdsCount(), outstandingBatch.size())); for (OutstandingPublish oustandingMessage : outstandingBatch.outstandingPublishes) { oustandingMessage.publishResult.setException(t); } return; } Iterator<OutstandingPublish> messagesResultsIt = outstandingBatch.outstandingPublishes.iterator(); for (String messageId : result.getMessageIdsList()) { messagesResultsIt.next().publishResult.set(messageId); } } finally { messagesWaiter.incrementPendingMessages(-outstandingBatch.size()); } }
private void rejectTransaction(final Throwable throwable) { if (throwable instanceof ApiException) { span.setStatus(TraceUtil.statusFromApiException((ApiException) throwable)); } span.end(); if (transaction.isPending()) { ApiFutures.addCallback( transaction.rollback(), new ApiFutureCallback<Void>() { @Override public void onFailure(Throwable throwable) { resultFuture.setException(throwable); } @Override public void onSuccess(Void ignored) { resultFuture.setException(throwable); } }); } else { resultFuture.setException(throwable); } } });
@Test public void errorIsPropagated() throws Exception { ApiFuture<List<KeyOffset>> result = callable.futureCall("my-table"); Throwable expectedError = new NotFoundException("fake error", null, GrpcStatusCode.of(Code.NOT_FOUND), false); inner.response.setException(expectedError); Throwable actualError = null; try { result.get(1, TimeUnit.SECONDS); } catch (ExecutionException e) { actualError = e.getCause(); } assertThat(actualError).isEqualTo(expectedError); }
@Override public void onEvent( @Nullable QuerySnapshot actualSnapshot, @Nullable FirestoreException error) { try { if (actualSnapshot != null) { Assert.assertNull(error); Assert.assertFalse(expectedSnapshots.isEmpty()); Snapshot expectedSnapshot = expectedSnapshots.remove(0); Assert.assertEquals(convertQuerySnapshot(expectedSnapshot), actualSnapshot); if (expectedSnapshots.isEmpty()) { if (!testCase.getIsError()) { testCaseFinished.set(null); } } } else { // Error case Assert.assertNotNull(error); Assert.assertTrue(expectedSnapshots.isEmpty()); Assert.assertTrue(testCase.getIsError()); testCaseFinished.set(null); } } catch (AssertionError e) { testCaseFinished.setException(e); } } });
@Test public void errorIsPropagated() throws Exception { ApiFuture<Row> result = callable.futureCall( ReadModifyWriteRow.create("my-table", "my-key").append("my-family", "", "suffix")); Throwable expectedError = new NotFoundException("fake error", null, GrpcStatusCode.of(Code.NOT_FOUND), false); inner.response.setException(expectedError); Throwable actualError = null; try { result.get(1, TimeUnit.SECONDS); } catch (ExecutionException e) { actualError = e.getCause(); } assertThat(actualError).isEqualTo(expectedError); }
@Test public void errorIsPropagated() throws Exception { ApiFuture<Boolean> result = callable.futureCall( ConditionalRowMutation.create("my-table", "row-key") .then(Mutation.create().deleteRow())); Throwable expectedError = new NotFoundException("fake error", null, GrpcStatusCode.of(Code.NOT_FOUND), false); inner.response.setException(expectedError); Throwable actualError = null; try { result.get(1, TimeUnit.SECONDS); } catch (ExecutionException e) { actualError = e.getCause(); } assertThat(actualError).isEqualTo(expectedError); }
@Test public void bulkMutationsBatchingFailureTest() throws Exception { BulkMutationBatcher batcher = bigtableDataClient.newBulkMutationBatcher(); RowMutation request = RowMutation.create("fake-table", "some-key") .setCell("some-family", "fake-qualifier", "fake-value"); SettableApiFuture<Void> innerResult = SettableApiFuture.create(); Mockito.when(mockBulkMutateRowsBatchingCallable.futureCall(request)).thenReturn(innerResult); ApiException innerError = new ApiException(null, GrpcStatusCode.of(Code.INTERNAL), false); batcher.add(request); innerResult.setException(innerError); Throwable outerError = null; try { batcher.close(Duration.ofMillis(10)); } catch (Throwable t) { outerError = t; } assertThat(outerError).isInstanceOf(BulkMutationFailure.class); }
@Override public void onFailure(Throwable t) { flowController.release(batch); retFuture.setException(t); } },
@Override protected void onErrorImpl(Throwable t) { done.setException(t); }
@Override public void onFailure(Throwable t) { flowController.release(batch); retFuture.setException(t); } },
@Override public void onComplete(DatabaseError error, DatabaseReference ref) { if (error != null) { future.setException(error.toException()); } else { future.set(null); } } };
@Override public void onError(Throwable throwable) { tracer.getCurrentSpan().addAnnotation("Firestore.BatchGet: Error"); futureList.setException(throwable); }
@Test public void testOperationFailed() { RuntimeException fakeError = new RuntimeException("fake error"); innerResult.setException(fakeError); tracedUnaryCallable.futureCall("test", callContext); verify(tracer, times(1)).operationFailed(fakeError); }