Skip to content

Commit

Permalink
Invoke callback first then signal future
Browse files Browse the repository at this point in the history
  • Loading branch information
anuchandy committed Aug 11, 2016
1 parent 61e0635 commit 5b2c095
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ protected CreatableResourcesImpl() {
@SafeVarargs
public final CreatedResources<T> create(Creatable<T> ... creatables) throws Exception {
ServiceCall<CreatedResources<T>> serviceCall = createAsync(null, creatables);
serviceCall.wait();
return serviceCall.get().getBody();
}

Expand Down Expand Up @@ -326,18 +325,18 @@ ServiceCallback<CreatableResourcesRoot<T>> wrapCallback(final ServiceCallback<Cr
return new ServiceCallback<CreatableResourcesRoot<T>>() {
@Override
public void failure(Throwable t) {
self.failure(t);
if (innerCallback != null) {
innerCallback.failure((t));
}
self.failure(t); // Signal Future
}

@Override
public void success(ServiceResponse<CreatableResourcesRoot<T>> result) {
self.success(new ServiceResponse<CreatedResources<T>>(new CreatedResourcesImpl<>(result.getBody()), null));
if (innerCallback != null) {
innerCallback.success(new ServiceResponse<CreatedResources<T>>(new CreatedResourcesImpl<>(result.getBody()), null));
}
self.success(new ServiceResponse<CreatedResources<T>>(new CreatedResourcesImpl<>(result.getBody()), null)); // Signal Future
}
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ public void failure(Throwable t) {
if (self.failureHandler != null) {
self.failureHandler.failure(t);
}
self.failure(t);
callback.failure(t);
self.failure(t); // Signal Future
}

@Override
Expand All @@ -66,8 +66,8 @@ public void success(ServiceResponse<InnerModelT> response) {
self.successHandler.success(response);
}
if (reportSuccess) {
self.success(new ServiceResponse<Resource>(self.fluentModelImpl, response.getResponse()));
callback.success(new ServiceResponse<Resource>(self.fluentModelImpl, response.getResponse()));
self.success(new ServiceResponse<Resource>(self.fluentModelImpl, response.getResponse())); // Signal Future
}
}
};
Expand Down

0 comments on commit 5b2c095

Please sign in to comment.