piotrrzysko commented on pull request #9315:
URL: https://github.com/apache/kafka/pull/9315#issuecomment-697717628
@jolshan @mumrah Thanks for the review! Of course, I agree with you that it
would be nice to use the mock in all tests, but after rethinking the solution
suggested in this PR I came to the conclusion that it is not so easy.
I assumed that `InetAddress#getAllByName` is the only place where DNS
resolution happens - it’s not true. The constructor of `InetSocketAddress` that
is used by `ClientUtils#parseAndValidateAddresses` in some circumstances (when
a passed hostname is a machine name rather than a literal IP address) may also
call an external DNS server. This behavior is much harder to mock. Perhaps it
is not a problem for tests from `ClientUtilsTest`, because as I checked only
`localhost` is resolved in this way. However, I wouldn’t like to introduce
abstraction over DNS resolving mechanism that is unable to cover all cases.
Unfortunately, the only solution that comes to my mind is to try a hack
based on reflection that will allow replacing the default DNS provider in
tests. It was something that I wanted to avoid because it can cause problems
with future versions of Java. Nevertheless, I can check if it is possible and
how ugly it will be :).
WDYT?
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org