Skip to content

Commit 302d49e

Browse files
committed
Do not mock sealed classes with java 21
1 parent c9b7da4 commit 302d49e

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

dd-java-agent/agent-bootstrap/src/test/groovy/datadog/trace/bootstrap/instrumentation/java/net/HostNameResolverForkedTest.groovy

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,18 @@ class HostNameResolverForkedTest extends DDSpecification {
2626
}
2727

2828
def "should use the cache for unresolved addresses"() {
29-
setup:
30-
def inet1 = Mock(InetAddress)
31-
def inet2 = Mock(InetAddress)
29+
given:
30+
def inet1 = new Inet4Address(null, InetAddress.getLocalHost().getAddress())
31+
def inet2 = new Inet4Address(null, 0) // this will fail if a resolution will happen
3232
when:
3333
def address = new InetSocketAddress(inet1, 666)
3434
def host = HostNameResolver.hostName(address.getAddress(), "127.0.0.1")
3535
then:
36-
host == "somehost"
37-
1 * inet1.getHostName() >> "somehost"
36+
host == "localhost"
3837
when:
3938
address = new InetSocketAddress(inet2, 666)
4039
host = HostNameResolver.hostName(address.getAddress(), "127.0.0.1")
4140
then:
42-
0 * inet2.getHostName()
43-
host == "somehost"
41+
host == "localhost"
4442
}
4543
}

0 commit comments

Comments
 (0)