You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ode.apache.org by bo...@apache.org on 2008/12/04 01:06:01 UTC
svn commit: r723157 - in /ode/branches/APACHE_ODE_1.X/bpel-api/src:
main/java/org/apache/ode/bpel/common/CorrelationKeySet.java
test/java/org/apache/ode/bpel/common/CorrelationKeySetTest.java
Author: boisvert
Date: Wed Dec 3 16:06:01 2008
New Revision: 723157
URL: http://svn.apache.org/viewvc?rev=723157&view=rev
Log:
ODE-448: Message routing fails when implicit and explicit correlations are used together
Modified:
ode/branches/APACHE_ODE_1.X/bpel-api/src/main/java/org/apache/ode/bpel/common/CorrelationKeySet.java
ode/branches/APACHE_ODE_1.X/bpel-api/src/test/java/org/apache/ode/bpel/common/CorrelationKeySetTest.java
Modified: ode/branches/APACHE_ODE_1.X/bpel-api/src/main/java/org/apache/ode/bpel/common/CorrelationKeySet.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-api/src/main/java/org/apache/ode/bpel/common/CorrelationKeySet.java?rev=723157&r1=723156&r2=723157&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/bpel-api/src/main/java/org/apache/ode/bpel/common/CorrelationKeySet.java (original)
+++ ode/branches/APACHE_ODE_1.X/bpel-api/src/main/java/org/apache/ode/bpel/common/CorrelationKeySet.java Wed Dec 3 16:06:01 2008
@@ -180,39 +180,43 @@
public List<CorrelationKeySet> findSubSets() {
List<CorrelationKeySet> subSets = new ArrayList<CorrelationKeySet>();
- // split into two sets: with mandatory keys and with optional keys
- CorrelationKeySet mandatoryKeySet = new CorrelationKeySet();
- CorrelationKeySet optionalKeySet = new CorrelationKeySet();
+ // if the key set contains a opaque key and at least one non-opaque key, take out the opaque key
+ CorrelationKey opaqueKey = null;
+ boolean containsNonOpaque = false;
+ CorrelationKeySet explicitKeySet = new CorrelationKeySet();
for( CorrelationKey ckey : correlationKeys ) {
- if( ckey instanceof OptionalCorrelationKey ) {
- optionalKeySet.add(ckey);
+ // assumes only ONE opaque key if there is
+ if( ckey.getCSetId() == -1 ) {
+ opaqueKey = ckey;
} else {
- mandatoryKeySet.add(ckey);
+ containsNonOpaque = true;
+ }
+ explicitKeySet.add(ckey);
+ }
+ if( opaqueKey != null && containsNonOpaque ) {
+ explicitKeySet.correlationKeys.remove(opaqueKey);
+ }
+
+ // we are generating (2 powered by the number of correlation keys) number of sub-sets
+ for( int setIndex = 0; setIndex < Math.pow(2, explicitKeySet.correlationKeys.size()); setIndex++ ) {
+ CorrelationKeySet subKeySet = new CorrelationKeySet();
+ int bitPattern = setIndex; // the bitPattern will be 0b0000, 0b0001, 0b0010 and so on
+ Iterator<CorrelationKey> ckeys = explicitKeySet.iterator();
+ while( ckeys.hasNext() && bitPattern > 0 ) { // bitPattern > 0 condition saves half of the iterations
+ CorrelationKey ckey = ckeys.next();
+ if( (bitPattern & 0x01) > 0 ) {
+ subKeySet.add(ckey);
+ }
+ bitPattern = bitPattern >> 1;
+ }
+
+ if(!subKeySet.isEmpty()) { // we don't want an empty set
+ subSets.add(subKeySet);
}
}
- if( optionalKeySet.isEmpty() ) {
- // no optional keys found
- subSets.add(this);
- } else {
- // we are generating (2 powered by the number of correlation keys) number of sub-sets
- for( int setIndex = 0; setIndex < Math.pow(2, optionalKeySet.correlationKeys.size()); setIndex++ ) {
- CorrelationKeySet subKeySet = new CorrelationKeySet();
- int bitPattern = setIndex; // the bitPattern will be 0b0000, 0b0001, 0b0010 and so on
- Iterator<CorrelationKey> ckeys = optionalKeySet.iterator();
- while( ckeys.hasNext() && bitPattern > 0 ) { // bitPattern > 0 condition saves half of the iterations
- CorrelationKey ckey = ckeys.next();
- if( (bitPattern & 0x01) > 0 ) {
- subKeySet.add(ckey);
- }
- bitPattern = bitPattern >> 1;
- }
- // add the mandatory keys
- subKeySet.correlationKeys.addAll(mandatoryKeySet.correlationKeys);
- if(!subKeySet.isEmpty()) { // we don't want an empty set
- subSets.add(subKeySet);
- }
- }
+ if( subSets.isEmpty() ) {
+ subSets.add(new CorrelationKeySet());
}
return subSets;
Modified: ode/branches/APACHE_ODE_1.X/bpel-api/src/test/java/org/apache/ode/bpel/common/CorrelationKeySetTest.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-api/src/test/java/org/apache/ode/bpel/common/CorrelationKeySetTest.java?rev=723157&r1=723156&r2=723157&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/bpel-api/src/test/java/org/apache/ode/bpel/common/CorrelationKeySetTest.java (original)
+++ ode/branches/APACHE_ODE_1.X/bpel-api/src/test/java/org/apache/ode/bpel/common/CorrelationKeySetTest.java Wed Dec 3 16:06:01 2008
@@ -10,6 +10,7 @@
private CorrelationKey optX = new OptionalCorrelationKey("1~a~b");
private CorrelationKey optY = new OptionalCorrelationKey("2~b~c");
private CorrelationKey optZ = new OptionalCorrelationKey("3~c~d");
+ private CorrelationKey implicit = new CorrelationKey("-1~a");
@Test
public void testCanonicalString() throws Exception {
@@ -57,7 +58,7 @@
assertEquals(new CorrelationKeySet("@2[1~key1],[2~key2~key3]?"),
new CorrelationKeySet().add(new CorrelationKey(1, new String[] {"key1"}))
.add(new CorrelationKey(2, new String[] {"key2", "key3"})));
- assertEquals(2, new CorrelationKeySet("@2[1~key1],[2~key2~key3]?").findSubSets().size());
+ assertEquals(3, new CorrelationKeySet("@2[1~key1],[2~key2~key3]?").findSubSets().size());
}
@Test
@@ -89,6 +90,13 @@
inbound.add(new CorrelationKey("-1~session_key_different"));
assertFalse(inbound.isRoutableTo(candidate, false));
assertFalse(inbound.isRoutableTo(candidate, true));
+
+ inbound.clear();
+ inbound.add(keyX);
+ inbound.add(implicit);
+ candidate.clear();
+ candidate.add(keyX);
+ assertTrue(inbound.isRoutableTo(candidate, false));
}
@Test
@@ -106,7 +114,7 @@
keySet.add(keyX);
keySet.add(keyY);
keySet.add(keyZ);
- assertTrue(keySet.findSubSets().size() == 1 && keySet.findSubSets().get(0).equals(keySet));
+ assertTrue(keySet.findSubSets().size() == 7);
keySet = new CorrelationKeySet();
keySet.add(optX);
@@ -133,7 +141,7 @@
}
buf.append("'").append(subSet.toCanonicalString()).append("'");
}
- assertEquals("'@2[1~a~b],[2~b~c]','@2[1~a~b],[2~b~c],[3~c~d]'", buf.toString());
+ assertEquals("'@2[1~a~b]','@2[2~b~c]','@2[1~a~b],[2~b~c]','@2[3~c~d]','@2[1~a~b],[3~c~d]','@2[2~b~c],[3~c~d]','@2[1~a~b],[2~b~c],[3~c~d]'", buf.toString());
keySet = new CorrelationKeySet();
keySet.add(keyX);
@@ -146,6 +154,6 @@
}
buf.append("'").append(subSet.toCanonicalString()).append("'");
}
- assertEquals("'@2[1~a~b]','@2[1~a~b],[2~b~c]','@2[1~a~b],[3~c~d]','@2[1~a~b],[2~b~c],[3~c~d]'", buf.toString());
+ assertEquals("'@2[1~a~b]','@2[2~b~c]','@2[1~a~b],[2~b~c]','@2[3~c~d]','@2[1~a~b],[3~c~d]','@2[2~b~c],[3~c~d]','@2[1~a~b],[2~b~c],[3~c~d]'", buf.toString());
}
}
\ No newline at end of file