Prevent SecretResponse from raising NPE in get()
This commit is contained in:
parent
7a67080aa0
commit
5d46e75068
2
pom.xml
2
pom.xml
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
<groupId>de.stklcode.jvault</groupId>
|
<groupId>de.stklcode.jvault</groupId>
|
||||||
<artifactId>connector</artifactId>
|
<artifactId>connector</artifactId>
|
||||||
<version>0.5.0</version>
|
<version>0.5.1-SNAPSHOT</version>
|
||||||
|
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
|||||||
import de.stklcode.jvault.connector.exception.InvalidResponseException;
|
import de.stklcode.jvault.connector.exception.InvalidResponseException;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -45,6 +46,8 @@ public class SecretResponse extends VaultDataResponse {
|
|||||||
* @since 0.4.0
|
* @since 0.4.0
|
||||||
*/
|
*/
|
||||||
public Map<String, Object> getData() {
|
public Map<String, Object> getData() {
|
||||||
|
if (data == null)
|
||||||
|
return new HashMap<>();
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,7 +59,9 @@ public class SecretResponse extends VaultDataResponse {
|
|||||||
* @since 0.4.0
|
* @since 0.4.0
|
||||||
*/
|
*/
|
||||||
public Object get(String key) {
|
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
|
@Deprecated
|
||||||
public String getValue() {
|
public String getValue() {
|
||||||
if (data.get("value") == null)
|
if (get("value") == null)
|
||||||
return null;
|
return null;
|
||||||
return data.get("value").toString();
|
return get("value").toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user