DnsOptions.StaleDnsOptions.Builder
public
static
final
class
DnsOptions.StaleDnsOptions.Builder
extends Object
Builder for StaleDnsOptions
.
Summary
Inherited methods |
From class
java.lang.Object
Object
|
clone()
Creates and returns a copy of this object.
|
boolean
|
equals(Object obj)
Indicates whether some other object is "equal to" this one.
|
void
|
finalize()
Called by the garbage collector on an object when garbage collection
determines that there are no more references to the object.
|
final
Class<?>
|
getClass()
Returns the runtime class of this Object .
|
int
|
hashCode()
Returns a hash code value for the object.
|
final
void
|
notify()
Wakes up a single thread that is waiting on this object's
monitor.
|
final
void
|
notifyAll()
Wakes up all threads that are waiting on this object's monitor.
|
String
|
toString()
Returns a string representation of the object.
|
final
void
|
wait(long timeoutMillis, int nanos)
Causes the current thread to wait until it is awakened, typically
by being notified or interrupted, or until a
certain amount of real time has elapsed.
|
final
void
|
wait(long timeoutMillis)
Causes the current thread to wait until it is awakened, typically
by being notified or interrupted, or until a
certain amount of real time has elapsed.
|
final
void
|
wait()
Causes the current thread to wait until it is awakened, typically
by being notified or interrupted.
|
|
Public constructors
Builder
public Builder ()
Public methods
setAllowCrossNetworkUsage
public DnsOptions.StaleDnsOptions.Builder setAllowCrossNetworkUsage (int state)
Sets whether to return results originating from other networks or not. Normally,
the HTTP stack clears the DNS cache entirely when switching connections, e.g. between
two Wi-Fi networks or from Wi-Fi to 4G.
setFreshLookupTimeout
public DnsOptions.StaleDnsOptions.Builder setFreshLookupTimeout (Duration freshLookupTimeout)
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.
Parameters |
freshLookupTimeout |
Duration : This value cannot be null . |
setMaxExpiredDelay
public DnsOptions.StaleDnsOptions.Builder setMaxExpiredDelay (Duration maxExpiredDelay)
Sets how long (in milliseconds) past expiration to consider using expired results.
Setting the value to zero means expired records can be used indefinitely.
Parameters |
maxExpiredDelay |
Duration : This value cannot be null . |
setUseStaleOnNameNotResolved
public DnsOptions.StaleDnsOptions.Builder setUseStaleOnNameNotResolved (int state)
Sets whether to allow use of stale DNS results when network resolver fails to resolve
the hostname.
Depending on the use case, if the DNS resolver 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 dealing with a DNS failure.
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 2025-02-10 UTC.
[null,null,["Last updated 2025-02-10 UTC."],[],[]]