In Tomcat versions prior to 7.0.35, the servlet context attribute "javax.servlet.context.orderedLibs" has a null value (a fix was added to Tomcat in https://issues.apache.org/bugzilla/show_bug.cgi?id=54391). When context replication is not used, the StandardContext.setAttribute method checks for and handles a null value by invoking StandardContext.removeAttribute. However, when context replication is enabled the null value is passed to ConcurrentHashMap.put which throws a NullPointerException. This causes the context to fail startup.
This work item is to make ReplicatedContext behave the way StandardContext does for null values.
Created attachment 32358 [details] Don't add orderedLibs attribute if it is null The attached patch is for tomcat 8. But the same logic would apply to tomcat 7. The file in tomcat 7 is named java/org/apache/catalina/deploy/WebXml.java. It applies cleanly for trunk. The idea is to not store the attribute, if it is null, since getAttribute will give a null value, if the attribute is not present and the replicated context fails, if the concurrent hashmap gets a null as a value or a key. If noone objects, I will apply the patch.
I'd suggest that this is fixing the symptom rather than the root cause. I think it would be better to replicate the correct handling of setAttribute(String,null) (which is to remove the attribute) in ReplicatedContext.ReplApplContext
Created attachment 32363 [details] Don't add context attribute if it is null Don't add a context attribute if its value or name is null. For the test case the bugfix 57431 will have to be applied.
Included in trunk (r1651120, r1651280). Will be included in 8.0.18 (r1651421, r1651422) and tomcat 7.0.58 (r1651439, r1651446).
Looks good. Thanks for the quick attention on this.