Source:
<code>private void performAuthorityValidation(final AuthenticationRequest authenticationRequest, final URL authorityUrl) throws AuthenticationException { Telemetry.getInstance().startEvent(authenticationRequest.getTelemetryRequestId(), EventStrings.AUTHORITY_VALIDATION_EVENT); APIEvent apiEvent = new APIEvent(EventStrings.AUTHORITY_VALIDATION_EVENT); apiEvent.setCorrelationId(authenticationRequest.getCorrelationId().toString()); apiEvent.setRequestId(authenticationRequest.getTelemetryRequestId()); if (mAuthContext.getValidateAuthority()) { try { validateAuthority(authorityUrl, authenticationRequest.getUpnSuffix(), authenticationRequest.isSilent(), authenticationRequest.getCorrelationId()); apiEvent.setValidationStatus(EventStrings.AUTHORITY_VALIDATION_SUCCESS); } catch (AuthenticationException ex) { apiEvent.setValidationStatus(EventStrings.AUTHORITY_VALIDATION_FAILURE); throw ex; } finally { Telemetry.getInstance().stopEvent(authenticationRequest.getTelemetryRequestId(), apiEvent, EventStrings.AUTHORITY_VALIDATION_EVENT); } } else { if (!UrlExtensions.isADFSAuthority(authorityUrl) && !AuthorityValidationMetadataCache.containsAuthorityHost(authorityUrl)) { <START> HttpWebRequest.throwIfNetworkNotAvailable(mContext); <END> try { mDiscovery.validateAuthority(authorityUrl); } catch (final AuthenticationException authenticationException) { AuthorityValidationMetadataCache.updateInstanceDiscoveryMap(authorityUrl.getHost(), new InstanceDiscoveryMetadata(false)); Logger.v(TAG, "Fail to get authority validation metadata back. Ignore the failure since authority validation is turned off."); } } apiEvent.setValidationStatus(EventStrings.AUTHORITY_VALIDATION_NOT_DONE); Telemetry.getInstance().stopEvent(authenticationRequest.getTelemetryRequestId(), apiEvent, EventStrings.AUTHORITY_VALIDATION_EVENT); } final InstanceDiscoveryMetadata metadata = AuthorityValidationMetadataCache.getCachedInstanceDiscoveryMetadata(authorityUrl); if (metadata == null || !metadata.isValidated()) { return; } updatePreferredNetworkLocation(authorityUrl, authenticationRequest, metadata); }</code><technical_language>I put this throw PerformInstanceDiscovery line 213, i reason this is Context object is run check. I add constructor of Discovery</technical_language>

Target:
private void performAuthorityValidation(final AuthenticationRequest authenticationRequest, final URL authorityUrl) throws AuthenticationException { Telemetry.getInstance().startEvent(authenticationRequest.getTelemetryRequestId(), EventStrings.AUTHORITY_VALIDATION_EVENT); APIEvent apiEvent = new APIEvent(EventStrings.AUTHORITY_VALIDATION_EVENT); apiEvent.setCorrelationId(authenticationRequest.getCorrelationId().toString()); apiEvent.setRequestId(authenticationRequest.getTelemetryRequestId()); if (mAuthContext.getValidateAuthority()) { try { validateAuthority(authorityUrl, authenticationRequest.getUpnSuffix(), authenticationRequest.isSilent(), authenticationRequest.getCorrelationId()); apiEvent.setValidationStatus(EventStrings.AUTHORITY_VALIDATION_SUCCESS); } catch (final AuthenticationException authenticationException) { if (null != authenticationException.getCode() && (authenticationException.getCode().equals(ADALError.DEVICE_CONNECTION_IS_NOT_AVAILABLE) || authenticationException.getCode().equals(ADALError.NO_NETWORK_CONNECTION_POWER_OPTIMIZATION))) { apiEvent.setValidationStatus(EventStrings.AUTHORITY_VALIDATION_NOT_DONE); } else { apiEvent.setValidationStatus(EventStrings.AUTHORITY_VALIDATION_FAILURE); } throw authenticationException; } finally { Telemetry.getInstance().stopEvent(authenticationRequest.getTelemetryRequestId(), apiEvent, EventStrings.AUTHORITY_VALIDATION_EVENT); } } else { if (!UrlExtensions.isADFSAuthority(authorityUrl) && !AuthorityValidationMetadataCache.containsAuthorityHost(authorityUrl)) { try { mDiscovery.validateAuthority(authorityUrl); } catch (final AuthenticationException authenticationException) { AuthorityValidationMetadataCache.updateInstanceDiscoveryMap(authorityUrl.getHost(), new InstanceDiscoveryMetadata(false)); Logger.v(TAG, "Fail to get authority validation metadata back. Ignore the failure since authority validation is turned off."); } } apiEvent.setValidationStatus(EventStrings.AUTHORITY_VALIDATION_NOT_DONE); Telemetry.getInstance().stopEvent(authenticationRequest.getTelemetryRequestId(), apiEvent, EventStrings.AUTHORITY_VALIDATION_EVENT); } final InstanceDiscoveryMetadata metadata = AuthorityValidationMetadataCache.getCachedInstanceDiscoveryMetadata(authorityUrl); if (metadata == null || !metadata.isValidated()) { return; } updatePreferredNetworkLocation(authorityUrl, authenticationRequest, metadata); }