Skip to content

Commit e1437fb

Browse files
authored
Avoid ignoring interrupts in testsuite (#12958)
Motivation: JUnit relies on interrupts to communicate test timeouts. When we silently swallow interrupts, we break this mechanism. Modification: Make the loops in the testsuite throw their interrupts instead of silently swallowing them. Result: The tests now responds to timeouts.
1 parent cfcc514 commit e1437fb

8 files changed

Lines changed: 14 additions & 70 deletions

File tree

testsuite/src/main/java/io/netty/testsuite/transport/sctp/SctpEchoTest.java

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,7 @@ public void initChannel(SctpChannel c) throws Exception {
119119
break;
120120
}
121121

122-
try {
123-
Thread.sleep(50);
124-
} catch (InterruptedException e) {
125-
// Ignore.
126-
}
122+
Thread.sleep(50);
127123
}
128124

129125
while (sh.counter < data.length) {
@@ -134,11 +130,7 @@ public void initChannel(SctpChannel c) throws Exception {
134130
break;
135131
}
136132

137-
try {
138-
Thread.sleep(50);
139-
} catch (InterruptedException e) {
140-
// Ignore.
141-
}
133+
Thread.sleep(50);
142134
}
143135

144136
sh.channel.close().sync();

testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketCancelWriteTest.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,7 @@ public void testCancelWrite(ServerBootstrap sb, Bootstrap cb) throws Throwable {
7777
if (ch.exception.get() != null) {
7878
break;
7979
}
80-
try {
81-
Thread.sleep(50);
82-
} catch (InterruptedException ignore) {
83-
// Ignore.
84-
}
80+
Thread.sleep(50);
8581
}
8682
sh.channel.close().sync();
8783
ch.channel.close().sync();

testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketEchoTest.java

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -219,11 +219,7 @@ public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws E
219219
break;
220220
}
221221

222-
try {
223-
Thread.sleep(50);
224-
} catch (InterruptedException e) {
225-
// Ignore.
226-
}
222+
Thread.sleep(50);
227223
}
228224

229225
while (sh.counter < data.length) {
@@ -234,11 +230,7 @@ public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws E
234230
break;
235231
}
236232

237-
try {
238-
Thread.sleep(50);
239-
} catch (InterruptedException e) {
240-
// Ignore.
241-
}
233+
Thread.sleep(50);
242234
}
243235

244236
sh.channel.close().sync();

testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketFileRegionTest.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -243,11 +243,7 @@ public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws E
243243
break;
244244
}
245245

246-
try {
247-
Thread.sleep(50);
248-
} catch (InterruptedException e) {
249-
// Ignore.
250-
}
246+
Thread.sleep(50);
251247
}
252248

253249
sh.channel.close().sync();

testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketFixedLengthEchoTest.java

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,7 @@ public void initChannel(Channel sch) throws Exception {
109109
break;
110110
}
111111

112-
try {
113-
Thread.sleep(50);
114-
} catch (InterruptedException e) {
115-
// Ignore.
116-
}
112+
Thread.sleep(50);
117113
}
118114

119115
while (sh.counter < data.length) {
@@ -124,11 +120,7 @@ public void initChannel(Channel sch) throws Exception {
124120
break;
125121
}
126122

127-
try {
128-
Thread.sleep(50);
129-
} catch (InterruptedException e) {
130-
// Ignore.
131-
}
123+
Thread.sleep(50);
132124
}
133125

134126
sh.channel.close().sync();

testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketObjectEchoTest.java

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,7 @@ public void initChannel(Channel sch) throws Exception {
120120
break;
121121
}
122122

123-
try {
124-
Thread.sleep(50);
125-
} catch (InterruptedException e) {
126-
// Ignore.
127-
}
123+
Thread.sleep(50);
128124
}
129125

130126
while (sh.counter < data.length) {
@@ -135,11 +131,7 @@ public void initChannel(Channel sch) throws Exception {
135131
break;
136132
}
137133

138-
try {
139-
Thread.sleep(50);
140-
} catch (InterruptedException e) {
141-
// Ignore.
142-
}
134+
Thread.sleep(50);
143135
}
144136

145137
sh.channel.close().sync();

testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketSpdyEchoTest.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -220,11 +220,7 @@ public void initChannel(SocketChannel channel) throws Exception {
220220
break;
221221
}
222222

223-
try {
224-
Thread.sleep(50);
225-
} catch (InterruptedException e) {
226-
// Ignore.
227-
}
223+
Thread.sleep(50);
228224
}
229225

230226
if (sh.exception.get() != null && !(sh.exception.get() instanceof IOException)) {

transport-native-epoll/src/test/java/io/netty/channel/epoll/EpollSpliceTest.java

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,7 @@ public void operationComplete(ChannelFuture future) throws Exception {
150150
break;
151151
}
152152

153-
try {
154-
Thread.sleep(50);
155-
} catch (InterruptedException e) {
156-
// Ignore.
157-
}
153+
Thread.sleep(50);
158154
}
159155

160156
while (sh.counter < data.length) {
@@ -165,11 +161,7 @@ public void operationComplete(ChannelFuture future) throws Exception {
165161
break;
166162
}
167163

168-
try {
169-
Thread.sleep(50);
170-
} catch (InterruptedException e) {
171-
// Ignore.
172-
}
164+
Thread.sleep(50);
173165
}
174166

175167
sh.channel.close().sync();
@@ -223,11 +215,7 @@ public void spliceToFile() throws Throwable {
223215
if (sh.exception.get() != null) {
224216
break;
225217
}
226-
try {
227-
Thread.sleep(50);
228-
} catch (InterruptedException e) {
229-
// Ignore.
230-
}
218+
Thread.sleep(50);
231219
}
232220

233221
sc.close().sync();

0 commit comments

Comments
 (0)