Skip to content

Commit deee859

Browse files
authored
update terminate and responseCallback methods to return Optional.absent() in IDLE/TERMINATED state (#4383)
1 parent a711e8f commit deee859

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

apollo-runtime/src/main/java/com/apollographql/apollo/internal/RealApolloCall.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -363,8 +363,7 @@ synchronized Optional<Callback<T>> responseCallback() {
363363
return Optional.fromNullable(originalCallback.get());
364364
case IDLE:
365365
case TERMINATED:
366-
throw new IllegalStateException(
367-
CallState.IllegalStateMessage.forCurrentState(state.get()).expected(ACTIVE, CANCELED));
366+
return Optional.absent();
368367
default:
369368
throw new IllegalStateException("Unknown state");
370369
}
@@ -380,8 +379,7 @@ synchronized Optional<Callback<T>> terminate() {
380379
return Optional.fromNullable(originalCallback.getAndSet(null));
381380
case IDLE:
382381
case TERMINATED:
383-
throw new IllegalStateException(
384-
CallState.IllegalStateMessage.forCurrentState(state.get()).expected(ACTIVE, CANCELED));
382+
return Optional.absent();
385383
default:
386384
throw new IllegalStateException("Unknown state");
387385
}

0 commit comments

Comments
 (0)