Skip to content

Commit

Permalink
Merge pull request Atmosphere#1774 from dmitry-treskunov/fix_semaphore
Browse files Browse the repository at this point in the history
JSR356WebSocket: always release semaphore
  • Loading branch information
jfarcand committed Nov 19, 2014
2 parents 225ed4e + 0d19fed commit 733f8a9
Showing 1 changed file with 7 additions and 6 deletions.
Expand Up @@ -47,10 +47,7 @@ public JSR356WebSocket(Session session, AtmosphereConfig config) {
super(config);
this.session = session;
// https://issues.apache.org/bugzilla/show_bug.cgi?id=56026
String s = config.getInitParameter(ApplicationConfig.WEBSOCKET_IDLETIME);
if (s != null) {
session.getAsyncRemote().setSendTimeout(Integer.valueOf(s));
}
session.getAsyncRemote().setSendTimeout(config.getInitParameter(ApplicationConfig.WEBSOCKET_IDLETIME, 10 * 1000));
}

@Override
Expand All @@ -65,8 +62,10 @@ public WebSocket write(String s) throws IOException {
session.getAsyncRemote().sendText(s, new WriteResult(resource(), s));
} catch (NullPointerException e) {
patchGlassFish(e);
} finally {
semaphore.release();
} catch (RuntimeException e){
semaphore.release();
throw e;
}
return this;
}
Expand All @@ -80,8 +79,10 @@ public WebSocket write(byte[] data, int offset, int length) throws IOException {
new WriteResult(resource(), b.array()));
} catch (NullPointerException e) {
patchGlassFish(e);
} finally {
semaphore.release();
} catch (RuntimeException e){
semaphore.release();
throw e;
}
return this;
}
Expand Down

0 comments on commit 733f8a9

Please sign in to comment.