Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AtmosphereInterceptor.postInspect() is not called in case of a handler thrown exception #2073

Closed
reda-alaoui opened this issue Oct 27, 2015 · 4 comments

Comments

@reda-alaoui
Copy link
Contributor

Hi,

Today, it seems that there is no guarantee that AtmosphereInterceptor.postInspect() be called after each AtmosphereInterceptor.inspect().

Indeed, there is no try/finally in AynchronousProcessor:

// handler interceptor lists
        Action a = invokeInterceptors(handlerWrapper.interceptors, resource, tracing);
        if (a.type() != Action.TYPE.CONTINUE && a.type() != Action.TYPE.SKIP_ATMOSPHEREHANDLER) {
            return a;
        }

        // Remap occured.
        if (req.getAttribute(FrameworkConfig.NEW_MAPPING) != null) {
            req.removeAttribute(FrameworkConfig.NEW_MAPPING);
            handlerWrapper = map(req);
            if (handlerWrapper == null) {
                logger.debug("Remap {}", resource.uuid());
                throw new AtmosphereMappingException("Invalid state. No AtmosphereHandler maps request for " + req.getRequestURI());
            }
            resource = configureWorkflow(resource, handlerWrapper, req, res);
            resource.setBroadcaster(handlerWrapper.broadcaster);
        }

        //Unit test mock the request and will throw NPE.
        boolean skipAtmosphereHandler = req.getAttribute(SKIP_ATMOSPHEREHANDLER.name()) != null
                ? (Boolean) req.getAttribute(SKIP_ATMOSPHEREHANDLER.name()) : Boolean.FALSE;
        if (!skipAtmosphereHandler) {
            try {
                logger.trace("\t Last: {}", handlerWrapper.atmosphereHandler.getClass().getName());
                handlerWrapper.atmosphereHandler.onRequest(resource);
            } catch (IOException t) {
                resource.onThrowable(t);
                throw t;
            }
        }

        postInterceptors(handlerWrapper.interceptors, resource);

This prevent us to make use of AtmosphereInterceptor like we do with javax.servlet.Filter.
Is it possible to add the try/finally? Something prevents us from doing it?

@reda-alaoui
Copy link
Contributor Author

Or at least an AtmosphereInterceptor.onThrowable() method?

reda-alaoui added a commit to Cosium/atmosphere that referenced this issue Oct 27, 2015
reda-alaoui added a commit to Cosium/atmosphere that referenced this issue Oct 27, 2015
reda-alaoui added a commit to Cosium/atmosphere that referenced this issue Oct 27, 2015
…case of a handler thrown exception

(cherry picked from commit 767ee2b)
reda-alaoui added a commit to Cosium/atmosphere that referenced this issue Oct 27, 2015
reda-alaoui added a commit to Cosium/atmosphere that referenced this issue Oct 27, 2015
reda-alaoui added a commit to Cosium/atmosphere that referenced this issue Oct 27, 2015
…case of a handler thrown exception

(cherry picked from commit 2679929)
jfarcand pushed a commit that referenced this issue Oct 27, 2015
@jfarcand
Copy link
Member

Fix

@reda-alaoui
Copy link
Contributor Author

Thank you !

@reda-alaoui
Copy link
Contributor Author

There is still an issue, even with my correction.
Incoming pull request.

reda-alaoui added a commit to Cosium/atmosphere that referenced this issue Jan 11, 2016
reda-alaoui added a commit to Cosium/atmosphere that referenced this issue Jan 11, 2016
reda-alaoui added a commit to Cosium/atmosphere that referenced this issue Jan 11, 2016
…case of a handler thrown exception

(cherry picked from commit 3133c59)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants