Source:
private void refreshAccessToken(final AuthenticationServer authServer) { clearScheduledAccessTokenRefresh(); Future<?> task = SyncManager.NETWORK_POOL_EXECUTOR.submit(new ExponentialBackoffTask<AuthenticateResponse>() { @Override protected AuthenticateResponse execute() { if (!isClosed && !Thread.currentThread().isInterrupted()) { return authServer.refreshUser(getUser().getSyncUser().getUserToken(), configuration.getServerUrl(), getUser().getSyncUser().getAuthenticationUrl()); } return null; } @Override protected void onSuccess(AuthenticateResponse response) { synchronized (SyncSession.this) { if (!isClosed && !Thread.currentThread().isInterrupted()) { RealmLog.debug("Access Token refreshed successfully"); if (nativeRefreshAccessToken(configuration.getPath(), response.getAccessToken().value(), configuration.getUser().getAuthURL())) { ObjectServerUser.AccessDescription desc = new ObjectServerUser.AccessDescription( response.getAccessToken(), configuration.getPath(), configuration.shouldDeleteRealmOnLogout() ); getUser().getSyncUser().addRealm(configuration.getServerUrl(), desc); scheduleRefreshAccessToken(authServer, response.getAccessToken().expiresMs()); } } } } @Override protected void onError(AuthenticateResponse response) { if (!isClosed && !Thread.currentThread().isInterrupted()) { onGoingAccessTokenQuery.set(false); RealmLog.error("Unrecoverable error, while refreshing the access Token (" + response.getError().toString() + ") reschedule will not happen"); } } }); refreshTokenNetworkRequest = new RealmAsyncTaskImpl(task, SyncManager.NETWORK_POOL_EXECUTOR); }

Target:
private void refreshAccessToken(final AuthenticationServer authServer) { clearScheduledAccessTokenRefresh(); Future<?> task = SyncManager.NETWORK_POOL_EXECUTOR.submit(new ExponentialBackoffTask<AuthenticateResponse>() { @Override protected AuthenticateResponse execute() { if (!isClosed && !Thread.currentThread().isInterrupted()) { return authServer.refreshUser(getUser().getSyncUser().getUserToken(), configuration.getServerUrl(), getUser().getSyncUser().getAuthenticationUrl()); } return null; } @Override protected void onSuccess(AuthenticateResponse response) { synchronized (SyncSession.this) { if (!isClosed && !Thread.currentThread().isInterrupted()) { RealmLog.debug("Access Token refreshed successfully, Sync URL: " + configuration.getServerUrl()); if (nativeRefreshAccessToken(configuration.getPath(), response.getAccessToken().value(), configuration.getUser().getAuthenticationUrl().toString())) { ObjectServerUser.AccessDescription desc = new ObjectServerUser.AccessDescription( response.getAccessToken(), configuration.getPath(), configuration.shouldDeleteRealmOnLogout() ); getUser().getSyncUser().addRealm(configuration.getServerUrl(), desc); scheduleRefreshAccessToken(authServer, response.getAccessToken().expiresMs()); } } } } @Override protected void onError(AuthenticateResponse response) { if (!isClosed && !Thread.currentThread().isInterrupted()) { onGoingAccessTokenQuery.set(false); RealmLog.error("Unrecoverable error, while refreshing the access Token (" + response.getError().toString() + ") reschedule will not happen"); } } }); refreshTokenNetworkRequest = new RealmAsyncTaskImpl(task, SyncManager.NETWORK_POOL_EXECUTOR); }