DATAREDIS-75

+ fix NPE in properties impl.
This commit is contained in:
Costin Leau
2011-07-27 11:42:31 +03:00
parent 8ea1302641
commit 58c0822adf
2 changed files with 14 additions and 6 deletions

View File

@@ -23,9 +23,9 @@ import java.util.Date;
import java.util.Enumeration;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Properties;
import java.util.Set;
import java.util.Map.Entry;
import java.util.concurrent.TimeUnit;
import org.springframework.data.redis.connection.DataType;
@@ -104,11 +104,13 @@ public class RedisProperties extends Properties implements RedisMap<Object, Obje
public synchronized void putAll(Map<? extends Object, ? extends Object> t) {
delegate.putAll((Map<? extends String, ? extends String>) t);
}
@Override
public Enumeration<?> propertyNames() {
Set<String> keys = new LinkedHashSet<String>(delegate.keySet());
keys.addAll(defaults.stringPropertyNames());
if (defaults != null) {
keys.addAll(defaults.stringPropertyNames());
}
return Collections.enumeration(keys);
}

View File

@@ -176,11 +176,11 @@ public class RedisPropertiesTests extends RedisMapTests {
@Test
public void testPropertyNames() throws Exception {
String key1="foo";
String key2="x";
String key1 = "foo";
String key2 = "x";
String key3 = "d";
String val ="o";
String val = "o";
defaults.setProperty(key3, val);
props.setProperty(key1, val);
@@ -195,6 +195,12 @@ public class RedisPropertiesTests extends RedisMapTests {
assertFalse(names.hasMoreElements());
}
@Test
public void testDefaultInit() throws Exception {
RedisProperties redisProperties = new RedisProperties("foo", template);
redisProperties.propertyNames();
}
@Test
public void testStringPropertyNames() throws Exception {
String key1 = "foo";