Details
-
Bug
-
Status: Open
-
Major
-
Resolution: Unresolved
-
1.7.4
-
None
-
None
-
Important
Description
I believe there is a problem or rather multiple problems in the Phase/Handler flow indexing..but I am not 100% sure.
In 'org.apache.axis2.engine.Phase':
1. During the Phase invocation:
While cycling through the handlers, I would expect 'msgctx.setHandlerIndex(i+1)' but instead the phase index is incremented.
int handlersSize = handlers.size(); for (int i= currentIndex; i < handlersSize; i++) { Handler handler = (Handler) handlers.get(i); InvocationResponse pi = invokeHandler(handler, msgctx); if (!pi.equals(InvocationResponse.CONTINUE)) { return pi; } // Set phase index to the next handler msgctx.setCurrentPhaseIndex(i+1); }
2. During the phase 'flowComplete':
I would expect here 'msgContext.getCurrenHandlerIndex()' and 'msgContext.setCurrentHandlerIndex(0)' instead.
// This will be non-zero if we failed during execution of one of the // handlers in this phase int currentHandlerIndex = msgContext.getCurrentPhaseIndex(); if (currentHandlerIndex == 0) { currentHandlerIndex = handlers.size(); } else { /*We need to set it to 0 so that any previous phases will execute all * of their handlers.*/ msgContext.setCurrentPhaseIndex(0); } for (; currentHandlerIndex > 0; currentHandlerIndex--) { Handler handler = (Handler) handlers.get(currentHandlerIndex - 1); if (isDebugEnabled) { log.debug(msgContext.getLogIDString() + " Invoking flowComplete() for Handler '" + handler.getName() + "' in Phase '" + phaseName + "'"); } handler.flowComplete(msgContext); }
This is currrently causing errors in our installation because we are seeing a currentPhaseIndex == 1, which forces the "currentHandlerIndex == 1"; however the phase we are in has no handlers. This causes an OutOfBoundsException when it attempts to get the handler with index[0] (1-1).
java.lang.ArrayIndexOutOfBoundsException: 0 at java.util.concurrent.CopyOnWriteArrayList.get(CopyOnWriteArrayList.java:368) at java.util.concurrent.CopyOnWriteArrayList.get(CopyOnWriteArrayList.java:377) at org.apache.axis2.engine.Phase.flowComplete(Phase.java:361)
Unfortunately I am not sure if there even more locations where HandlerIndex instead of PhaseIndex probably should have been used.