Prevent SecretResponse from raising NPE in get()

This commit is contained in:
Stefan Kalscheuer 2017-04-07 20:57:47 +02:00
parent 7a67080aa0
commit 5d46e75068
2 changed files with 9 additions and 4 deletions

View File

@ -4,7 +4,7 @@
<groupId>de.stklcode.jvault</groupId>
<artifactId>connector</artifactId>
<version>0.5.0</version>
<version>0.5.1-SNAPSHOT</version>
<packaging>jar</packaging>

View File

@ -21,6 +21,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import de.stklcode.jvault.connector.exception.InvalidResponseException;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
/**
@ -45,6 +46,8 @@ public class SecretResponse extends VaultDataResponse {
* @since 0.4.0
*/
public Map<String, Object> getData() {
if (data == null)
return new HashMap<>();
return data;
}
@ -56,7 +59,9 @@ public class SecretResponse extends VaultDataResponse {
* @since 0.4.0
*/
public Object get(String key) {
return data.get(key);
if (data == null)
return null;
return getData().get(key);
}
/**
@ -68,9 +73,9 @@ public class SecretResponse extends VaultDataResponse {
*/
@Deprecated
public String getValue() {
if (data.get("value") == null)
if (get("value") == null)
return null;
return data.get("value").toString();
return get("value").toString();
}
/**