|
30 | 30 | import java.util.NoSuchElementException; |
31 | 31 | import java.util.Optional; |
32 | 32 | import java.util.Set; |
| 33 | +import java.util.concurrent.ExecutionException; |
33 | 34 | import java.util.concurrent.ExecutorService; |
34 | 35 | import java.util.concurrent.Executors; |
35 | 36 | import java.util.concurrent.Future; |
@@ -114,17 +115,22 @@ public boolean start() throws IOException { |
114 | 115 | try { |
115 | 116 | Duration timeout = resolveDefaultApiTimeout(spec); |
116 | 117 | future.get(timeout.getMillis(), TimeUnit.MILLISECONDS); |
117 | | - } catch (TimeoutException e) { |
118 | | - consumer.wakeup(); // This unblocks consumer stuck on network I/O. |
119 | | - // Likely reason : Kafka servers are configured to advertise internal ips, but |
120 | | - // those ips are not accessible from workers outside. |
121 | | - String msg = |
122 | | - String.format( |
123 | | - "%s: Timeout while initializing partition '%s'. " |
124 | | - + "Kafka client may not be able to connect to servers.", |
125 | | - this, pState.topicPartition); |
126 | | - LOG.error("{}", msg); |
127 | | - throw new IOException(msg); |
| 118 | + } catch (TimeoutException | ExecutionException e) { |
| 119 | + if (e instanceof TimeoutException |
| 120 | + || e.getCause() instanceof org.apache.kafka.common.errors.TimeoutException) { |
| 121 | + // TODO: Find out if manually waking up was only relevant for legacy Kafka clients. |
| 122 | + consumer.wakeup(); // This unblocks consumer stuck on network I/O. |
| 123 | + // Likely reason : Kafka servers are configured to advertise internal ips, but |
| 124 | + // those ips are not accessible from workers outside. |
| 125 | + String msg = |
| 126 | + String.format( |
| 127 | + "%s: Timeout while initializing partition '%s'. " |
| 128 | + + "Kafka client may not be able to connect to servers.", |
| 129 | + this, pState.topicPartition); |
| 130 | + LOG.error("{}", msg); |
| 131 | + throw new IOException(msg); |
| 132 | + } |
| 133 | + throw new IOException(e); |
128 | 134 | } catch (Exception e) { |
129 | 135 | throw new IOException(e); |
130 | 136 | } |
|
0 commit comments