benlucchesi / grails-cookie-session

cookie sessions for grails applications
28 stars 32 forks source link

Throw MaxSizeExceededException instead of raw exception when session max size is exceeded #70

Closed sanmibuh closed 8 years ago

sanmibuh commented 8 years ago

Throwing a particular exception instead of raw exception when session max size is exceeded avoids this workaround if you need to change behavior of CookieSessionRepository extending the base bean:

    @Override
    void putDataInCookie(HttpServletResponse response, String value) {
        try {
            super.putDataInCookie(response, value)
        } catch (RuntimeException rte) {
            throw rte
        } catch (Exception e) {
            deleteCookie(response)
        }
    } 

with

    @Override
    void putDataInCookie(HttpServletResponse response, String value) {
        try {
            super.putDataInCookie(response, value)
        } catch (MaxSizeExceededException msee) {
            deleteCookie(response)
        }
    }

PD: We Use grails 2.X. This is the cause that the PR goes to 2.0.18 version

benlucchesi commented 8 years ago

can you take a look at line 144 in CookieSessionRepository...

log.debug 'retrieved {} bytes of data from {} session cookies.', data.size(), values.size()

I'm not familiar with this pattern - does the second and third arguments get merged into the first argument?

sanmibuh commented 8 years ago

Yes, It is Slf4j API mode logging (see @Slf4j annotation). The strings are generated only if selected logging level is active.

See http://www.slf4j.org/faq.html#logging_performance

benlucchesi commented 8 years ago

are you guys building the plugin locally or deploying through plugin system? I ask because its going to take me a bit to get this published.

sanmibuh commented 8 years ago

We are deploying through the plugin system. We would be very grateful that you will publish the new release 2.0.19