You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bu...@apache.org on 2012/07/26 18:15:05 UTC
[Bug 53606] New: NullPointerException in TcpPingInterceptor
https://issues.apache.org/bugzilla/show_bug.cgi?id=53606
Priority: P2
Bug ID: 53606
Assignee: dev@tomcat.apache.org
Summary: NullPointerException in TcpPingInterceptor
Severity: blocker
Classification: Unclassified
Reporter: frederic.arnoud@gmail.com
Hardware: PC
Status: NEW
Version: unspecified
Component: Cluster
Product: Tomcat 7
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
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
[Bug 53606] NullPointerException in TcpPingInterceptor
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=53606
F.Arnoud <fr...@gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
OS| |All
--- Comment #1 from F.Arnoud <fr...@gmail.com> ---
Sorry:
Forget first solution (v1) we cannot set a weak reference.
Need to modify sendPing method to check null pointer.
regards
fred
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
[Bug 53606] NullPointerException in TcpPingInterceptor
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=53606
--- Comment #3 from Sebb <se...@apache.org> ---
(In reply to comment #2)
> I used this solution:
>
> protected void sendPing() {
> TcpFailureDetector tcpFailureDetector = failureDetector!=null ?
> failureDetector.get() : null;
> if (tcpFailureDetector!=null) {
That's nice; and better than v2 as it also protects against another possible
NPE, i.e.:
failureDetector.get() can return null (it's a WeakReference, so get() can
return null at any time).
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
[Bug 53606] NullPointerException in TcpPingInterceptor
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=53606
Mark Thomas <ma...@apache.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|REOPENED |RESOLVED
Resolution|--- |FIXED
--- Comment #7 from Mark Thomas <ma...@apache.org> ---
Fixed in 6.0.x and will be included in 6.0.36 onwards.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
[Bug 53606] NullPointerException in TcpPingInterceptor
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=53606
Mark Thomas <ma...@apache.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |FIXED
Severity|blocker |normal
--- Comment #5 from Mark Thomas <ma...@apache.org> ---
Fixed in trunk and 7.0.x and will be included in 7.0.30 onwards. Thanks for the
patch.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
[Bug 53606] NullPointerException in TcpPingInterceptor
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=53606
--- Comment #4 from F.Arnoud <fr...@gmail.com> ---
You're right, only one access to get() for WeakReference (and brother classes).
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
[Bug 53606] NullPointerException in TcpPingInterceptor
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=53606
--- Comment #2 from F.Arnoud <fr...@gmail.com> ---
I used this solution:
protected void sendPing() {
TcpFailureDetector tcpFailureDetector = failureDetector!=null ?
failureDetector.get() : null;
if (tcpFailureDetector!=null) {
//we have a reference to the failure detector
//piggy back on that dude
tcpFailureDetector.checkMembers(true);
}else {
StaticMembershipInterceptor staticMembershipInterceptor =
staticOnly && staticMembers!=null ? staticMembers.get() : null;
if (staticMembershipInterceptor!=null) {
sendPingMessage(staticMembershipInterceptor.getMembers());
} else {
sendPingMessage(getMembers());
}
}
}
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
[Bug 53606] NullPointerException in TcpPingInterceptor
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=53606
Mark Thomas <ma...@apache.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |REOPENED
Component|Cluster |Cluster
Resolution|FIXED |---
Product|Tomcat 7 |Tomcat 6
Target Milestone|--- |default
--- Comment #6 from Mark Thomas <ma...@apache.org> ---
Whoops. Re-open for Tomcat 6.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org