Skip to content

Commit 827e87c

Browse files
committed
TelnetInputStream now restores the current thread's interrupt flag when
catching InterruptedException.
1 parent 83bee9a commit 827e87c

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

src/changes/changes.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ The <action> type attribute can be add,update,fix,remove.
6868
<action type="fix" dev="ggregory" due-to="Gary Gregory">Fix malformed Javadoc comments.</action>
6969
<action type="fix" dev="ggregory" due-to="Gary Gregory">IMAPExportMbox now restores the current thread's interrupt flag when catching InterruptedException.</action>
7070
<action type="fix" dev="ggregory" due-to="Gary Gregory">IOUtil.readWrite() now restores the current thread's interrupt flag when catching InterruptedException.</action>
71+
<action type="fix" dev="ggregory" due-to="Gary Gregory">TelnetInputStream now restores the current thread's interrupt flag when catching InterruptedException.</action>
7172
<!-- ADD -->
7273
<action type="add" dev="ggregory" due-to="Gary Gregory">Add DatagramSocketClient.getDefaultTimeoutDuration() and deprecate getDefaultTimeout().</action>
7374
<!-- UPDATE -->

src/main/java/org/apache/commons/net/telnet/TelnetInputStream.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ private boolean processChar(final int ch) throws InterruptedException {
149149
try {
150150
queue.wait();
151151
} catch (final InterruptedException e) {
152+
Thread.currentThread().interrupt();
152153
throw e;
153154
}
154155
}
@@ -197,6 +198,7 @@ public int read() throws IOException {
197198
queue.wait();
198199
readIsWaiting = false;
199200
} catch (final InterruptedException e) {
201+
Thread.currentThread().interrupt();
200202
throw new InterruptedIOException("Fatal thread interruption during read.");
201203
}
202204
} else {
@@ -218,7 +220,7 @@ public int read() throws IOException {
218220
try {
219221
queue.wait(100);
220222
} catch (final InterruptedException interrupted) {
221-
// Ignored
223+
Thread.currentThread().interrupt();
222224
}
223225
}
224226
return EOF;
@@ -229,6 +231,7 @@ public int read() throws IOException {
229231
processChar(ch);
230232
}
231233
} catch (final InterruptedException e) {
234+
Thread.currentThread().interrupt();
232235
if (isClosed) {
233236
return EOF;
234237
}
@@ -508,6 +511,7 @@ public void run() {
508511
try {
509512
queue.wait(100);
510513
} catch (final InterruptedException interrupted) {
514+
Thread.currentThread().interrupt();
511515
if (isClosed) {
512516
break _outerLoop;
513517
}
@@ -529,6 +533,7 @@ public void run() {
529533
try {
530534
notify = processChar(ch);
531535
} catch (final InterruptedException e) {
536+
Thread.currentThread().interrupt();
532537
if (isClosed) {
533538
break _outerLoop;
534539
}

0 commit comments

Comments
 (0)