Source:
public Bundle getAuthToken(final Context context, final Bundle requestBundle, final BrokerEvent brokerEvent) throws AuthenticationException { final CountDownLatch countDownLatch = new CountDownLatch(1); final AtomicReference<Bundle> bundleResult = new AtomicReference<>(null); final AtomicReference<Throwable> exception = new AtomicReference<>(null); performAsyncCallOnBound(context, new Callback<BrokerAccountServiceConnection>() { @Override public void onSuccess(BrokerAccountServiceConnection result) { final IBrokerAccountService brokerAccountService = result.getBrokerAccountServiceProvider(); try { bundleResult.set(brokerAccountService.acquireTokenSilently(prepareGetAuthTokenRequestData(context, requestBundle))); } catch (final RemoteException remoteException) { exception.set(remoteException); } countDownLatch.countDown(); } @Override public void onError(Throwable throwable) { exception.set(throwable); countDownLatch.countDown(); } }, brokerEvent); try { countDownLatch.await(); } catch (final InterruptedException e) { exception.set(e); } final Throwable throwable = exception.getAndSet(null); if (throwable != null) { if (throwable instanceof RemoteException) { Logger.e(TAG, "Get error when trying to get token from broker: " + throwable.getMessage(), "", ADALError.BROKER_AUTHENTICATOR_NOT_RESPONDING, throwable); throw new AuthenticationException(ADALError.BROKER_AUTHENTICATOR_NOT_RESPONDING, throwable.getMessage(), throwable); } else if (throwable instanceof InterruptedException) { Logger.v(TAG, "The thread is interrupted while it is sleeping. " + throwable.getMessage()); } else { Logger.e(TAG, "Get error when trying to bond the broker account service." + throwable.getMessage(), "", ADALError.BROKER_AUTHENTICATOR_NOT_RESPONDING, throwable); throw new AuthenticationException(ADALError.BROKER_AUTHENTICATOR_NOT_RESPONDING, throwable.getMessage(), throwable); } } return bundleResult.getAndSet(null); }

Target:
public Bundle getAuthToken(final Context context, final Bundle requestBundle, final BrokerEvent brokerEvent) throws AuthenticationException { final CountDownLatch countDownLatch = new CountDownLatch(1); final AtomicReference<Bundle> bundleResult = new AtomicReference<>(null); final AtomicReference<Throwable> exception = new AtomicReference<>(null); performAsyncCallOnBound(context, new Callback<BrokerAccountServiceConnection>() { @Override public void onSuccess(BrokerAccountServiceConnection result) { final IBrokerAccountService brokerAccountService = result.getBrokerAccountServiceProvider(); try { bundleResult.set(brokerAccountService.acquireTokenSilently(prepareGetAuthTokenRequestData(context, requestBundle))); } catch (final RemoteException remoteException) { exception.set(remoteException); } countDownLatch.countDown(); } @Override public void onError(Throwable throwable) { exception.set(throwable); countDownLatch.countDown(); } }, brokerEvent); try { countDownLatch.await(); } catch (final InterruptedException e) { exception.set(e); } final Throwable throwable = exception.getAndSet(null); if (throwable != null) { if (throwable instanceof RemoteException) { Logger.e(TAG, "Get error when trying to get token from broker: " + throwable.getMessage(), "", ADALError.BROKER_AUTHENTICATOR_NOT_RESPONDING, throwable); throw new AuthenticationException(ADALError.BROKER_AUTHENTICATOR_NOT_RESPONDING, throwable.getMessage(), throwable); } else if (throwable instanceof InterruptedException) { Logger.e(TAG, "The broker account service binding call is interrupted. " + throwable.getMessage(), "", ADALError.BROKER_AUTHENTICATOR_EXCEPTION, throwable); throw new AuthenticationException(ADALError.BROKER_AUTHENTICATOR_NOT_RESPONDING, throwable.getMessage(), throwable); } else { Logger.e(TAG, "Get error when trying to bind the broker account service." + throwable.getMessage(), "", ADALError.BROKER_AUTHENTICATOR_NOT_RESPONDING, throwable); throw new AuthenticationException(ADALError.BROKER_AUTHENTICATOR_NOT_RESPONDING, throwable.getMessage(), throwable); } } return bundleResult.getAndSet(null); }