Closed sudosandwich3 closed 7 years ago
@sudosandwich3 I have also faced the same issue. Did you find any fix or fixed using inline hibernate-plugin?
Can you provide either written steps to reproduce this or an actual test case? I am having trouble understanding how to get into this scenario.
As for a workaround, the interceptor is a spring bean. Did you try to define your own implementation of the interceptor that overrides the interceptor included by this plugin?
@alexkramer I have created a custom hibernate interceptor filter bean to override now.
class HibernateFilterInterceptor implements Interceptor {
private static Logger log = LoggerFactory.getLogger(HibernateFilterInterceptor)
SessionFactory sessionFactory
RxHibernateFilterInterceptor() {
matchAll()
.excludes(uri: "/static/**").excludes(uri: "/img/**")
.excludes(uri: "/js/*").excludes(uri: "/css/**")
.excludes(uri: "/assets/**").excludes(uri: "/**.**")
.excludes(uri: "/images/**")
.excludes(uri: "/console/**")
}
boolean before() {
Session session
try {
session = sessionFactory.currentSession
} catch (HibernateException ex) {
log.debug("No Hibernate session found for HibernateFilterInterceptor")
log.debug(ex.message)
session = null
}
if (session) {
DefaultHibernateFiltersHolder.defaultFilters.each {
session.enableFilter it
}
}
true
}
}
The fix for this should be merged and published to the bintray repo as 0.5.3.
HibernateFilterInterceptor assumes a session exists in the current thread. In the case of error or the user not being authorized, this will not defined and an exception is thrown. There probably needs to be a check here: