You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by "Jonathan S Fisher (Jira)" <ji...@apache.org> on 2019/08/30 13:34:00 UTC

[jira] [Created] (TOMEE-2653) TomEE throws a JMS2 exception when the request CDI Scope closes down, if you thread is in an interrupted state

Jonathan S Fisher created TOMEE-2653:
----------------------------------------

             Summary: TomEE throws a JMS2 exception when the request CDI Scope closes down, if you thread is in an interrupted state
                 Key: TOMEE-2653
                 URL: https://issues.apache.org/jira/browse/TOMEE-2653
             Project: TomEE
          Issue Type: Bug
            Reporter: Jonathan S Fisher


TomEE throws a JMS2 exception when the request CDI Scope closes down, if you thread is in an interrupted state.

Let's say you start a message consumer in a request scoped context. If you interrupt the thread (stopping the consumer) and close the consumer properly, TomEE will throw an exception when it cleans up the request scope (the point at which closes the JMS Context, per the JMS 2.0 spec).

 
{code:java}
SEVERE: Exception thrown while destroying bean instance : [RequestAutoContextDestruction, WebBeansType:MANAGED, Name:null, API Types:[org.apache.openejb.resource.activemq.jms2.cdi.JMS2CDIExtension$RequestAutoContextDestruction,java.lang.Object,org.apache.openejb.resource.activemq.jms2.cdi.JMS2CDIExtension$AutoContextDestruction,java.io.Serializable], Qualifiers:[javax.enterprise.inject.Default,javax.enterprise.inject.Any]]
javax.jms.JMSRuntimeException: java.io.InterruptedIOException
	at org.apache.openejb.resource.activemq.jms2.JMS2.toRuntimeException(JMS2.java:86)
	at org.apache.openejb.resource.activemq.jms2.JMSContextImpl.close(JMSContextImpl.java:155)
	at org.apache.openejb.resource.activemq.jms2.cdi.JMS2CDIExtension$AutoContextDestruction.destroy(JMS2CDIExtension.java:158)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.apache.webbeans.intercept.LifecycleInterceptorInvocationContext.proceed(LifecycleInterceptorInvocationContext.java:103)
	at org.apache.webbeans.portable.InjectionTargetImpl.preDestroy(InjectionTargetImpl.java:352)
	at org.apache.webbeans.component.AbstractOwbBean.destroy(AbstractOwbBean.java:179)
	at org.apache.webbeans.context.AbstractContext.destroyInstance(AbstractContext.java:206)
	at org.apache.webbeans.context.AbstractContext.destroyInstance(AbstractContext.java:192)
	at org.apache.webbeans.context.AbstractContext.destroy(AbstractContext.java:218)
	at org.apache.webbeans.web.context.ServletRequestContext.destroy(ServletRequestContext.java:69)
	at org.apache.webbeans.web.context.WebContextsService.destroyRequestContext(WebContextsService.java:426)
	at org.apache.openejb.cdi.CdiAppContextsService.destroyRequestContext(CdiAppContextsService.java:113)
	at org.apache.webbeans.web.context.WebContextsService.endContext(WebContextsService.java:223)
	at org.apache.deltaspike.cdise.owb.OpenWebBeansContextControl.stopRequestScope(OpenWebBeansContextControl.java:230)
	at org.apache.deltaspike.cdise.owb.OpenWebBeansContextControl.stopContext(OpenWebBeansContextControl.java:104)
	at com.xxx.ContactActivityMonitor.run(ContactActivityMonitor.java:94)
	at org.apache.openejb.threads.task.CURunnable$1.call(CURunnable.java:35)
	at org.apache.openejb.threads.task.CURunnable$1.call(CURunnable.java:32)
	at org.apache.openejb.threads.task.CUTask.invoke(CUTask.java:100)
	at org.apache.openejb.threads.task.CURunnable.run(CURunnable.java:32)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
Caused by: javax.jms.JMSException: java.io.InterruptedIOException
	at org.apache.activemq.util.JMSExceptionSupport.create(JMSExceptionSupport.java:72)
	at org.apache.activemq.ActiveMQConnection.doAsyncSendPacket(ActiveMQConnection.java:1310)
	at org.apache.activemq.ActiveMQConnection.asyncSendPacket(ActiveMQConnection.java:1302)
	at org.apache.activemq.ActiveMQSession.doClose(ActiveMQSession.java:666)
	at org.apache.activemq.ActiveMQSession.close(ActiveMQSession.java:657)
	at org.apache.openejb.resource.activemq.jms2.JMSContextImpl.close(JMSContextImpl.java:147)
	... 29 more
Caused by: java.io.InterruptedIOException
	at org.apache.activemq.transport.vm.VMTransport.oneway(VMTransport.java:128)
	at org.apache.activemq.transport.MutexTransport.oneway(MutexTransport.java:68)
	at org.apache.activemq.transport.ResponseCorrelator.oneway(ResponseCorrelator.java:60)
	at org.apache.activemq.ActiveMQConnection.doAsyncSendPacket(ActiveMQConnection.java:1308)
	... 33 more
Caused by: java.lang.InterruptedException
	at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireInterruptibly(AbstractQueuedSynchronizer.java:1220)
	at java.util.concurrent.locks.ReentrantLock.lockInterruptibly(ReentrantLock.java:335)
	at java.util.concurrent.LinkedBlockingQueue.put(LinkedBlockingQueue.java:339)
	at org.apache.activemq.transport.vm.VMTransport.oneway(VMTransport.java:97)
	... 36 more

{code}


This appears to be a result JMSContextImpl attempting to close both the session and the connection:

{code}
    @Override
    public void close() {
        try {
            synchronized (this) {
                if (session != null) {
                    session.close();
                }
                if (connection != null) {
                    connection.close();
                }
                closed = true;
            }
        } catch (final JMSException e) {
            throw toRuntimeException(e);
        }
    }
{code}

Per the JMS Connection spec, closing the connection should be more than sufficient to cleanup.



--
This message was sent by Atlassian Jira
(v8.3.2#803003)