|
1 | 1 | /*
|
2 |
| - * Copyright 2012-2023 the original author or authors. |
| 2 | + * Copyright 2012-2025 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.
|
|
34 | 34 | */
|
35 | 35 | class MessageSourceMessageInterpolator implements MessageInterpolator {
|
36 | 36 |
|
| 37 | + private static final String DEFAULT_MESSAGE = MessageSourceMessageInterpolator.class.getName(); |
| 38 | + |
37 | 39 | private static final char PREFIX = '{';
|
38 | 40 |
|
39 | 41 | private static final char SUFFIX = '}';
|
@@ -115,13 +117,11 @@ else if (buf.charAt(i) == SUFFIX) {
|
115 | 117 |
|
116 | 118 | private String replaceParameter(String parameter, Locale locale, Set<String> visitedParameters) {
|
117 | 119 | parameter = replaceParameters(parameter, locale, visitedParameters);
|
118 |
| - String value = this.messageSource.getMessage(parameter, null, null, locale); |
119 |
| - return (value != null && !isUsingCodeAsDefaultMessage(value, parameter)) |
120 |
| - ? replaceParameters(value, locale, visitedParameters) : null; |
121 |
| - } |
122 |
| - |
123 |
| - private boolean isUsingCodeAsDefaultMessage(String value, String parameter) { |
124 |
| - return value.equals(parameter); |
| 120 | + String value = this.messageSource.getMessage(parameter, null, DEFAULT_MESSAGE, locale); |
| 121 | + if (value == null || value.equals(DEFAULT_MESSAGE)) { |
| 122 | + return null; |
| 123 | + } |
| 124 | + return replaceParameters(value, locale, visitedParameters); |
125 | 125 | }
|
126 | 126 |
|
127 | 127 | }
|
0 commit comments