SpringBoot: fix potential null pointer
This commit is contained in:
parent
89fcf4e10f
commit
c8d733dfac
@ -13,6 +13,8 @@ import org.springframework.web.client.RestTemplate;
|
||||
import djmil.cordacheckers.cordaclient.dao.VirtualNode;
|
||||
import djmil.cordacheckers.cordaclient.dao.VirtualNodeList;
|
||||
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
@Service
|
||||
public class CordaClient {
|
||||
private final RestTemplate restTemplate;
|
||||
@ -39,12 +41,12 @@ public class CordaClient {
|
||||
request,
|
||||
VirtualNodeList.class );
|
||||
|
||||
// TODO: throw exeption instead
|
||||
if (resp.getStatusCode() != HttpStatus.OK || !resp.hasBody()) {
|
||||
return null;
|
||||
if (resp.getStatusCode() != HttpStatus.OK) {
|
||||
throw new RuntimeException("CordaClient.getVirtualNodeList: unexpected request status "+resp.getStatusCode()) ;
|
||||
}
|
||||
|
||||
return resp.getBody().virtualNodes();
|
||||
return requireNonNull(resp.getBody(), "CordaClient.getVirtualNodeList: empty getBody()")
|
||||
.virtualNodes();
|
||||
}
|
||||
|
||||
// public String getGemeProposals(String ) {
|
||||
|
Loading…
Reference in New Issue
Block a user