Skip to content

Lock contention in HostsFileParser #369

@ivanr-rs

Description

@ivanr-rs

Documenting for awareness. By default, the Lookup class will check the contents of /etc/hosts on every A and AAAA lookup, via a call to HostsFileParser#getAddressForHost. This method is synchronized and creates a hot path in a high-volume environment. There is also an I/O operation (in validateCache) inside the synchronized block, which contributes to the contention.

A workaround for this problem is to call Lookup#setDefaultHostsFileParser, Lookup#setHostsFileParser, or use the dnsjava.lookup.use_hosts_file configuration property.

Perhaps a future version of dnsjava could disable this feature by default?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions