tcs = tcss.get(i); if (task.isFaulted()) { tcs.setError(task.getError()); } else { tcs.setCancelled(); tcs.setError(new IllegalStateException( "Batch command result count expected: " + batchSize + " but was: " + resultLength)); } else if (result.has("error")) { JSONObject error = result.getJSONObject("error"); tcs.setError(new ParseException(error.getInt("code"), error.getString("error")));
@Override public Task<JSONObject> then(Task<JSONObject> task) { String localId = command.getLocalId(); Exception error = task.getError(); if (error != null) { if (error instanceof ParseException && ((ParseException) error).getCode() == ParseException.CONNECTION_FAILED) { // do nothing } else { if (tcs != null) { tcs.setError(error); } } return task; } JSONObject json = task.getResult(); if (tcs != null) { tcs.setResult(json); } else if (localId != null) { // If this command created a new objectId, add it to the map. String objectId = json.optString("objectId", null); if (objectId != null) { ParseCorePlugins.getInstance() .getLocalIdManager().setObjectId(localId, objectId); } } return task; } });
tcs.setError(new IllegalStateException("This object must have already been " + "fetched from the local datastore, but isn't marked as fetched.")); synchronized (lock) {
@Override public void disconnected() { rollbackTimestamps.putAll(lastTimestamp); TaskCompletionSource<Void> taskSource = downloadTask.getAndSet(null); if (taskSource != null) { taskSource.setError(new RuntimeException("Lost connection while downloading log data")); } }
@Override public Task<Route> queueRouteBuilder(RouteBuilder builder, String producerTag) { TaskCompletionSource<Route> taskSrc= new TaskCompletionSource<>(); if (persist.taggedProducers.containsKey(producerTag)) { pendingRoutes.add(new Tuple3<>(builder, new RouteComponentImpl(persist.taggedProducers.get(producerTag)), taskSrc)); routeTypes.add(RouteType.DATA); createRoute(false); } else { taskSrc.setError(new NullPointerException(String.format(Locale.US, "Producer tag \'%s\' does not exist", producerTag))); } return taskSrc.getTask(); }
private void executeGattOperation(boolean ready) { if (!pendingGattOps.isEmpty() && (pendingGattOps.size() == 1 || ready)) { GattOp next = pendingGattOps.peek(); gattOpTask.execute(next.msg, 1000, next.task).continueWith(task -> { if (task.isFaulted()) { next.taskSource.setError(task.getError()); } else if (task.isCancelled()) { next.taskSource.setCancelled(); } else { next.taskSource.setResult(task.getResult()); } pendingGattOps.poll(); next.owner.gattTaskCompleted(); executeGattOperation(true); return null; }); } }
persist.taggedProducers.remove(it); current.third.setError(task.getError()); } else { HashSet<String> processorNames = new HashSet<>(); }).continueWith(task -> { if (task.isFaulted()) { current.first.setError(task.getError()); } else { current.first.setResult(mwTimer.createTimedEventManager(ScheduledTaskId.get(), task.getResult())); event.queueEvents(eventCodeBlocks).continueWith(task -> { if (task.isFaulted()) { current.first.setError(task.getError()); } else { ObserverInner newManager= new ObserverInner(persist.routeIdCounter, task.getResult());