Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 2.0-RC2
    • Fix Version/s: None
    • Component/s: Persistence
    • Labels:
    • Environment:
      Java 6.0.29 (64), Win 7 (64), Postgres 9.0, postgresql-9.1-901.jdbc4

      Description

      Not sure whether this should be better forward to the hibernate team as I guess it is a pure hibernate issue:
      Sometimes, I get an NPE on a list() invokation when hibernate does a flush first.
      I could localize the issue pretty well with a NPE breakpoint in the STS debugger.

      This is the stacktrace:

      DefaultAutoFlushEventListener(AbstractFlushingEventListener).prepareEntityFlushes(EventSource) line: 142	
      DefaultAutoFlushEventListener(AbstractFlushingEventListener).flushEverythingToExecutions(FlushEvent) line: 88	
      DefaultAutoFlushEventListener.onAutoFlush(AutoFlushEvent) line: 58	
      SessionImpl.autoFlushIfRequired(Set) line: 1185	
      SessionImpl.list(CriteriaImpl) line: 1709	
      CriteriaImpl.list() line: 347	
      ListPersistentMethod$1.doInHibernate(Session) line: 76	
      GrailsHibernateTemplate(HibernateTemplate).doExecute(HibernateCallback<T>, boolean, boolean) line: 406	
      GrailsHibernateTemplate(HibernateTemplate).executeFind(HibernateCallback<?>) line: 343	
      ListPersistentMethod.doInvokeInternal(Class, String, Closure, Object[]) line: 56	
      ListPersistentMethod(AbstractStaticPersistentMethod).invoke(Class, String, Closure, Object[]) line: 72	
      ListPersistentMethod(AbstractStaticPersistentMethod).invoke(Class, String, Object[]) line: 65	
      StaticMethodInvocation$invoke.call(Object, Object, Object, Object) line: not available	
      HibernateGormStaticApi<D>.list() line: 317	
      MyDomainClass.list() line: not available	
      MyDomainClass$list.call(Object) line: not available	
      MyService.getMyDomainClass(Date, Date) line: 914	
      MyService$$FastClassByCGLIB$$9f3e42b2.invoke(int, Object, Object[]) line: not available	
      MethodProxy.invoke(Object, Object[]) line: 191	
      Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint() line: 689	
      Cglib2AopProxy$CglibMethodInvocation(ReflectiveMethodInvocation).proceed() line: 150	
      TransactionInterceptor.invoke(MethodInvocation) line: 110	
      Cglib2AopProxy$CglibMethodInvocation(ReflectiveMethodInvocation).proceed() line: 172	
      Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Object, Method, Object[], MethodProxy) line: 622	
      MyService$$EnhancerByCGLIB$$2213eaa6.getMyDomainClass(Date, Date) line: not available	
      NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]	
      NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39	
      DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25	
      Method.invoke(Object, Object...) line: 597	
      ReflectiveInterceptor.jlrMethodInvoke(Method, Object, Object...) line: 1231	
      CachedMethod.invoke(Object, Object[]) line: 90	
      CachedMethod(MetaMethod).doMethodInvoke(Object, Object[]) line: 233	
      ExpandoMetaClass(MetaClassImpl).invokeMethod(Class, Object, String, Object[], boolean, boolean) line: 1054	
      ExpandoMetaClass.invokeMethod(Class, Object, String, Object[], boolean, boolean) line: 1110	
      ExpandoMetaClass(MetaClassImpl).invokeMethod(Object, String, Object[]) line: 884	
      InvokerHelper.invokePogoMethod(Object, String, Object) line: 793	
      InvokerHelper.invokeMethod(Object, String, Object) line: 776	
      ScriptBytecodeAdapter.invokeMethodN(Class, Object, String, Object[]) line: 164	
      GwtController.processCall(String) line: 78	
      GwtController(RemoteServiceServlet).processPost(HttpServletRequest, HttpServletResponse) line: 248	
      GwtController(AbstractRemoteServiceServlet).doPost(HttpServletRequest, HttpServletResponse) line: 62	
      GeneratedMethodAccessor1495.invoke(Object, Object[]) line: not available	
      DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25	
      Method.invoke(Object, Object...) line: 597	
      ReflectiveInterceptor.jlrMethodInvoke(Method, Object, Object...) line: 1231	
      CachedMethod.invoke(Object, Object[]) line: 90	
      CachedMethod(MetaMethod).doMethodInvoke(Object, Object[]) line: 233	
      ExpandoMetaClass(MetaClassImpl).invokeMethod(Class, Object, String, Object[], boolean, boolean) line: 1054	
      ExpandoMetaClass.invokeMethod(Class, Object, String, Object[], boolean, boolean) line: 1110	
      ExpandoMetaClass(MetaClassImpl).invokeMethod(Object, String, Object[]) line: 884	
      ExpandoMetaClass(MetaClassImpl).invokeMethod(Class, Object, String, Object[], boolean, boolean) line: 999	
      ExpandoMetaClass.invokeMethod(Class, Object, String, Object[], boolean, boolean) line: 1110	
      ExpandoMetaClass(MetaClassImpl).invokeMethod(Object, String, Object[]) line: 884	
      PogoMetaClassSite.callCurrent(GroovyObject, Object[]) line: 66	
      PogoMetaClassSite(AbstractCallSite).callCurrent(GroovyObject, Object, Object) line: 145	
      GwtController$_closure1.doCall(Object) line: 29	
      GeneratedMethodAccessor1493.invoke(Object, Object[]) line: not available	
      DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25	
      Method.invoke(Object, Object...) line: 597	
      ReflectiveInterceptor.jlrMethodInvoke(Method, Object, Object...) line: 1231	
      PogoMetaMethodSite$PogoCachedMethodSite.invoke(Object, Object[]) line: 226	
      PogoMetaMethodSite$PogoCachedMethodSite(PogoMetaMethodSite).callCurrent(GroovyObject, Object[]) line: 52	
      PogoMetaMethodSite$PogoCachedMethodSite(AbstractCallSite).callCurrent(GroovyObject, Object) line: 141	
      GwtController$_closure1.doCall() line: not available	
      GeneratedMethodAccessor1492.invoke(Object, Object[]) line: not available	
      DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25	
      Method.invoke(Object, Object...) line: 597	
      ReflectiveInterceptor.jlrMethodInvoke(Method, Object, Object...) line: 1231	
      CachedMethod.invoke(Object, Object[]) line: 90	
      CachedMethod(MetaMethod).doMethodInvoke(Object, Object[]) line: 233	
      ExpandoMetaClass(MetaClassImpl).invokeMethod(Class, Object, String, Object[], boolean, boolean) line: 1054	
      ExpandoMetaClass.invokeMethod(Class, Object, String, Object[], boolean, boolean) line: 1110	
      ExpandoMetaClass(MetaClassImpl).invokeMethod(Object, String, Object[]) line: 884	
      GwtController$_closure1(Closure<V>).call(Object...) line: 410	
      GwtController$_closure1.call(Object...) line: not available	
      GwtController$_closure1(Closure<V>).call() line: 404	
      GwtController$_closure1.call() line: not available	
      java_util_concurrent_Callable$call.call(Object) line: not available	
      GwtController.index() line: not available	
      GeneratedMethodAccessor1490.invoke(Object, Object[]) line: not available	
      DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25	
      Method.invoke(Object, Object...) line: 597	
      ReflectiveInterceptor.jlrMethodInvoke(Method, Object, Object...) line: 1231	
      MixedGrailsControllerHelper.invoke(GroovyObject, Object) line: 67	
      MixedGrailsControllerHelper(AbstractGrailsControllerHelper).handleAction(GroovyObject, Object, HttpServletRequest, HttpServletResponse, Map) line: 330	
      MixedGrailsControllerHelper(AbstractGrailsControllerHelper).executeAction(GroovyObject, String, String, GrailsWebRequest, Map) line: 211	
      MixedGrailsControllerHelper(AbstractGrailsControllerHelper).handleURI(String, GrailsWebRequest, Map) line: 177	
      MixedGrailsControllerHelper(AbstractGrailsControllerHelper).handleURI(String, GrailsWebRequest) line: 116	
      SimpleGrailsController.handleRequest(HttpServletRequest, HttpServletResponse) line: 72	
      SimpleControllerHandlerAdapter.handle(HttpServletRequest, HttpServletResponse, Object) line: 48	
      GrailsDispatcherServlet.doDispatch(HttpServletRequest, HttpServletResponse) line: 325	
      GrailsDispatcherServlet(DispatcherServlet).doService(HttpServletRequest, HttpServletResponse) line: 827	
      GrailsDispatcherServlet(FrameworkServlet).processRequest(HttpServletRequest, HttpServletResponse) line: 874	
      GrailsDispatcherServlet(FrameworkServlet).doPost(HttpServletRequest, HttpServletResponse) line: 790	
      GrailsDispatcherServlet(HttpServlet).service(HttpServletRequest, HttpServletResponse) line: 641	
      GrailsDispatcherServlet(HttpServlet).service(ServletRequest, ServletResponse) line: 722	
      ApplicationFilterChain.internalDoFilter(ServletRequest, ServletResponse) line: 304	
      ApplicationFilterChain.doFilter(ServletRequest, ServletResponse) line: 210	
      UrlMappingsFilter(OncePerRequestFilter).doFilter(ServletRequest, ServletResponse, FilterChain) line: 70	
      ApplicationFilterChain.internalDoFilter(ServletRequest, ServletResponse) line: 243	
      ApplicationFilterChain.doFilter(ServletRequest, ServletResponse) line: 210	
      GrailsWebRequestFilter(OncePerRequestFilter).doFilter(ServletRequest, ServletResponse, FilterChain) line: 70	
      ApplicationFilterChain.internalDoFilter(ServletRequest, ServletResponse) line: 243	
      ApplicationFilterChain.doFilter(ServletRequest, ServletResponse) line: 210	
      HiddenHttpMethodFilter(OncePerRequestFilter).doFilter(ServletRequest, ServletResponse, FilterChain) line: 70	
      ApplicationFilterChain.internalDoFilter(ServletRequest, ServletResponse) line: 243	
      ApplicationFilterChain.doFilter(ServletRequest, ServletResponse) line: 210	
      ApplicationDispatcher.invoke(ServletRequest, ServletResponse, ApplicationDispatcher$State) line: 684	
      ApplicationDispatcher.processRequest(ServletRequest, ServletResponse, ApplicationDispatcher$State) line: 471	
      ApplicationDispatcher.doForward(ServletRequest, ServletResponse) line: 402	
      ApplicationDispatcher.forward(ServletRequest, ServletResponse) line: 329	
      WebUtils.forwardRequestForUrlMappingInfo(HttpServletRequest, HttpServletResponse, UrlMappingInfo, Map, boolean) line: 310	
      WebUtils.forwardRequestForUrlMappingInfo(HttpServletRequest, HttpServletResponse, UrlMappingInfo, Map) line: 275	
      WebUtils.forwardRequestForUrlMappingInfo(HttpServletRequest, HttpServletResponse, UrlMappingInfo) line: 266	
      UrlMappingsFilter.doFilterInternal(HttpServletRequest, HttpServletResponse, FilterChain) line: 209	
      UrlMappingsFilter(OncePerRequestFilter).doFilter(ServletRequest, ServletResponse, FilterChain) line: 76	
      ApplicationFilterChain.internalDoFilter(ServletRequest, ServletResponse) line: 243	
      ApplicationFilterChain.doFilter(ServletRequest, ServletResponse) line: 210	
      GrailsPageFilter.obtainContent(ContentProcessor, SiteMeshWebAppContext, HttpServletRequest, HttpServletResponse, FilterChain) line: 200	
      GrailsPageFilter.doFilter(ServletRequest, ServletResponse, FilterChain) line: 151	
      ApplicationFilterChain.internalDoFilter(ServletRequest, ServletResponse) line: 243	
      ApplicationFilterChain.doFilter(ServletRequest, ServletResponse) line: 210	
      GrailsWebRequestFilter.doFilterInternal(HttpServletRequest, HttpServletResponse, FilterChain) line: 69	
      GrailsWebRequestFilter(OncePerRequestFilter).doFilter(ServletRequest, ServletResponse, FilterChain) line: 76	
      ApplicationFilterChain.internalDoFilter(ServletRequest, ServletResponse) line: 243	
      ApplicationFilterChain.doFilter(ServletRequest, ServletResponse) line: 210	
      HiddenHttpMethodFilter.doFilterInternal(HttpServletRequest, HttpServletResponse, FilterChain) line: 65	
      HiddenHttpMethodFilter(OncePerRequestFilter).doFilter(ServletRequest, ServletResponse, FilterChain) line: 76	
      ApplicationFilterChain.internalDoFilter(ServletRequest, ServletResponse) line: 243	
      ApplicationFilterChain.doFilter(ServletRequest, ServletResponse) line: 210	
      ShiroFilterFactoryBean$SpringShiroFilter(AbstractShiroFilter).executeChain(ServletRequest, ServletResponse, FilterChain) line: 359	
      AbstractShiroFilter$1.call() line: 275	
      SubjectCallable<V>.doCall(Callable<V>) line: 90	
      SubjectCallable<V>.call() line: 83	
      WebDelegatingSubject(DelegatingSubject).execute(Callable<V>) line: 344	
      ShiroFilterFactoryBean$SpringShiroFilter(AbstractShiroFilter).doFilterInternal(ServletRequest, ServletResponse, FilterChain) line: 272	
      ShiroFilterFactoryBean$SpringShiroFilter(OncePerRequestFilter).doFilter(ServletRequest, ServletResponse, FilterChain) line: 81	
      DelegatingFilterProxy.invokeDelegate(Filter, ServletRequest, ServletResponse, FilterChain) line: 346	
      DelegatingFilterProxy.doFilter(ServletRequest, ServletResponse, FilterChain) line: 259	
      ApplicationFilterChain.internalDoFilter(ServletRequest, ServletResponse) line: 243	
      ApplicationFilterChain.doFilter(ServletRequest, ServletResponse) line: 210	
      SavedRequestFilter.doFilter(ServletRequest, ServletResponse, FilterChain) line: 55	
      ApplicationFilterChain.internalDoFilter(ServletRequest, ServletResponse) line: 243	
      ApplicationFilterChain.doFilter(ServletRequest, ServletResponse) line: 210	
      CharacterEncodingFilter.doFilterInternal(HttpServletRequest, HttpServletResponse, FilterChain) line: 88	
      CharacterEncodingFilter(OncePerRequestFilter).doFilter(ServletRequest, ServletResponse, FilterChain) line: 76	
      DelegatingFilterProxy.invokeDelegate(Filter, ServletRequest, ServletResponse, FilterChain) line: 346	
      DelegatingFilterProxy.doFilter(ServletRequest, ServletResponse, FilterChain) line: 259	
      ApplicationFilterChain.internalDoFilter(ServletRequest, ServletResponse) line: 243	
      ApplicationFilterChain.doFilter(ServletRequest, ServletResponse) line: 210	
      StandardWrapperValve.invoke(Request, Response) line: 240	
      StandardContextValve.invoke(Request, Response) line: 164	
      NonLoginAuthenticator(AuthenticatorBase).invoke(Request, Response) line: 462	
      StandardHostValve.invoke(Request, Response) line: 164	
      ErrorReportValve.invoke(Request, Response) line: 100	
      StandardEngineValve.invoke(Request, Response) line: 118	
      CoyoteAdapter.service(Request, Response) line: 403	
      Http11Processor.process(SocketWrapper<Socket>) line: 301	
      Http11Protocol$Http11ConnectionHandler.process(SocketWrapper<Socket>, SocketStatus) line: 162	
      JIoEndpoint$SocketProcessor.run() line: 309	
      ThreadPoolExecutor$Worker.runTask(Runnable) line: 886	
      ThreadPoolExecutor$Worker.run() line: 908	
      TaskThread(Thread).run() line: 662
      

      The offending method is

      private void prepareEntityFlushes(EventSource session) throws HibernateException {
      
      		log.debug("processing flush-time cascades");
      
      		final Map.Entry[] list = IdentityMap.concurrentEntries( session.getPersistenceContext().getEntityEntries() );
      		//safe from concurrent modification because of how entryList() is implemented on IdentityMap
      		final int size = list.length;
      		final Object anything = getAnything();
      		for ( int i=0; i<size; i++ ) {
      			Map.Entry me = list[i];
      			EntityEntry entry = (EntityEntry) me.getValue();
      			Status status = entry.getStatus();
      			if ( status == Status.MANAGED || status == Status.SAVING || status == Status.READ_ONLY ) {
      				cascadeOnFlush( session, entry.getPersister(), me.getKey(), anything );
      			}
      		}
      	}
      

      The last entry in the generated list (from the IdentityMap) is sometimes null.

      Would like to create a test case for this but really don't know how ;(

        Activity

        Hide
        Fat Zopilot added a comment -

        Some more information:
        What I did in my code (and what I tried to put in a case (that did not reproduce the error so far)) is

        def one = entries.list()
        def two = entries2.list()
        
        def entries = Entry.list();
            GParsPool.withPool {
        	entries.eachParallel{entry ->
            	    Entry.withTransaction { it ->
                         doSomethingWith(it)  //possible modification
                    }
                }
            }
        
        Entry2.list(); <- offending code, but only because it triggers the flush
        

        It must be something cache related (as it does not occur on initial fetch and if there is "enough" time between consecutive invocations (cache invalidation).
        If DataSource.hibernate.cache.use_query_cache = false the error does not seem to occur any more.

        Show
        Fat Zopilot added a comment - Some more information: What I did in my code (and what I tried to put in a case (that did not reproduce the error so far)) is def one = entries.list() def two = entries2.list() def entries = Entry.list(); GParsPool.withPool { entries.eachParallel{entry -> Entry.withTransaction { it -> doSomethingWith(it) //possible modification } } } Entry2.list(); <- offending code, but only because it triggers the flush It must be something cache related (as it does not occur on initial fetch and if there is "enough" time between consecutive invocations (cache invalidation). If DataSource.hibernate.cache.use_query_cache = false the error does not seem to occur any more.

          People

          • Assignee:
            Unassigned
            Reporter:
            Fat Zopilot
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Last Reviewed:

              Development