Skip to content

Commit

Permalink
Fix regression (cr == null)
Browse files Browse the repository at this point in the history
  • Loading branch information
jfarcand committed May 25, 2012
1 parent e51cf30 commit a63c953
Showing 1 changed file with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,26 +50,26 @@ public final static void broadcast(final AtmosphereResource r, final AtmosphereR

// Make sure only one thread can play with the ContainerResponse. Threading issue can arise if there is a scheduler
// or if ContainerResponse is associated with more than Broadcaster.
synchronized (cr) {
try {
cr = (ContainerResponse) request.getAttribute(FrameworkConfig.CONTAINER_RESPONSE);
boolean isCancelled = r.getAtmosphereResourceEvent().isCancelled();

if (cr == null || isCancelled) {
logger.debug("Retrieving HttpServletRequest {} with ContainerResponse {}", request, cr);
if (!isCancelled) {
logger.debug("Unexpected state. ContainerResponse cannot be null or already committed. The connection hasn't been suspended yet");
} else {
logger.debug("ContainerResponse already resumed or cancelled. Ignoring");
}
cr = (ContainerResponse) request.getAttribute(FrameworkConfig.CONTAINER_RESPONSE);
boolean isCancelled = r.getAtmosphereResourceEvent().isCancelled();

if (cr == null || isCancelled) {
logger.debug("Retrieving HttpServletRequest {} with ContainerResponse {}", request, cr);
if (!isCancelled) {
logger.debug("Unexpected state. ContainerResponse cannot be null or already committed. The connection hasn't been suspended yet");
} else {
logger.debug("ContainerResponse already resumed or cancelled. Ignoring");
}

if (DefaultBroadcaster.class.isAssignableFrom(broadcaster.getClass())) {
DefaultBroadcaster.class.cast(broadcaster).cacheLostMessage(r);
}
AsynchronousProcessor.destroyResource(r);
return;
}
if (DefaultBroadcaster.class.isAssignableFrom(broadcaster.getClass())) {
DefaultBroadcaster.class.cast(broadcaster).cacheLostMessage(r);
}
AsynchronousProcessor.destroyResource(r);
return;
}

synchronized (cr) {
try {
// This is required when you change the response's type
String m = null;

Expand Down

0 comments on commit a63c953

Please sign in to comment.