amichair commented on code in PR #58:
URL: https://github.com/apache/aries-rsa/pull/58#discussion_r3111282618
##########
provider/tcp/src/main/java/org/apache/aries/rsa/provider/tcp/TcpInvocationHandler.java:
##########
@@ -46,22 +49,105 @@
* which sends the details of the method invocations
* over a TCP connection, to be executed by the remote service.
*/
-public class TcpInvocationHandler implements InvocationHandler {
+public class TcpInvocationHandler implements InvocationHandler, Closeable {
+
+ private static class Connection {
+ Socket socket;
+ BasicObjectOutputStream out;
+ BasicObjectInputStream in;
+
+ public Connection(Socket socket) throws IOException {
+ this.socket = socket;
+ out = new BasicObjectOutputStream(socket.getOutputStream());
+ in = new BasicObjectInputStream(socket.getInputStream());
+ }
+ }
+
private String host;
private int port;
private String endpointId;
private ClassLoader cl;
private int timeoutMillis;
+ private final Deque<Connection> pool = new ArrayDeque<>();
+ private int acquired; // counts connections currently in use (not in pool)
+ private boolean closed;
+
public TcpInvocationHandler(ClassLoader cl, String host, int port, String
endpointId, int timeoutMillis)
- throws UnknownHostException, IOException {
+ throws UnknownHostException, IOException {
this.cl = cl;
this.host = host;
this.port = port;
this.endpointId = endpointId;
this.timeoutMillis = timeoutMillis;
}
+ private Connection acquireConnection() throws IOException {
+ Connection conn;
+ synchronized (pool) {
+ acquired++; // must be first
+ if (closed) {
Review Comment:
I'm not sure what the question is :-)
It's just a comment to avoid accidental regression during future refactoring
or such - the counting must come before the exception check. At least that's
what I believe me from a year ago would have commented about :-)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]