private FcpConnection connect() throws IOException {
FcpConnection fcpConnection = this.fcpConnection.get();
- if (fcpConnection != null) {
+ if ((fcpConnection != null) && !fcpConnection.isClosed()) {
return fcpConnection;
}
fcpConnection = createConnection();
- this.fcpConnection.compareAndSet(null, fcpConnection);
+ this.fcpConnection.set(fcpConnection);
return fcpConnection;
}
}
@Override
+ public GetNodeCommand getNode() {
+ return new GetNodeCommandImpl(threadPool, this::connect);
+ }
+
+ @Override
public GenerateKeypairCommand generateKeypair() {
return new GenerateKeypairCommandImpl(threadPool, this::connect);
}
}
@Override
+ public ListPeerCommand listPeer() {
+ return new ListPeerCommandImpl(threadPool, this::connect);
+ }
+
+ @Override
public ListPeersCommand listPeers() {
return new ListPeersCommandImpl(threadPool, this::connect);
}