Hi: Recently when I am checking/testing CXF , there is a mysteriously deadlock of CXF Oneway Process; Normally CXF engine will invoke the one way bussiness logical asynchronized ,, so the servlet handle will finished and return back to servlet engine immediately;
But sometime, I noticed that the servlet handle(JettyHTTPHandler) at server side doesn't return back to servlet engine(Jetty) immediately , it will waiting until the asynchrouse business logical finished; After dig source of CXF, I find it 's relate to OnewayProcessorInterceptor;But until now I can only show when will the deadlock occurs, but I still can not explain why; Following is details: OnewayProcessInterceptor.handleMessage{ synchronized (chain) { message.getExchange().get(Bus.class).getExtension(WorkQueueManager.class) .getAutomaticWorkQueue().execute(new Runnable() { public void run() { synchronized (chain) { System.out.println("--notify all"); chain.notifyAll(); } chain.resume(); //if chain.resume is called before chain.wait finished , the dead lock will occurs; It seems as chain.resume is synchronized, so it will relock on chain object, so the chain.wait() will deadlocked (... I feel confused for this, because jdk doesn't say so...) ;After chain.resume finished, locking on chain is released, deadlock of chain.wait() is also released; but I don't think this is problem of CXF , maybe it's jdk's problem ?? I feels confused; } }); System.out.println("--wait begin"); chain.wait(20); System.out.println("--wait end"); } } syncrhonized PhaseInterceptorChain.resume(){ System.out.println("--api chain resume"); ... } if the execute sequence as following, every thing is ok. there is no dead lock; chain.wait enter chian.notify invoked chain.wait return; chain.resume(); //resume also synchronzed on chain object; if the execute sequence as following , dead lock will occurs: chain.wait enter chain.notify chain.resume// ..now waiting on chain will blocked until chain.resume finished(release sync on chain) chain.wait return; following dump on console indicate the above sequence: No DeadLock dump : --wait begin --notify all --wait end --api chain resume product service begin Fri Aug 19 12:10:28 CST 2011 //a lone time(10 seconds) one way business logical begin product service end Fri Aug 19 12:10:38 CST 2011 .//a lone time(10 seconds) one way business logical end; DeadLock Dump: --wait begin --notify all --api chain resume product service begin Fri Aug 19 12:10:40 CST 2011 product service end Fri Aug 19 12:10:50 CST 2011 --wait end Until now I am not sure if problem is CXF's or JDK's, or something which I don't know cause such a deadlock; I also wrote a simple program to simulate the execute sequnce which causeddead lock in CXF, but the simple program never dead lock; I tried CXF 2.3.3 version && Jetty transport && (JDK1.5_22 || JDK 1.6_17) && Windows XP system; I also post this question as a JIRA issue: