Author: nextgens
Date: 2007-07-04 23:04:37 +0000 (Wed, 04 Jul 2007)
New Revision: 13935
Modified:
trunk/freenet/src/freenet/support/SimpleFieldSet.java
trunk/freenet/test/freenet/support/SimpleFieldSetTest.java
Log:
Resolve 1493: SimpleFieldSet get() method fails when a key with a couple of
paired .. is put
Modified: trunk/freenet/src/freenet/support/SimpleFieldSet.java
===================================================================
--- trunk/freenet/src/freenet/support/SimpleFieldSet.java 2007-07-04
22:59:32 UTC (rev 13934)
+++ trunk/freenet/src/freenet/support/SimpleFieldSet.java 2007-07-04
23:04:37 UTC (rev 13935)
@@ -169,8 +169,8 @@
if(idx == -1)
return (String) values.get(key);
else if(idx == 0)
- return null;
- else {
+ return (subset("") == null) ? null :
subset("").get(key.substring(1));
+ else {
if(subsets == null) return null;
String before = key.substring(0, idx);
String after = key.substring(idx+1);
Modified: trunk/freenet/test/freenet/support/SimpleFieldSetTest.java
===================================================================
--- trunk/freenet/test/freenet/support/SimpleFieldSetTest.java 2007-07-04
22:59:32 UTC (rev 13934)
+++ trunk/freenet/test/freenet/support/SimpleFieldSetTest.java 2007-07-04
23:04:37 UTC (rev 13935)
@@ -56,18 +56,8 @@
String methodKey = "foo..bar";
String methodValue = "foobar";
methodSFS.putSingle(methodKey,methodValue);
- methodSFS.subset("foo").subset("").get("bar"); /*it returns
"foobar" */
-
- /*methodSFS.subset("foo").subset(null).get("bar"); /* it
raises null exception
-
* because subset(null) returns
-
* null by default */
-
- methodSFS.get("foo..bar");
/* it doesn't work
-
* but if I put("foo.bar.boo","bazoo")
-
* and I get("foo.bar.boo") -> it
returns "bazoo"
-
* so it should do the same for
"foo..bar"
-
* or it would raise an exception */
- //assertEquals(methodSFS.get(methodKey),methodValue);
+
assertEquals(methodSFS.subset("foo").subset("").get("bar"),methodValue);
+ assertEquals(methodSFS.get(methodKey),methodValue);
}
/**
@@ -80,7 +70,7 @@
String methodKey = "foo..bar";
String methodValue = "foobar";
methodSFS.putAppend(methodKey,methodValue);
- //assertEquals(methodSFS.get(methodKey),methodValue);
+ assertEquals(methodSFS.get(methodKey),methodValue);
}
/**
@@ -672,4 +662,4 @@
Iterator itr = methodSFS.keyIterator(methodPrefix);
assertTrue(areAllContainedKeys(SAMPLE_STRING_PAIRS,methodPrefix,itr));
}
-}
\ No newline at end of file
+}