Project: Tomcat
Bug 53606 NullPointerException in TcpPingInterceptor
Reported: 2012-07-26 16:15:05 | Status: resolved fixed

start(int) method initializes failureDetector (resp. staticMembers) only if TcpFailureDetector (resp. StaticMembershipInterceptor) was found in channel interceptors stack. Without TcpFailureDetector (resp. StaticMembershipInterceptor), futur calls to sendPing() will fail because failureDetector (resp. staticMembers) wasn't initialized at least to new WeakReference<StaticMembershipInterceptor>(null). Fix: v1) initializes weak references containers: Replace: WeakReference<TcpFailureDetector> failureDetector = null; WeakReference<StaticMembershipInterceptor> staticMembers = null; for: WeakReference<TcpFailureDetector> failureDetector = new WeakReference<TcpFailureDetector>(); WeakReference<StaticMembershipInterceptor> staticMembers = new WeakReference<StaticMembershipInterceptor>(); v2) checks field before dereferencing it: sendPing becomes: protected void sendPing() { if (failureDetector!=null && failureDetector.get()!=null) { //we have a reference to the failure detector //piggy back on that dude failureDetector.get().checkMembers(true); }else { if (staticOnly && staticMembers!=null && staticMembers.get()!=null) { sendPingMessage(staticMembers.get().getMembers()); } else { sendPingMessage(getMembers()); } } } affect also tomcat 6 regards fred arnoud

Files changed in fix:
java/org/apache/catalina/tribes/group/interceptors/TcpPingInterceptor.java