SUPPORT-9536: Fix npe

This commit is contained in:
Eduard Tihomiorv 2025-11-07 09:46:17 +03:00
parent b251439461
commit de2db2a9db

View file

@ -7,6 +7,7 @@ import java.net.http.HttpResponse;
import java.time.Duration;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
@ -78,10 +79,13 @@ public class MchdService {
private boolean isEsiaMchdNotFoundError(HttpResponse<String> response)
throws JsonProcessingException {
if (response.statusCode() == 400) {
String errorCode = objectMapper.readTree(response.body())
.get("code")
.asText();
return errorCode.equals("ESIA-044009");
JsonNode jsonNode = objectMapper.readTree(response.body())
.get("code");
if (jsonNode == null) {
return false;
}
String errorCode = jsonNode.asText();
return errorCode != null && errorCode.equals("ESIA-044009");
}
return false;
}