[jboss-cvs] JBossAS SVN: r104478 - in branches/JBPAPP_5_1: testsuite/src/main/org/jboss/test/cluster/defaultcfg/test and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed May 5 10:26:56 EDT 2010
Author: bstansberry at jboss.com
Date: 2010-05-05 10:26:55 -0400 (Wed, 05 May 2010)
New Revision: 104478
Modified:
branches/JBPAPP_5_1/cluster/src/main/org/jboss/ha/jndi/LookupSucceededFilter.java
branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/LookupSucceededFilterUnitTestCase.java
branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/cluster/rspfilter/TruthfulResponseFilter.java
Log:
[JBPAPP-4113] Make LookupSucceededFilter thread safe
Modified: branches/JBPAPP_5_1/cluster/src/main/org/jboss/ha/jndi/LookupSucceededFilter.java
===================================================================
--- branches/JBPAPP_5_1/cluster/src/main/org/jboss/ha/jndi/LookupSucceededFilter.java 2010-05-05 14:03:49 UTC (rev 104477)
+++ branches/JBPAPP_5_1/cluster/src/main/org/jboss/ha/jndi/LookupSucceededFilter.java 2010-05-05 14:26:55 UTC (rev 104478)
@@ -37,7 +37,7 @@
{
private static final Logger log = Logger.getLogger(LookupSucceededFilter.class);
private static final boolean trace = log.isTraceEnabled();
- private boolean lookupSucceeded;
+ private volatile boolean lookupSucceeded;
public boolean isAcceptable(Object response, ClusterNode sender)
{
@@ -46,14 +46,20 @@
log.trace("isAcceptable (" + response + ") from " + sender);
}
- lookupSucceeded = (response != null) && !(response instanceof Exception) && !(response instanceof NoHandlerForRPC);
-
- if (trace && lookupSucceeded)
- {
- log.trace("Lookup succeded from " + sender);
+ if ((response != null) && !(response instanceof Exception) && !(response instanceof NoHandlerForRPC))
+ {
+ if (trace)
+ {
+ log.trace("Lookup succeded from " + sender);
+ }
+ lookupSucceeded = true;
}
-
- return true;
+
+ // NOTE: *MUST* always return true or the RPC will never complete
+ // if no response is "acceptable". Returning true cause the response
+ // count to be incremented, allowing the call to complete when the
+ // desired numbers of responses are in
+ return true;
}
public boolean needMoreResponses()
Modified: branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/LookupSucceededFilterUnitTestCase.java
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/LookupSucceededFilterUnitTestCase.java 2010-05-05 14:03:49 UTC (rev 104477)
+++ branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/LookupSucceededFilterUnitTestCase.java 2010-05-05 14:26:55 UTC (rev 104478)
@@ -55,6 +55,22 @@
exerciseFilterLogic(adapter, sender);
}
+ /**
+ * JBAS-7945. Test that receiving a non-acceptable response before
+ * the needMoreResponses() call from an earlier acceptable response
+ * doesn't result in an incorrect answer.
+ */
+ public void testConcurrentResponses()
+ {
+ ResponseFilter filter = new LookupSucceededFilter();
+ ClusterNode sender1 = new ClusterNodeImpl(new IpAddress(12345));
+ ClusterNode sender2 = new ClusterNodeImpl(new IpAddress(67890));
+
+ filter.isAcceptable("A", sender1);
+ filter.isAcceptable(null, sender2);
+ assertFalse("Concurrency problem (JBAS-7945)",filter.needMoreResponses());
+ }
+
private void exerciseFilterLogic(ResponseFilter filter, ClusterNode sender)
{
filter.isAcceptable(null, sender);
Modified: branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/cluster/rspfilter/TruthfulResponseFilter.java
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/cluster/rspfilter/TruthfulResponseFilter.java 2010-05-05 14:03:49 UTC (rev 104477)
+++ branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/cluster/rspfilter/TruthfulResponseFilter.java 2010-05-05 14:26:55 UTC (rev 104478)
@@ -37,23 +37,22 @@
{
private static final long serialVersionUID = 2223820538160300865L;
private static final Logger log = Logger.getLogger(TruthfulResponseFilter.class);
- private boolean lookupSucceeded;
+ private volatile boolean lookupSucceeded;
public boolean isAcceptable(Object response, ClusterNode sender)
{
log.debug("isAcceptable (" + response + ") from " + sender);
- if (response != null && !(response instanceof Exception) && !(response instanceof NoHandlerForRPC))
+ if (response instanceof Boolean && ((Boolean)response).booleanValue())
{
- lookupSucceeded = (Boolean)response;
- }
-
- if (lookupSucceeded)
- {
+ lookupSucceeded = true;
+
log.debug("Lookup succeded from " + sender);
+
+ return true;
}
- return lookupSucceeded;
+ return false;
}
public boolean needMoreResponses()
More information about the jboss-cvs-commits
mailing list