1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package io.netty.util.internal;
18
19 import io.netty.util.concurrent.FastThreadLocalThread;
20 import reactor.blockhound.BlockHound;
21 import reactor.blockhound.integration.BlockHoundIntegration;
22
23 import java.util.function.Function;
24 import java.util.function.Predicate;
25
26
27
28
29 class Hidden {
30
31
32
33
34
35
36
37 @UnstableApi
38 public static final class NettyBlockHoundIntegration implements BlockHoundIntegration {
39
40 @Override
41 public void applyTo(BlockHound.Builder builder) {
42 builder.allowBlockingCallsInside(
43 "io.netty.channel.nio.NioEventLoop",
44 "handleLoopException"
45 );
46
47 builder.allowBlockingCallsInside(
48 "io.netty.channel.kqueue.KQueueEventLoop",
49 "handleLoopException"
50 );
51
52 builder.allowBlockingCallsInside(
53 "io.netty.channel.epoll.EpollEventLoop",
54 "handleLoopException"
55 );
56
57 builder.allowBlockingCallsInside(
58 "io.netty.util.HashedWheelTimer",
59 "start"
60 );
61
62 builder.allowBlockingCallsInside(
63 "io.netty.util.HashedWheelTimer",
64 "stop"
65 );
66
67 builder.allowBlockingCallsInside(
68 "io.netty.util.HashedWheelTimer$Worker",
69 "waitForNextTick"
70 );
71
72 builder.allowBlockingCallsInside(
73 "io.netty.util.concurrent.SingleThreadEventExecutor",
74 "confirmShutdown"
75 );
76
77 builder.allowBlockingCallsInside(
78 "io.netty.buffer.PoolArena",
79 "lock"
80 );
81
82 builder.allowBlockingCallsInside(
83 "io.netty.buffer.PoolSubpage",
84 "lock"
85 );
86
87 builder.allowBlockingCallsInside(
88 "io.netty.buffer.PoolChunk",
89 "allocateRun"
90 );
91
92 builder.allowBlockingCallsInside(
93 "io.netty.buffer.PoolChunk",
94 "free"
95 );
96
97 builder.allowBlockingCallsInside(
98 "io.netty.handler.ssl.SslHandler",
99 "handshake"
100 );
101
102 builder.allowBlockingCallsInside(
103 "io.netty.handler.ssl.SslHandler",
104 "runAllDelegatedTasks"
105 );
106 builder.allowBlockingCallsInside(
107 "io.netty.handler.ssl.SslHandler",
108 "runDelegatedTasks"
109 );
110 builder.allowBlockingCallsInside(
111 "io.netty.util.concurrent.GlobalEventExecutor",
112 "takeTask");
113
114 builder.allowBlockingCallsInside(
115 "io.netty.util.concurrent.GlobalEventExecutor",
116 "addTask");
117
118 builder.allowBlockingCallsInside(
119 "io.netty.util.concurrent.SingleThreadEventExecutor",
120 "takeTask");
121
122 builder.allowBlockingCallsInside(
123 "io.netty.util.concurrent.SingleThreadEventExecutor",
124 "addTask");
125
126 builder.allowBlockingCallsInside(
127 "io.netty.handler.ssl.ReferenceCountedOpenSslClientContext$ExtendedTrustManagerVerifyCallback",
128 "verify");
129
130 builder.allowBlockingCallsInside(
131 "io.netty.handler.ssl.JdkSslContext$Defaults",
132 "init");
133
134
135
136 builder.allowBlockingCallsInside(
137 "sun.security.ssl.SSLEngineImpl",
138 "unwrap");
139
140 builder.allowBlockingCallsInside(
141 "sun.security.ssl.SSLEngineImpl",
142 "wrap");
143
144 builder.allowBlockingCallsInside(
145 "io.netty.resolver.dns.UnixResolverDnsServerAddressStreamProvider",
146 "parse");
147
148 builder.allowBlockingCallsInside(
149 "io.netty.resolver.dns.UnixResolverDnsServerAddressStreamProvider",
150 "parseEtcResolverSearchDomains");
151
152 builder.allowBlockingCallsInside(
153 "io.netty.resolver.dns.UnixResolverDnsServerAddressStreamProvider",
154 "parseEtcResolverOptions");
155
156 builder.allowBlockingCallsInside(
157 "io.netty.resolver.HostsFileEntriesProvider$ParserImpl",
158 "parse");
159
160 builder.allowBlockingCallsInside(
161 "io.netty.util.NetUtil$SoMaxConnAction",
162 "run");
163
164 builder.allowBlockingCallsInside("io.netty.util.internal.ReferenceCountUpdater",
165 "retryRelease0");
166
167 builder.allowBlockingCallsInside("io.netty.util.internal.PlatformDependent", "createTempFile");
168 builder.nonBlockingThreadPredicate(new Function<Predicate<Thread>, Predicate<Thread>>() {
169 @Override
170 public Predicate<Thread> apply(final Predicate<Thread> p) {
171 return new Predicate<Thread>() {
172 @Override
173 public boolean test(Thread thread) {
174 return p.test(thread) ||
175 thread instanceof FastThreadLocalThread &&
176 !((FastThreadLocalThread) thread).permitBlockingCalls();
177 }
178 };
179 }
180 });
181 }
182
183 @Override
184 public int compareTo(BlockHoundIntegration o) {
185 return 0;
186 }
187 }
188 }