@@ -17,7 +17,6 @@ This product includes software developed at Datadog (https://www.datadoghq.com/)
1717import org .slf4j .Logger ;
1818import org .slf4j .LoggerFactory ;
1919
20- import javax .ws .rs .core .Response ;
2120import java .io .ByteArrayOutputStream ;
2221import java .io .DataOutputStream ;
2322import java .io .IOException ;
@@ -191,7 +190,7 @@ private void sendRequest(JsonArray content, URL url) throws IOException {
191190
192191 // get response
193192 int status = con .getResponseCode ();
194- if (Response . Status . Family . familyOf (status ) != Response . Status . Family . SUCCESSFUL ) {
193+ if (! isSuccessfulHttpStatus (status )) {
195194 InputStream stream = con .getErrorStream ();
196195 String error = "" ;
197196 if (stream != null ) {
@@ -206,6 +205,16 @@ private void sendRequest(JsonArray content, URL url) throws IOException {
206205 log .trace ("Received HTTP response {} {} with body {}" , status , con .getResponseMessage (), getOutput (con .getInputStream ()));
207206 }
208207
208+ /**
209+ * Check if the HTTP status code indicates success (2xx range)
210+ *
211+ * @param statusCode HTTP status code to check
212+ * @return true if status code is in the 2xx range (200-299)
213+ */
214+ private boolean isSuccessfulHttpStatus (int statusCode ) {
215+ return statusCode >= 200 && statusCode < 300 ;
216+ }
217+
209218 private void setRequestProperties (HttpURLConnection con ) {
210219 con .setRequestProperty ("Content-Type" , "application/json" );
211220 con .setRequestProperty ("Content-Encoding" , "gzip" );
0 commit comments