summaryrefslogtreecommitdiff
path: root/src/main/java/com/orbekk/protobuf/RpcChannel.java
diff options
context:
space:
mode:
authorKjetil Ørbekk <kjetil.orbekk@gmail.com>2012-04-10 17:51:59 +0200
committerKjetil Ørbekk <kjetil.orbekk@gmail.com>2012-04-10 17:51:59 +0200
commitbb4dc8012467d47ed21a8fa1cf11fca27a1fafd7 (patch)
treef0e2c8f5b78154fb294f13f559a7987b13145e5f /src/main/java/com/orbekk/protobuf/RpcChannel.java
parentafb415dcaf614c177176a00220f3b0418daada1f (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.java9
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.");