|
1 | 1 | /*
|
2 |
| - * Copyright 2014-2016 the original author or authors. |
| 2 | + * Copyright 2014-2018 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
@@ -71,19 +71,33 @@ public ConditionalRejectingErrorHandler(FatalExceptionStrategy exceptionStrategy
|
71 | 71 |
|
72 | 72 | @Override
|
73 | 73 | public void handleError(Throwable t) {
|
74 |
| - if (this.logger.isWarnEnabled()) { |
75 |
| - this.logger.warn("Execution of Rabbit message listener failed.", t); |
76 |
| - } |
| 74 | + log(t); |
77 | 75 | if (!this.causeChainContainsARADRE(t) && this.exceptionStrategy.isFatal(t)) {
|
78 | 76 | throw new AmqpRejectAndDontRequeueException("Error Handler converted exception to fatal", t);
|
79 | 77 | }
|
80 | 78 | }
|
81 | 79 |
|
82 | 80 | /**
|
| 81 | + * Log the throwable at WARN level, including stack trace. |
| 82 | + * Subclasses can override this behavior. |
| 83 | + * @param t the {@link Throwable}. |
| 84 | + * @since 1.7.8 |
| 85 | + */ |
| 86 | + protected void log(Throwable t) { |
| 87 | + if (this.logger.isWarnEnabled()) { |
| 88 | + this.logger.warn("Execution of Rabbit message listener failed.", t); |
| 89 | + } |
| 90 | + } |
| 91 | + |
| 92 | + /** |
| 93 | + * Return true if there is already an {@link AmqpRejectAndDontRequeueException} |
| 94 | + * present in the cause chain. |
| 95 | + * @param t a {@link Throwable}. |
83 | 96 | * @return true if the cause chain already contains an
|
84 | 97 | * {@link AmqpRejectAndDontRequeueException}.
|
| 98 | + * @since 1.7.8 |
85 | 99 | */
|
86 |
| - private boolean causeChainContainsARADRE(Throwable t) { |
| 100 | + protected boolean causeChainContainsARADRE(Throwable t) { |
87 | 101 | Throwable cause = t.getCause();
|
88 | 102 | while (cause != null) {
|
89 | 103 | if (cause instanceof AmqpRejectAndDontRequeueException) {
|
|
0 commit comments