diff options
author | Kjetil Ørbekk <kjetil.orbekk@gmail.com> | 2012-04-10 17:51:59 +0200 |
---|---|---|
committer | Kjetil Ørbekk <kjetil.orbekk@gmail.com> | 2012-04-10 17:51:59 +0200 |
commit | bb4dc8012467d47ed21a8fa1cf11fca27a1fafd7 (patch) | |
tree | f0e2c8f5b78154fb294f13f559a7987b13145e5f /src/main/java/com/orbekk/protobuf/RpcChannel.java | |
parent | afb415dcaf614c177176a00220f3b0418daada1f (diff) |
Fix some bugs in RpcChannel and NewRpcChannel.
Use protobuf v.2.4.1.
Diffstat (limited to 'src/main/java/com/orbekk/protobuf/RpcChannel.java')
-rw-r--r-- | src/main/java/com/orbekk/protobuf/RpcChannel.java | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/main/java/com/orbekk/protobuf/RpcChannel.java b/src/main/java/com/orbekk/protobuf/RpcChannel.java index 2f53349..8e24d0c 100644 --- a/src/main/java/com/orbekk/protobuf/RpcChannel.java +++ b/src/main/java/com/orbekk/protobuf/RpcChannel.java @@ -143,7 +143,11 @@ public class RpcChannel extends Thread implements Data.Request request = createRequest(method, controller, requestMessage, responsePrototype, done); Socket socket = getSocket(); - request.writeDelimitedTo(socket.getOutputStream()); + if (socket == null) { + cancelAllRpcs(); + } else { + request.writeDelimitedTo(socket.getOutputStream()); + } } catch (IOException e) { throw new AssertionError("Should return error."); } @@ -194,7 +198,7 @@ public class RpcChannel extends Thread implements Socket socket = sockets.take(); handleResponses(socket); } catch (InterruptedException e) { - // Interrupts handled by outer loop + Thread.currentThread().interrupt(); } } } @@ -202,6 +206,7 @@ public class RpcChannel extends Thread implements public void close() { if (socket != null) { try { + this.interrupt(); socket.close(); } catch (IOException e) { logger.info("Error closing socket."); |