Skip to content

Commit b1fc5d7

Browse files
committed
fix for GRAILS-6532 "JSONObject.containsKey() is broken"
1 parent 09bd010 commit b1fc5d7

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

src/java/org/codehaus/groovy/grails/web/json/JSONObject.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,11 +1157,11 @@ public boolean isEmpty() {
11571157
}
11581158

11591159
public boolean containsKey(Object o) {
1160-
return false;
1160+
return myHashMap.containsKey(o);
11611161
}
11621162

11631163
public boolean containsValue(Object o) {
1164-
return this.myHashMap.containsKey(o);
1164+
return this.myHashMap.containsValue(o);
11651165
}
11661166

11671167
public Object get(Object o) {
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package org.codehaus.groovy.grails.web.json
2+
3+
/**
4+
* @author Graeme Rocher
5+
* @since 1.0
6+
*/
7+
class JSONObjectTests extends GroovyTestCase {
8+
9+
10+
void testContainsKey() {
11+
JSONObject j = new JSONObject();
12+
j.put('test', 1)
13+
assert j.containsKey('test')
14+
}
15+
16+
void testContainsValue() {
17+
JSONObject j = new JSONObject();
18+
j.put('test', 1)
19+
assert j.containsValue(1)
20+
21+
}
22+
}

0 commit comments

Comments
 (0)