Skip to content

Commit

Permalink
Catch not authorized exception in appropriate places
Browse files Browse the repository at this point in the history
  • Loading branch information
blootsvoets committed Sep 8, 2021
1 parent dc7f9b0 commit 99bfb07
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import javax.ws.rs.NotAuthorizedException;
import org.apache.kafka.connect.errors.ConnectException;
import org.apache.kafka.connect.source.SourceRecord;
import org.apache.kafka.connect.source.SourceTask;
Expand Down Expand Up @@ -86,7 +87,7 @@ public List<SourceRecord> poll() throws InterruptedException {
try {
requests = request.handleRequest()
.collect(Collectors.toList());
} catch (IOException ex) {
} catch (IOException | NotAuthorizedException ex) {
logger.warn("Failed to make request: {}", ex.toString());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.util.Map;
import java.util.function.Predicate;
import java.util.stream.Stream;
import javax.ws.rs.NotAuthorizedException;
import okhttp3.Headers;
import okhttp3.OkHttpClient;
import okhttp3.Request;
Expand Down Expand Up @@ -95,7 +96,7 @@ public Stream<SourceRecord> handleRequest() throws IOException {
headers = response.headers();
ResponseBody body = response.body();
data = body != null ? body.bytes() : null;
} catch (IOException ex) {
} catch (IOException | NotAuthorizedException ex) {
route.requestFailed(this, null);
throw ex;
}
Expand Down

0 comments on commit 99bfb07

Please sign in to comment.