Skip to content

Commit

Permalink
Fix issues related to #1974
Browse files Browse the repository at this point in the history
  • Loading branch information
Mac authored and jfarcand committed Nov 18, 2015
1 parent d3ec2f2 commit 5d29263
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,19 +121,22 @@ public AsyncSupport complete(AtmosphereResourceImpl r) {
}

public void endAsyncContext(AtmosphereRequest request){
AsyncContext asyncContext = (AsyncContext) request.getAttribute(FrameworkConfig.ASYNC_CONTEXT);
if (asyncContext != null) {
try {
asyncContext.complete();
} catch (IllegalStateException ex) {
// Already completed. Jetty throw an exception on shutdown with log
try {
logger.trace("Already resumed!", ex);
} catch (Exception ex2){};
} finally {
request.removeAttribute(FrameworkConfig.ASYNC_CONTEXT);
}
}
final Object attribute = request.getAttribute(FrameworkConfig.ASYNC_CONTEXT);
if (attribute instanceof AsyncContext) {
AsyncContext asyncContext = (AsyncContext) attribute;
if (asyncContext != null) {
try {
asyncContext.complete();
} catch (IllegalStateException ex) {
// Already completed. Jetty throw an exception on shutdown with log
try {
logger.trace("Already resumed!", ex);
} catch (Exception ex2){};
} finally {
request.removeAttribute(FrameworkConfig.ASYNC_CONTEXT);
}
}
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -931,7 +931,6 @@ public AtmosphereFramework init(final ServletConfig sc, boolean wrap) throws Ser

this.shutdownHook = new Thread() {
public void run() {
AtmosphereFramework.this.shutdownHook = null;
AtmosphereFramework.this.destroy();
}
};
Expand Down Expand Up @@ -1838,6 +1837,7 @@ public AtmosphereFramework destroy() {

if ( this.shutdownHook != null) {
Runtime.getRuntime().removeShutdownHook(this.shutdownHook);
shutdownHook = null;
}
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,12 @@ public HttpSession getSession(boolean create) {
throw ex;
} catch (NullPointerException ex) {
// GLASSFISH http://java.net/jira/browse/GLASSFISH-18856
return b.request.getSession(create);
try {
return b.request.getSession(create);
} catch (Exception e) {
logger.trace("", ex);
return null;
}
} catch (RuntimeException ex) {
// https://github.com/Atmosphere/atmosphere/issues/1974
logger.trace("", ex);
Expand Down

0 comments on commit 5d29263

Please sign in to comment.