Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 7 additions & 11 deletions src/main/java/org/caffa/rpc/RestClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ public RestClient(String host, int port) throws Exception {

public void connect(String username, String password) throws Exception {
try {
disconnecting.set(false);
this.httpClient = createHttpClient(username, password);
this.sessionUuid = this.createSession(initialSessionType).getUuid();
startKeepAliveTransfer();
Expand All @@ -267,20 +268,15 @@ public CaffaSession.Type getInitialSessionType() {
}

public CaffaSession.Type getCurrentSessionType() {
CaffaSession.Type type = CaffaSession.Type.INVALID;

lock();
try {
type = getSession().getType();
lock();
return getSession().getType();
} catch (CaffaConnectionError e) {
logger.error("Failed to retrieve session " + this.sessionUuid);
this.sessionUuid = "";
this.disconnecting.set(true);
logger.error("Failed to retrieve session: " + this.sessionUuid);
return CaffaSession.Type.INVALID;
} finally {
unlock();
}

unlock();

return type;
}

private CaffaSession createSession(CaffaSession.Type type) throws CaffaConnectionError {
Expand Down