GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add BlockHound exception for DnsQueryIdSpace (#16896) · netty/netty@d0957df

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • common/src/main/java/io/netty/util/internal
    • Hidden.java
  • transport-blockhound-tests/src/test/java/io/netty/util/internal
    • NettyBlockHoundIntegrationTest.java
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎common/src/main/java/io/netty/util/internal/Hidden.java‎

Copy file name to clipboardExpand all lines: common/src/main/java/io/netty/util/internal/Hidden.java
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,14 @@ public void applyTo(BlockHound.Builder builder) {
167167
"io.netty.resolver.dns.UnixResolverDnsServerAddressStreamProvider",
168168
"parseEtcResolverOptions");
169169

170+
builder.allowBlockingCallsInside(
171+
"io.netty.resolver.dns.DnsQueryIdSpace",
172+
"nextId");
173+
174+
builder.allowBlockingCallsInside(
175+
"io.netty.resolver.dns.DnsQueryIdSpace$DnsQueryIdRange",
176+
"pushId");
177+
170178
builder.allowBlockingCallsInside(
171179
"io.netty.resolver.HostsFileEntriesProvider$ParserImpl",
172180
"parse");
Collapse file

‎transport-blockhound-tests/src/test/java/io/netty/util/internal/NettyBlockHoundIntegrationTest.java‎

Copy file name to clipboardExpand all lines: transport-blockhound-tests/src/test/java/io/netty/util/internal/NettyBlockHoundIntegrationTest.java
+36Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import io.netty.handler.ssl.util.InsecureTrustManagerFactory;
4141
import io.netty.pkitesting.CertificateBuilder;
4242
import io.netty.pkitesting.X509Bundle;
43+
import io.netty.resolver.dns.DnsNameResolver;
4344
import io.netty.resolver.dns.DnsNameResolverBuilder;
4445
import io.netty.resolver.dns.DnsServerAddressStreamProviders;
4546
import io.netty.util.HashedWheelTimer;
@@ -75,6 +76,7 @@
7576
import java.util.concurrent.Future;
7677
import java.util.concurrent.FutureTask;
7778
import java.util.concurrent.LinkedBlockingQueue;
79+
import java.util.concurrent.ThreadFactory;
7880
import java.util.concurrent.TimeUnit;
7981
import java.util.concurrent.atomic.AtomicLong;
8082
import java.util.concurrent.atomic.AtomicReference;
@@ -420,6 +422,40 @@ public void testUnixResolverDnsServerAddressStreamProvider_ParseEtcResolverSearc
420422
}
421423
}
422424

425+
@Test
426+
@Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
427+
public void testDnsNameResolverAllowsBlockingCalls() throws InterruptedException {
428+
CountDownLatch latch = new CountDownLatch(1);
429+
List<Throwable> error = new ArrayList<>();
430+
ThreadFactory threadFactory = r -> {
431+
Thread t = new DefaultThreadFactory("test").newThread(r);
432+
t.setUncaughtExceptionHandler((t1, e) -> {
433+
error.add(e);
434+
latch.countDown();
435+
});
436+
return t;
437+
};
438+
EventLoopGroup group = new MultiThreadIoEventLoopGroup(1, threadFactory, NioIoHandler.newFactory());
439+
try (DnsNameResolver resolver = new DnsNameResolverBuilder(group.next())
440+
.datagramChannelFactory(NioDatagramChannel::new)
441+
.build()) {
442+
resolver.resolve("netty.io").addListener(future -> {
443+
if (!future.isSuccess()) {
444+
error.add(future.cause());
445+
}
446+
latch.countDown();
447+
});
448+
latch.await();
449+
for (Throwable t : error) {
450+
if (t instanceof BlockingOperationError || t.getCause() instanceof BlockingOperationError) {
451+
fail("BlockingOperationError was thrown: " + t);
452+
}
453+
}
454+
} finally {
455+
group.shutdownGracefully();
456+
}
457+
}
458+
423459
private static void doTestParseResolverFilesAllowsBlockingCalls(Callable<Object> callable)
424460
throws InterruptedException {
425461
SingleThreadEventExecutor executor =

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.