Hi,
There was a bug reported for TomcatValveContainer, saying that, if someone
try to call addValves(index, valveList) to add a valve to
TomcatValveContainer when the TomcatValveContainer is empty, it gives,
java.lang.IllegalArgumentException: Invalid value specified for index: 0
So, when the code is analyzed, I found out that, it is caused by the
following line.
if (index < 0 || index >= TomcatValveContainer.valves.size()) {throw new
IllegalArgumentException("Invalid value specified for index: " + index);
}
According to the line above, if someone try to add a valve to the index=0,
when the TomcatValveContainer.valves is empty, it will throw an exception.
There was another issue, if you add 3 valves from index=2 onwards, when
there are 5 valves already in the TomcatValveContainer. The
TomcatValveContainer will have 8 valves but the link between the last valve
on the inserting valve list and the valve, previously at the index=2 was
not set. So you will end up having 0,1, from the previous list and 2,3,4
from the new list. So if you access valve chain you have access to only 5
valves. Links to the valves at 2,3,4 position are lost.
So, as per the new implementation.
1. Check the inserting valves list for null and emptiness
2. Boundary check on the TomcatValveContainer.valves
3. Link the previous valve to the first valve in the inserting list
4. Link the last valve of the inserting list to the valve previously
resided at the given index
5. Make links between inserting valves
6. Add valves to the TomcatValveContainer.valves
Regards,
*Jayanga Dissanayake*
Senior Software Engineer
WSO2 Inc. - http://wso2.com/
lean . enterprise . middleware
email: [email protected]
mobile: +94772207259
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev