@@ -179,7 +179,11 @@ private SDKInfo initForSdkUrl(Map<String, String> initParams, String sdkServiceU
179179 throw new BioSdkClientException (ResponseStatus .UNKNOWN_ERROR + "" ,
180180 TAG_HTTP_STATUS + responseEntity .getStatusCode ().toString ());
181181 }
182- String responseBody = responseEntity .getBody ().toString ();
182+ Object body = responseEntity .getBody ();
183+ if (body == null ) {
184+ throw new NullPointerException ("Response body is null" );
185+ }
186+ String responseBody = body .toString ();
183187 JSONParser parser = new JSONParser ();
184188 JSONObject js = (JSONObject ) parser .parse (responseBody );
185189
@@ -188,10 +192,7 @@ private SDKInfo initForSdkUrl(Map<String, String> initParams, String sdkServiceU
188192
189193 sdkInfo = Util .getObjectMapper ().readValue (js .get ("response" ).toString (), new TypeReference <SDKInfo >() {
190194 });
191- } catch (ParseException e ) {
192- logger .error (LOGGER_SESSIONID , LOGGER_IDTYPE , "error" , e );
193- throw new BioSdkClientException (ResponseStatus .UNKNOWN_ERROR + "" , e .getLocalizedMessage (), e );
194- } catch (JsonProcessingException e ) {
195+ } catch (Exception e ) {
195196 logger .error (LOGGER_SESSIONID , LOGGER_IDTYPE , "error" , e );
196197 throw new BioSdkClientException (ResponseStatus .UNKNOWN_ERROR + "" , e .getLocalizedMessage (), e );
197198 }
@@ -313,7 +314,11 @@ public Response<QualityCheck> checkQuality(BiometricRecord sample, List<Biometri
313314 throw new BioSdkClientException (ResponseStatus .UNKNOWN_ERROR .getStatusCode () + "" ,
314315 TAG_HTTP_STATUS + responseEntity .getStatusCode ().toString ());
315316 }
316- String responseBody = responseEntity .getBody ().toString ();
317+ Object body = responseEntity .getBody ();
318+ if (body == null ) {
319+ throw new NullPointerException ("Response body is null" );
320+ }
321+ String responseBody = body .toString ();
317322 JSONParser parser = new JSONParser ();
318323 JSONObject js = (JSONObject ) parser .parse (responseBody );
319324 JSONObject responseJson = (JSONObject ) ((JSONObject ) js .get ("response" )).get ("response" );
@@ -361,7 +366,11 @@ public Response<MatchDecision[]> match(BiometricRecord sample, BiometricRecord[]
361366 throw new BioSdkClientException (ResponseStatus .UNKNOWN_ERROR + "" ,
362367 TAG_HTTP_STATUS + responseEntity .getStatusCode ().toString ());
363368 }
364- String responseBody = responseEntity .getBody ().toString ();
369+ Object body = responseEntity .getBody ();
370+ if (body == null ) {
371+ throw new NullPointerException ("Response body is null" );
372+ }
373+ String responseBody = body .toString ();
365374 JSONParser parser = new JSONParser ();
366375 JSONObject js = (JSONObject ) parser .parse (responseBody );
367376
@@ -494,7 +503,11 @@ public Response<BiometricRecord> segment(BiometricRecord biometricRecord, List<B
494503 * @throws BioSdkClientException If the JSON mapping fails during response conversion.
495504 */
496505 private void convertAndSetResponseObject (Response <BiometricRecord > response , ResponseEntity <?> responseEntity ) throws ParseException , JsonProcessingException {
497- String responseBody = responseEntity .getBody ().toString ();
506+ Object body = responseEntity .getBody ();
507+ if (body == null ) {
508+ throw new NullPointerException ("Response body is null" );
509+ }
510+ String responseBody = body .toString ();
498511 JSONParser parser = new JSONParser ();
499512 JSONObject js = (JSONObject ) parser .parse (responseBody );
500513
@@ -549,7 +562,11 @@ public BiometricRecord convertFormat(BiometricRecord sample, String sourceFormat
549562 throw new BioSdkClientException (ResponseStatus .UNKNOWN_ERROR .getStatusCode () + "" ,
550563 TAG_HTTP_STATUS + responseEntity .getStatusCode ().toString ());
551564 }
552- String responseBody = responseEntity .getBody ().toString ();
565+ Object body = responseEntity .getBody ();
566+ if (body == null ) {
567+ throw new NullPointerException ("Response body is null" );
568+ }
569+ String responseBody = body .toString ();
553570 JSONParser parser = new JSONParser ();
554571 JSONObject js = (JSONObject ) parser .parse (responseBody );
555572
@@ -601,7 +618,11 @@ public Response<BiometricRecord> convertFormatV2(BiometricRecord sample, String
601618 throw new BioSdkClientException (ResponseStatus .UNKNOWN_ERROR .getStatusCode () + "" ,
602619 TAG_HTTP_STATUS + responseEntity .getStatusCode ().toString ());
603620 }
604- String responseBody = responseEntity .getBody ().toString ();
621+ Object body = responseEntity .getBody ();
622+ if (body == null ) {
623+ throw new NullPointerException ("Response body is null" );
624+ }
625+ String responseBody = body .toString ();
605626 convertAndSetResponseObject (response , responseBody , new TypeReference <BiometricRecord >() {
606627 });
607628 } catch (Exception e ) {
0 commit comments