Skip to content

Commit 19a8efc

Browse files
committed
Revised assertions and $[invocationTime] support for exceptionMessage
Issue: SPR-15763
1 parent 5f767a8 commit 19a8efc

File tree

1 file changed

+18
-20
lines changed

1 file changed

+18
-20
lines changed

spring-aop/src/main/java/org/springframework/aop/interceptor/CustomizableTraceInterceptor.java

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -129,20 +129,20 @@ public class CustomizableTraceInterceptor extends AbstractTraceInterceptor {
129129
/**
130130
* The default message used for writing method entry messages.
131131
*/
132-
private static final String DEFAULT_ENTER_MESSAGE =
133-
"Entering method '" + PLACEHOLDER_METHOD_NAME + "' of class [" + PLACEHOLDER_TARGET_CLASS_NAME + "]";
132+
private static final String DEFAULT_ENTER_MESSAGE = "Entering method '" +
133+
PLACEHOLDER_METHOD_NAME + "' of class [" + PLACEHOLDER_TARGET_CLASS_NAME + "]";
134134

135135
/**
136136
* The default message used for writing method exit messages.
137137
*/
138-
private static final String DEFAULT_EXIT_MESSAGE =
139-
"Exiting method '" + PLACEHOLDER_METHOD_NAME + "' of class [" + PLACEHOLDER_TARGET_CLASS_NAME + "]";
138+
private static final String DEFAULT_EXIT_MESSAGE = "Exiting method '" +
139+
PLACEHOLDER_METHOD_NAME + "' of class [" + PLACEHOLDER_TARGET_CLASS_NAME + "]";
140140

141141
/**
142142
* The default message used for writing exception messages.
143143
*/
144-
private static final String DEFAULT_EXCEPTION_MESSAGE =
145-
"Exception thrown in method '" + PLACEHOLDER_METHOD_NAME + "' of class [" + PLACEHOLDER_TARGET_CLASS_NAME + "]";
144+
private static final String DEFAULT_EXCEPTION_MESSAGE = "Exception thrown in method '" +
145+
PLACEHOLDER_METHOD_NAME + "' of class [" + PLACEHOLDER_TARGET_CLASS_NAME + "]";
146146

147147
/**
148148
* The {@code Pattern} used to match placeholders.
@@ -183,14 +183,14 @@ public class CustomizableTraceInterceptor extends AbstractTraceInterceptor {
183183
* </ul>
184184
*/
185185
public void setEnterMessage(String enterMessage) throws IllegalArgumentException {
186-
Assert.hasText(enterMessage, "'enterMessage' must not be empty");
186+
Assert.hasText(enterMessage, "enterMessage must not be empty");
187187
checkForInvalidPlaceholders(enterMessage);
188188
Assert.doesNotContain(enterMessage, PLACEHOLDER_RETURN_VALUE,
189-
"enterMessage cannot contain placeholder [" + PLACEHOLDER_RETURN_VALUE + "]");
189+
"enterMessage cannot contain placeholder " + PLACEHOLDER_RETURN_VALUE);
190190
Assert.doesNotContain(enterMessage, PLACEHOLDER_EXCEPTION,
191-
"enterMessage cannot contain placeholder [" + PLACEHOLDER_EXCEPTION + "]");
191+
"enterMessage cannot contain placeholder " + PLACEHOLDER_EXCEPTION);
192192
Assert.doesNotContain(enterMessage, PLACEHOLDER_INVOCATION_TIME,
193-
"enterMessage cannot contain placeholder [" + PLACEHOLDER_INVOCATION_TIME + "]");
193+
"enterMessage cannot contain placeholder " + PLACEHOLDER_INVOCATION_TIME);
194194
this.enterMessage = enterMessage;
195195
}
196196

@@ -207,10 +207,10 @@ public void setEnterMessage(String enterMessage) throws IllegalArgumentException
207207
* </ul>
208208
*/
209209
public void setExitMessage(String exitMessage) {
210-
Assert.hasText(exitMessage, "'exitMessage' must not be empty");
210+
Assert.hasText(exitMessage, "exitMessage must not be empty");
211211
checkForInvalidPlaceholders(exitMessage);
212212
Assert.doesNotContain(exitMessage, PLACEHOLDER_EXCEPTION,
213-
"exitMessage cannot contain placeholder [" + PLACEHOLDER_EXCEPTION + "]");
213+
"exitMessage cannot contain placeholder" + PLACEHOLDER_EXCEPTION);
214214
this.exitMessage = exitMessage;
215215
}
216216

@@ -226,12 +226,10 @@ public void setExitMessage(String exitMessage) {
226226
* </ul>
227227
*/
228228
public void setExceptionMessage(String exceptionMessage) {
229-
Assert.hasText(exceptionMessage, "'exceptionMessage' must not be empty");
229+
Assert.hasText(exceptionMessage, "exceptionMessage must not be empty");
230230
checkForInvalidPlaceholders(exceptionMessage);
231231
Assert.doesNotContain(exceptionMessage, PLACEHOLDER_RETURN_VALUE,
232-
"exceptionMessage cannot contain placeholder [" + PLACEHOLDER_RETURN_VALUE + "]");
233-
Assert.doesNotContain(exceptionMessage, PLACEHOLDER_INVOCATION_TIME,
234-
"exceptionMessage cannot contain placeholder [" + PLACEHOLDER_INVOCATION_TIME + "]");
232+
"exceptionMessage cannot contain placeholder " + PLACEHOLDER_RETURN_VALUE);
235233
this.exceptionMessage = exceptionMessage;
236234
}
237235

@@ -263,17 +261,17 @@ protected Object invokeUnderTrace(MethodInvocation invocation, Log logger) throw
263261
stopWatch.stop();
264262
}
265263
exitThroughException = true;
266-
writeToLog(logger,
267-
replacePlaceholders(this.exceptionMessage, invocation, null, ex, stopWatch.getTotalTimeMillis()), ex);
264+
writeToLog(logger, replacePlaceholders(
265+
this.exceptionMessage, invocation, null, ex, stopWatch.getTotalTimeMillis()), ex);
268266
throw ex;
269267
}
270268
finally {
271269
if (!exitThroughException) {
272270
if (stopWatch.isRunning()) {
273271
stopWatch.stop();
274272
}
275-
writeToLog(logger,
276-
replacePlaceholders(this.exitMessage, invocation, returnValue, null, stopWatch.getTotalTimeMillis()));
273+
writeToLog(logger, replacePlaceholders(
274+
this.exitMessage, invocation, returnValue, null, stopWatch.getTotalTimeMillis()));
277275
}
278276
}
279277
}

0 commit comments

Comments
 (0)