Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
manueliglesias committed Jan 1, 2023
1 parent 0bbb614 commit 945e5a9
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,6 @@ public void onResponse(@NonNull Call call, @NonNull Response response) {
if (responseBody != null) {
try {
jsonResponse = responseBody.string();

LOG.debug(String.format("Response: %s", jsonResponse));
} catch (IOException exception) {
LOG.warn("Error retrieving JSON from response.", exception);
onFailure.accept(new ApiException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,6 @@ synchronized <T> void requestSubscription(
.put("authorization", authorizer.createHeadersForSubscription(request, authType))))
.toString();

LOG.verbose(String.format("Outgoing WebSocket message: %s", jsonMessage));

webSocket.send(jsonMessage);
} catch (JSONException | ApiException exception) {
// If the subscriptionId was still pending, then we can call the onSubscriptionError
Expand Down Expand Up @@ -274,8 +272,6 @@ synchronized void releaseSubscription(String subscriptionId) throws ApiException
.put("id", subscriptionId)
.toString();

LOG.verbose(String.format("Outgoing WebSocket message: %s", jsonMessage));

webSocket.send(jsonMessage);
} catch (JSONException jsonException) {
throw new ApiException(
Expand Down Expand Up @@ -568,8 +564,6 @@ private void sendConnectionInit(WebSocket webSocket) {
.put("type", "connection_init")
.toString();

LOG.verbose(String.format("Outgoing WebSocket message: %s", jsonMessage));

webSocket.send(jsonMessage);
} catch (JSONException jsonException) {
notifyError(jsonException);
Expand All @@ -582,8 +576,6 @@ private void processJsonMessage(WebSocket webSocket, String message) throws ApiE
final SubscriptionMessageType subscriptionMessageType =
SubscriptionMessageType.from(jsonMessage.getString("type"));

LOG.verbose(String.format("Incoming WebSocket message: %s", jsonMessage));

switch (subscriptionMessageType) {
case CONNECTION_ACK:
timeoutWatchdog.start(() -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,8 @@ public ApiKeyRequestDecorator(@NonNull ApiKeyAuthProvider apiKeyProvider) {

@Override
public okhttp3.Request decorate(okhttp3.Request request) {
String apiKey = apiKeyProvider.getAPIKey();

return request.newBuilder()
.addHeader(X_API_KEY, apiKey)
.addHeader(X_API_KEY, apiKeyProvider.getAPIKey())
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ protected <T> Single<T> retry(Single<T> single, List<Class<? extends Throwable>>


/**
* Method returns jittered delay time in milliseconds.
* Method returns a jittered 2^numAttempt delay time in milliseconds.
*
* @param numAttempt Attempt number.
* @return delay in milliseconds.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,17 +273,13 @@ private <T extends Model> Single<PaginatedResult<ModelWithMetadata<T>>> syncPage

// We don't want to treat DataStoreException.GraphQLResponseException as non retryable here because we want to
// support merging the applicable data if any.
// TODO: Merge applicable data if any, and log errors
List<Class<? extends Throwable>> nonRetryableExceptions = new ArrayList<>();
nonRetryableExceptions.add(DataStoreException.IrRecoverableException.class);
nonRetryableExceptions.add(ApiException.NonRetryableException.class);

return requestRetry.retry(Single.create(emitter -> {
Cancelable cancelable = appSync.sync(request, result -> {
if (result.hasErrors()) {
// TODO: Check if there is applicable data, if so, emit it but also log the errors.
// For now, we treat any error as irrecoverable

emitter.onError(new DataStoreException.IrRecoverableException(
String.format("A model sync failed: %s", result.getErrors()),
"Check your schema."
Expand Down

0 comments on commit 945e5a9

Please sign in to comment.