Skip to content

Commit a065c62

Browse files
authored
Remove javax dependency to maintain kafka version interoperability (#53)
1 parent f003338 commit a065c62

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<url>https://www.datadoghq.com/</url>
1212
</organization>
1313
<name>datadog-kafka-connect-logs</name>
14-
<version>1.4.0-SNAPSHOT</version>
14+
<version>1.4.0</version>
1515
<description>A Kafka Connect Connector that sends Kafka Connect records as logs to the Datadog API.</description>
1616
<url>https://github.com/DataDog/datadog-kafka-connect-logs</url>
1717

src/main/java/com/datadoghq/connect/logs/sink/DatadogLogsApiWriter.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ This product includes software developed at Datadog (https://www.datadoghq.com/)
1717
import org.slf4j.Logger;
1818
import org.slf4j.LoggerFactory;
1919

20-
import javax.ws.rs.core.Response;
2120
import java.io.ByteArrayOutputStream;
2221
import java.io.DataOutputStream;
2322
import 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

Comments
 (0)