|
37 | 37 | import org.springframework.messaging.converter.MessageConversionException; |
38 | 38 | import org.springframework.messaging.handler.invocation.MethodArgumentResolutionException; |
39 | 39 | import org.springframework.util.Assert; |
| 40 | +import org.springframework.util.ObjectUtils; |
40 | 41 | import org.springframework.util.backoff.BackOff; |
41 | 42 | import org.springframework.util.backoff.FixedBackOff; |
42 | 43 |
|
@@ -181,10 +182,17 @@ public void setClassifier(BinaryExceptionClassifier classifier) { |
181 | 182 | public void handle(Exception thrownException, List<ConsumerRecord<?, ?>> records, |
182 | 183 | Consumer<?, ?> consumer, MessageListenerContainer container) { |
183 | 184 |
|
184 | | - if (thrownException instanceof SerializationException) { |
185 | | - throw new IllegalStateException("This error handler cannot process 'SerializationException's directly, " |
186 | | - + "please consider configuring an 'ErrorHandlingDeserializer2' in the value and/or key " |
187 | | - + "deserializer", thrownException); |
| 185 | + if (ObjectUtils.isEmpty(records)) { |
| 186 | + if (thrownException instanceof SerializationException) { |
| 187 | + throw new IllegalStateException("This error handler cannot process 'SerializationException's directly; " |
| 188 | + + "please consider configuring an 'ErrorHandlingDeserializer2' in the value and/or key " |
| 189 | + + "deserializer", thrownException); |
| 190 | + } |
| 191 | + else { |
| 192 | + throw new IllegalStateException("This error handler cannot process '" |
| 193 | + + thrownException.getClass().getName() |
| 194 | + + "'s; no record information is available", thrownException); |
| 195 | + } |
188 | 196 | } |
189 | 197 |
|
190 | 198 | if (!SeekUtils.doSeeks(records, consumer, thrownException, true, getSkipPredicate(records, thrownException), |
|
0 commit comments