Why does java.net.URL's hashcode resolve the host to an IP?

前端 未结 4 2071
广开言路
广开言路 2020-12-16 04:13

Is the idea after the first resolution it\'ll rely on OS caching? Still this seems inefficient and in cases of multiple domains resolving to the same IP, incorrect. What am

4条回答
  •  一整个雨季
    2020-12-16 04:57

    hashCode() is closely related to equals(). The explanation for this behavior is described in the docs for equals() as follows:

    Two hosts are considered equivalent if both host names can be resolved into the same IP addresses; else if either host name can't be resolved, the host names must be equal without regard to case; or both host names equal to null.

    Source: java.net.URL.equals() docs.

提交回复
热议问题