Skip to content

Commit

Permalink
Fixed a BufferUnderflowException in message parsing when PeerExchange…
Browse files Browse the repository at this point in the history
… is closing
  • Loading branch information
bwzhou authored Jul 1, 2016
1 parent 7acb2d0 commit fce1fc7
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,14 @@ public void run() {
}

buffer.rewind();


if (stop) {
// The buffer may contain the type from the last message
// if we were stopped before reading the payload and cause
// BufferUnderflowException in parsing.
break;
}

try {
PeerMessage message = PeerMessage.parse(buffer, torrent);
logger.trace("Received {} from {}", message, peer);
Expand Down

0 comments on commit fce1fc7

Please sign in to comment.