49
49
*/
50
50
public class RepublishMessageRecoverer implements MessageRecoverer {
51
51
52
- private static final int ELIPSIS_LENGTH = 3 ;
52
+ private static final int ELLIPSIS_LENGTH = 3 ;
53
53
54
54
public static final String X_EXCEPTION_STACKTRACE = "x-exception-stacktrace" ;
55
55
@@ -61,7 +61,7 @@ public class RepublishMessageRecoverer implements MessageRecoverer {
61
61
62
62
public static final int DEFAULT_FRAME_MAX_HEADROOM = 20_000 ;
63
63
64
- private static final int MAX_EXCEPTION_MESSAGE_SIZE_IN_TRACE = 100 - ELIPSIS_LENGTH ;
64
+ private static final int MAX_EXCEPTION_MESSAGE_SIZE_IN_TRACE = 100 - ELLIPSIS_LENGTH ;
65
65
66
66
protected final Log logger = LogFactory .getLog (getClass ()); // NOSONAR
67
67
@@ -165,7 +165,7 @@ public void recover(Message message, Throwable cause) {
165
165
headers .put (X_EXCEPTION_MESSAGE , exceptionMessage );
166
166
headers .put (X_ORIGINAL_EXCHANGE , messageProperties .getReceivedExchange ());
167
167
headers .put (X_ORIGINAL_ROUTING_KEY , messageProperties .getReceivedRoutingKey ());
168
- Map <? extends String , ? extends Object > additionalHeaders = additionalHeaders (message , cause );
168
+ Map <? extends String , ?> additionalHeaders = additionalHeaders (message , cause );
169
169
if (additionalHeaders != null ) {
170
170
headers .putAll (additionalHeaders );
171
171
}
@@ -207,31 +207,31 @@ private String[] processStackTrace(Throwable cause, String exceptionMessage) {
207
207
String truncatedExceptionMessage = exceptionMessage .length () <= MAX_EXCEPTION_MESSAGE_SIZE_IN_TRACE
208
208
? exceptionMessage
209
209
: (exceptionMessage .substring (0 , MAX_EXCEPTION_MESSAGE_SIZE_IN_TRACE ) + "..." );
210
- if (this .maxStackTraceLength > 0 ) {
211
- if (stackTraceAsString .length () + exceptionMessage .length () > this .maxStackTraceLength ) {
212
- if (!exceptionMessage .equals (truncatedExceptionMessage )) {
213
- int start = stackTraceAsString .indexOf (exceptionMessage );
214
- stackTraceAsString = stackTraceAsString .substring (0 , start )
215
- + truncatedExceptionMessage
216
- + stackTraceAsString .substring (start + exceptionMessage .length ());
210
+ if (this .maxStackTraceLength > 0 &&
211
+ stackTraceAsString .length () + exceptionMessage .length () > this .maxStackTraceLength ) {
212
+
213
+ if (!exceptionMessage .equals (truncatedExceptionMessage )) {
214
+ int start = stackTraceAsString .indexOf (exceptionMessage );
215
+ stackTraceAsString = stackTraceAsString .substring (0 , start )
216
+ + truncatedExceptionMessage
217
+ + stackTraceAsString .substring (start + exceptionMessage .length ());
218
+ }
219
+ int adjustedStackTraceLen = this .maxStackTraceLength - truncatedExceptionMessage .length ();
220
+ if (adjustedStackTraceLen > 0 ) {
221
+ if (stackTraceAsString .length () > adjustedStackTraceLen ) {
222
+ stackTraceAsString = stackTraceAsString .substring (0 , adjustedStackTraceLen );
223
+ this .logger .warn ("Stack trace in republished message header truncated due to frame_max "
224
+ + "limitations; "
225
+ + "consider increasing frame_max on the broker or reduce the stack trace depth" , cause );
226
+ truncated = true ;
217
227
}
218
- int adjustedStackTraceLen = this .maxStackTraceLength - truncatedExceptionMessage .length ();
219
- if (adjustedStackTraceLen > 0 ) {
220
- if (stackTraceAsString .length () > adjustedStackTraceLen ) {
221
- stackTraceAsString = stackTraceAsString .substring (0 , adjustedStackTraceLen );
222
- this .logger .warn ("Stack trace in republished message header truncated due to frame_max "
223
- + "limitations; "
224
- + "consider increasing frame_max on the broker or reduce the stack trace depth" , cause );
225
- truncated = true ;
226
- }
227
- else if (stackTraceAsString .length () + exceptionMessage .length () > this .maxStackTraceLength ) {
228
- this .logger .warn ("Exception message in republished message header truncated due to frame_max "
229
- + "limitations; consider increasing frame_max on the broker or reduce the exception "
230
- + "message size" , cause );
231
- truncatedExceptionMessage = exceptionMessage .substring (0 ,
232
- this .maxStackTraceLength - stackTraceAsString .length () - ELIPSIS_LENGTH ) + "..." ;
233
- truncated = true ;
234
- }
228
+ else if (stackTraceAsString .length () + exceptionMessage .length () > this .maxStackTraceLength ) {
229
+ this .logger .warn ("Exception message in republished message header truncated due to frame_max "
230
+ + "limitations; consider increasing frame_max on the broker or reduce the exception "
231
+ + "message size" , cause );
232
+ truncatedExceptionMessage = exceptionMessage .substring (0 ,
233
+ this .maxStackTraceLength - stackTraceAsString .length () - ELLIPSIS_LENGTH ) + "..." ;
234
+ truncated = true ;
235
235
}
236
236
}
237
237
}
@@ -244,7 +244,7 @@ else if (stackTraceAsString.length() + exceptionMessage.length() > this.maxStack
244
244
* @param cause The cause.
245
245
* @return A {@link Map} of additional headers to add.
246
246
*/
247
- protected Map <? extends String , ? extends Object > additionalHeaders (Message message , Throwable cause ) {
247
+ protected Map <? extends String , ?> additionalHeaders (Message message , Throwable cause ) {
248
248
return null ;
249
249
}
250
250
0 commit comments