diff --git a/src/main/java/com/algorand/algosdk/v2/client/common/Query.java b/src/main/java/com/algorand/algosdk/v2/client/common/Query.java index e66a10d90..94333c98c 100644 --- a/src/main/java/com/algorand/algosdk/v2/client/common/Query.java +++ b/src/main/java/com/algorand/algosdk/v2/client/common/Query.java @@ -23,8 +23,15 @@ protected Response baseExecute() throws Exception { protected Response baseExecute(String[] headers, String[] values) throws Exception { - QueryData qData = this.getRequestString(); - com.squareup.okhttp.Response resp = this.client.executeCall(qData, httpMethod, headers, values); + // Make sure the path is generated by calling getRequestString (at most) once. + if (qd.pathSegments.size() == 0) { + this.getRequestString(); + } + if(qd.pathSegments.size() == 0 ) { + throw new RuntimeException("Something unexpected went wrong. QueryData path segment is not populated."); + } + + com.squareup.okhttp.Response resp = this.client.executeCall(qd, httpMethod, headers, values); if (resp.isSuccessful()) { return new Response(resp.code(), null, resp.body().contentType().toString(), resp.body().bytes()); } else {