Skip to content

Commit 99bfb07

Browse files
committed
Catch not authorized exception in appropriate places
1 parent dc7f9b0 commit 99bfb07

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

kafka-connect-rest-source/src/main/java/org/radarbase/connect/rest/RestSourceTask.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import java.util.List;
2727
import java.util.Map;
2828
import java.util.stream.Collectors;
29+
import javax.ws.rs.NotAuthorizedException;
2930
import org.apache.kafka.connect.errors.ConnectException;
3031
import org.apache.kafka.connect.source.SourceRecord;
3132
import org.apache.kafka.connect.source.SourceTask;
@@ -86,7 +87,7 @@ public List<SourceRecord> poll() throws InterruptedException {
8687
try {
8788
requests = request.handleRequest()
8889
.collect(Collectors.toList());
89-
} catch (IOException ex) {
90+
} catch (IOException | NotAuthorizedException ex) {
9091
logger.warn("Failed to make request: {}", ex.toString());
9192
}
9293
}

kafka-connect-rest-source/src/main/java/org/radarbase/connect/rest/request/RestRequest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import java.util.Map;
2323
import java.util.function.Predicate;
2424
import java.util.stream.Stream;
25+
import javax.ws.rs.NotAuthorizedException;
2526
import okhttp3.Headers;
2627
import okhttp3.OkHttpClient;
2728
import okhttp3.Request;
@@ -95,7 +96,7 @@ public Stream<SourceRecord> handleRequest() throws IOException {
9596
headers = response.headers();
9697
ResponseBody body = response.body();
9798
data = body != null ? body.bytes() : null;
98-
} catch (IOException ex) {
99+
} catch (IOException | NotAuthorizedException ex) {
99100
route.requestFailed(this, null);
100101
throw ex;
101102
}

0 commit comments

Comments
 (0)