Skip to content

Commit

Permalink
Do not close socket if it is already closed.
Browse files Browse the repository at this point in the history
  • Loading branch information
ManfredKarrer committed Nov 26, 2017
1 parent c694d22 commit 58de2b5
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<groupId>org.bitcoinj</groupId>
<artifactId>bitcoinj-parent</artifactId>
<version>0.14.4.3</version>
<version>0.14.4.4</version>
</parent>

<artifactId>bitcoinj-core</artifactId>
Expand Down
11 changes: 7 additions & 4 deletions core/src/main/java/org/bitcoinj/net/BlockingClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,14 @@ public void closeConnection() {
@Override
public synchronized void writeBytes(byte[] message) throws IOException {
try {
OutputStream stream = socket.getOutputStream();
stream.write(message);
stream.flush();
if(!socket.isClosed()) {
OutputStream stream = socket.getOutputStream();
stream.write(message);
stream.flush();
}
} catch (IOException e) {
log.error("Error writing message to connection, closing connection", e);
if(!(e instanceof SocketException && e.toString().equals("Socket is closed")))
log.error("Error writing message to connection, closing connection", e);
closeConnection();
throw e;
}
Expand Down
2 changes: 1 addition & 1 deletion examples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<groupId>org.bitcoinj</groupId>
<artifactId>bitcoinj-parent</artifactId>
<version>0.14.4.3</version>
<version>0.14.4.4</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>org.bitcoinj</groupId>
<artifactId>bitcoinj-parent</artifactId>
<version>0.14.4.3</version>
<version>0.14.4.4</version>
<packaging>pom</packaging>

<modules>
Expand Down
2 changes: 1 addition & 1 deletion tools/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<groupId>org.bitcoinj</groupId>
<artifactId>bitcoinj-parent</artifactId>
<version>0.14.4.3</version>
<version>0.14.4.4</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion wallettemplate/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.bitcoinj</groupId>
<artifactId>bitcoinj-parent</artifactId>
<version>0.14.4.3</version>
<version>0.14.4.4</version>
</parent>

<artifactId>wallettemplate</artifactId>
Expand Down

0 comments on commit 58de2b5

Please sign in to comment.