Skip to content

Commit

Permalink
TEIID-3664 resolving timing issue with ping by properly logging off
Browse files Browse the repository at this point in the history
  • Loading branch information
shawkins committed Sep 11, 2015
1 parent 074486d commit 61d720f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
Expand Up @@ -134,7 +134,7 @@ public static void setWorkContext(DQPWorkContext context) {
}
}

private SessionMetadata session = new SessionMetadata();
private volatile SessionMetadata session = new SessionMetadata();
private String clientAddress;
private String clientHostname;
private SecurityHelper securityHelper;
Expand Down
Expand Up @@ -224,11 +224,13 @@ private <T> T proxyService(final Class<T> iface, final T instance, String contex
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
Throwable exception = null;
try {
if (DQPWorkContext.getWorkContext().getSession().isClosed()) {
String sessionID = DQPWorkContext.getWorkContext().getSession().getSessionId();
DQPWorkContext workContext = DQPWorkContext.getWorkContext();
if (workContext.getSession().isClosed() || workContext.getSessionId() == null) {
String sessionID = workContext.getSession().getSessionId();
if (sessionID == null) {
throw new InvalidSessionException(RuntimePlugin.Event.TEIID40041, RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40041));
}
workContext.setSession(new SessionMetadata());
throw new InvalidSessionException(RuntimePlugin.Event.TEIID40042, RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40042, sessionID));
}
return super.invoke(proxy, method, args);
Expand Down
12 changes: 11 additions & 1 deletion runtime/src/main/java/org/teiid/transport/LogonImpl.java
Expand Up @@ -234,7 +234,17 @@ private String updateDQPContext(SessionMetadata s) {

public ResultsFuture<?> logoff() throws InvalidSessionException {
DQPWorkContext workContext = DQPWorkContext.getWorkContext();
this.service.closeSession(workContext.getSessionId());
if (workContext.getSession().isClosed() || workContext.getSessionId() == null) {
if (workContext.getSessionId() != null) {
this.updateDQPContext(new SessionMetadata());
}
return ResultsFuture.NULL_FUTURE;
}
try {
this.service.closeSession(workContext.getSessionId());
} finally {
this.updateDQPContext(new SessionMetadata());
}
return ResultsFuture.NULL_FUTURE;
}

Expand Down

0 comments on commit 61d720f

Please sign in to comment.