8000 Old DNS servers are not cleared out when network changes · Issue #226 · dnsjava/dnsjava · GitHub
[go: up one dir, main page]

Skip to content
Old DNS servers are not cleared out when network changes #226
Closed
@balgillo

Description

@balgillo

DNSJava v3.4.1.

When a network change is detected, our application calls ResolverConfig.refresh(). However, this does not clear out the old servers, only adds new ones. This is a problem if disconnecting from a VPN, because the VPN's DNS servers are still active but no longer reachable, resulting in a lot of failed DNS queries.

Technical analysis

ResolverConfig class contains a static list of ResolverConfigProviders

  private static List<ResolverConfigProvider> configProviders;

The objects in this list are populated by checkInitialized and then never changed unless setConfigProviders is called.

Each ResolverConfigProvider contains an initialize method which invokes BaseResolverConfigProvider.addNameserver to add servers to the list, but has no means of clearing the list first.

ResolverConfig.refresh() calls ResolverConfig constructor which runs initialize() on each provider, but that doesn't clear out the previous name servers or search paths. So, new ones are added on the end of the lists, but old ones are retained at the start of the lists.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0