benlucchesi / grails-cookie-session

cookie sessions for grails applications
28 stars 32 forks source link

Cannot use 'grails.plugin.cookiesession.serializer' #74

Open fchristol opened 6 years ago

fchristol commented 6 years ago

Hello,

I have created a custom Session serializer which implements SessionSerializer and that is declared as bean mySessionSerializer. But I cannot use it with : grails.plugin.cookiesession.serializer='mySessionSerializer'

The reason is that it seems that there is a bug in CookieSessionRepository.groovy, in line :

else if( applicationContext.containsBean(serializer) && applicationContext.getType(serializer) instanceof SessionSerializer ){

Indeed, the test "applicationContext.getType(serializer) instanceof SessionSerializer" is never 'true'. It is even not 'true' for the 'javaSessionSerializer' :

"applicationContext.getType('javaSessionSerializer') instanceof SessionSerializer" is 'false'

My two cents is that the test should be :

"applicationContext.getBean(serializer) instanceof SessionSerializer", which returns 'true' as expected

double16 commented 6 years ago

If you are using Grails 3, please try http://plugins.grails.org/plugin/double16/cookie-session . This issue has been addressed there.