DnsOptions.StaleDnsOptions.Builder
Stay organized with collections
Save and categorize content based on your preferences.
Inherited Method Summary
From class
java.lang.Object
Object
|
clone()
|
boolean
|
equals(Object arg0)
|
void
|
finalize()
|
final
Class<?>
|
getClass()
|
int
|
hashCode()
|
final
void
|
notify()
|
final
void
|
notifyAll()
|
String
|
toString()
|
final
void
|
wait(long arg0, int arg1)
|
final
void
|
wait(long arg0)
|
final
void
|
wait()
|
Public Methods
Sets whether to return results originating from other networks or not. Normally,
Cronet clears the DNS cache entirely when switching connections, e.g. between two
Wi-Fi networks or from Wi-Fi to 4G.
Sets how long (in milliseconds) to wait for a DNS request to return before using a
stale result instead. If set to zero, returns stale results instantly but continues
the DNS request in the background to update the cache.
Sets how long (in milliseconds) past expiration to consider using expired results.
Setting the value to zero means expired records can be used indefinitely.
Sets whether to allow use of stale DNS results when network resolver fails to resolve
the hostname.
Depending on the use case, if Cronet quickly sees a fresh failure, it may be
desirable to use the failure as it is technically the fresher result, and we had such
a fresh result quickly; or, prefer having any result (even if stale) to use over
having a failure.
Parameters
useStaleOnNameNotResolved |
|
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2023-10-26 UTC.
[null,null,["Last updated 2023-10-26 UTC."],[],[],null,["# DnsOptions.StaleDnsOptions.Builder\n\npublic static final class **DnsOptions.StaleDnsOptions.Builder** extends Object \nBuilder for [DnsOptions.StaleDnsOptions](../../../../reference/org/chromium/net/DnsOptions.StaleDnsOptions.html). \n\n### Public Method Summary\n\n|----------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [DnsOptions.StaleDnsOptions.Builder](../../../../reference/org/chromium/net/DnsOptions.StaleDnsOptions.Builder.html) | [allowCrossNetworkUsage](../../../../reference/org/chromium/net/DnsOptions.StaleDnsOptions.Builder.html#allowCrossNetworkUsage(boolean))(boolean allowCrossNetworkUsage) Sets whether to return results originating from other networks or not. |\n| [DnsOptions.StaleDnsOptions](../../../../reference/org/chromium/net/DnsOptions.StaleDnsOptions.html) | [build](../../../../reference/org/chromium/net/DnsOptions.StaleDnsOptions.Builder.html#build())() Creates and returns the final [DnsOptions.StaleDnsOptions](../../../../reference/org/chromium/net/DnsOptions.StaleDnsOptions.html) instance, based on the values in this builder. |\n| [DnsOptions.StaleDnsOptions.Builder](../../../../reference/org/chromium/net/DnsOptions.StaleDnsOptions.Builder.html) | [setFreshLookupTimeout](../../../../reference/org/chromium/net/DnsOptions.StaleDnsOptions.Builder.html#setFreshLookupTimeout(java.time.Duration))(Duration freshLookupTimeout) Same as [setFreshLookupTimeoutMillis(long)](../../../../reference/org/chromium/net/DnsOptions.StaleDnsOptions.Builder.html#setFreshLookupTimeoutMillis(long)) but using [Duration](../../../../reference/java/time/Duration.html). |\n| [DnsOptions.StaleDnsOptions.Builder](../../../../reference/org/chromium/net/DnsOptions.StaleDnsOptions.Builder.html) | [setFreshLookupTimeoutMillis](../../../../reference/org/chromium/net/DnsOptions.StaleDnsOptions.Builder.html#setFreshLookupTimeoutMillis(long))(long freshLookupTimeoutMillis) Sets how long (in milliseconds) to wait for a DNS request to return before using a stale result instead. |\n| [DnsOptions.StaleDnsOptions.Builder](../../../../reference/org/chromium/net/DnsOptions.StaleDnsOptions.Builder.html) | [setMaxExpiredDelayMillis](../../../../reference/org/chromium/net/DnsOptions.StaleDnsOptions.Builder.html#setMaxExpiredDelayMillis(long))(long maxExpiredDelayMillis) Sets how long (in milliseconds) past expiration to consider using expired results. |\n| [DnsOptions.StaleDnsOptions.Builder](../../../../reference/org/chromium/net/DnsOptions.StaleDnsOptions.Builder.html) | [setMaxExpiredDelayMillis](../../../../reference/org/chromium/net/DnsOptions.StaleDnsOptions.Builder.html#setMaxExpiredDelayMillis(java.time.Duration))(Duration maxExpiredDelay) Same as [setMaxExpiredDelayMillis(long)](../../../../reference/org/chromium/net/DnsOptions.StaleDnsOptions.Builder.html#setMaxExpiredDelayMillis(long)) but using [Duration](../../../../reference/java/time/Duration.html). |\n| [DnsOptions.StaleDnsOptions.Builder](../../../../reference/org/chromium/net/DnsOptions.StaleDnsOptions.Builder.html) | [useStaleOnNameNotResolved](../../../../reference/org/chromium/net/DnsOptions.StaleDnsOptions.Builder.html#useStaleOnNameNotResolved(boolean))(boolean useStaleOnNameNotResolved) Sets whether to allow use of stale DNS results when network resolver fails to resolve the hostname. |\n\n### Inherited Method Summary\n\nFrom class java.lang.Object \n\n|------------------|---------------------------|\n| Object | clone() |\n| boolean | equals(Object arg0) |\n| void | finalize() |\n| final Class\\\u003c?\\\u003e | getClass() |\n| int | hashCode() |\n| final void | notify() |\n| final void | notifyAll() |\n| String | toString() |\n| final void | wait(long arg0, int arg1) |\n| final void | wait(long arg0) |\n| final void | wait() |\n\nPublic Methods\n--------------\n\n#### public [DnsOptions.StaleDnsOptions.Builder](../../../../reference/org/chromium/net/DnsOptions.StaleDnsOptions.Builder.html)\n**allowCrossNetworkUsage**\n(boolean allowCrossNetworkUsage)\n\nSets whether to return results originating from other networks or not. Normally,\nCronet clears the DNS cache entirely when switching connections, e.g. between two\nWi-Fi networks or from Wi-Fi to 4G. \n\n##### Parameters\n\n| allowCrossNetworkUsage | |\n|------------------------|---|\n\n##### Returns\n\n- the builder for chaining \n\n#### public [DnsOptions.StaleDnsOptions](../../../../reference/org/chromium/net/DnsOptions.StaleDnsOptions.html)\n**build**\n()\n\nCreates and returns the final [DnsOptions.StaleDnsOptions](../../../../reference/org/chromium/net/DnsOptions.StaleDnsOptions.html) instance, based on the values\nin this builder. \n\n#### public [DnsOptions.StaleDnsOptions.Builder](../../../../reference/org/chromium/net/DnsOptions.StaleDnsOptions.Builder.html)\n**setFreshLookupTimeout**\n(Duration freshLookupTimeout)\n\nSame as [setFreshLookupTimeoutMillis(long)](../../../../reference/org/chromium/net/DnsOptions.StaleDnsOptions.Builder.html#setFreshLookupTimeoutMillis(long)) but using [Duration](../../../../reference/java/time/Duration.html). \n\n##### Parameters\n\n| freshLookupTimeout | |\n|--------------------|---|\n\n##### Returns\n\n- the builder for chaining \n\n#### public [DnsOptions.StaleDnsOptions.Builder](../../../../reference/org/chromium/net/DnsOptions.StaleDnsOptions.Builder.html)\n**setFreshLookupTimeoutMillis**\n(long freshLookupTimeoutMillis)\n\nSets how long (in milliseconds) to wait for a DNS request to return before using a\nstale result instead. If set to zero, returns stale results instantly but continues\nthe DNS request in the background to update the cache. \n\n##### Parameters\n\n| freshLookupTimeoutMillis | |\n|--------------------------|---|\n\n##### Returns\n\n- the builder for chaining \n\n#### public [DnsOptions.StaleDnsOptions.Builder](../../../../reference/org/chromium/net/DnsOptions.StaleDnsOptions.Builder.html)\n**setMaxExpiredDelayMillis**\n(long maxExpiredDelayMillis)\n\nSets how long (in milliseconds) past expiration to consider using expired results.\nSetting the value to zero means expired records can be used indefinitely. \n\n##### Parameters\n\n| maxExpiredDelayMillis | |\n|-----------------------|---|\n\n##### Returns\n\n- the builder for chaining \n\n#### public [DnsOptions.StaleDnsOptions.Builder](../../../../reference/org/chromium/net/DnsOptions.StaleDnsOptions.Builder.html)\n**setMaxExpiredDelayMillis**\n(Duration maxExpiredDelay)\n\nSame as [setMaxExpiredDelayMillis(long)](../../../../reference/org/chromium/net/DnsOptions.StaleDnsOptions.Builder.html#setMaxExpiredDelayMillis(long)) but using [Duration](../../../../reference/java/time/Duration.html). \n\n##### Parameters\n\n| maxExpiredDelay | |\n|-----------------|---|\n\n##### Returns\n\n- the builder for chaining \n\n#### public [DnsOptions.StaleDnsOptions.Builder](../../../../reference/org/chromium/net/DnsOptions.StaleDnsOptions.Builder.html)\n**useStaleOnNameNotResolved**\n(boolean useStaleOnNameNotResolved)\n\nSets whether to allow use of stale DNS results when network resolver fails to resolve\nthe hostname.\n\nDepending on the use case, if Cronet quickly sees a fresh failure, it may be\ndesirable to use the failure as it is technically the fresher result, and we had such\na fresh result quickly; or, prefer having any result (even if stale) to use over\nhaving a failure. \n\n##### Parameters\n\n| useStaleOnNameNotResolved | |\n|---------------------------|---|\n\n##### Returns\n\n- the builder for chaining"]]