MessageSource.getMessage returns null default message as-is (again)
Issue: SPR-16127
This commit is contained in:
@@ -653,6 +653,9 @@ public class RequestContext {
|
||||
*/
|
||||
public String getMessage(String code, @Nullable Object[] args, String defaultMessage, boolean htmlEscape) {
|
||||
String msg = this.webApplicationContext.getMessage(code, args, defaultMessage, getLocale());
|
||||
if (msg == null) {
|
||||
return "";
|
||||
}
|
||||
return (htmlEscape ? HtmlUtils.htmlEscape(msg) : msg);
|
||||
}
|
||||
|
||||
@@ -732,7 +735,8 @@ public class RequestContext {
|
||||
* @return the message
|
||||
*/
|
||||
public String getThemeMessage(String code, String defaultMessage) {
|
||||
return getTheme().getMessageSource().getMessage(code, null, defaultMessage, getLocale());
|
||||
String msg = getTheme().getMessageSource().getMessage(code, null, defaultMessage, getLocale());
|
||||
return (msg != null ? msg : "");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -745,7 +749,8 @@ public class RequestContext {
|
||||
* @return the message
|
||||
*/
|
||||
public String getThemeMessage(String code, @Nullable Object[] args, String defaultMessage) {
|
||||
return getTheme().getMessageSource().getMessage(code, args, defaultMessage, getLocale());
|
||||
String msg = getTheme().getMessageSource().getMessage(code, args, defaultMessage, getLocale());
|
||||
return (msg != null ? msg : "");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -758,8 +763,9 @@ public class RequestContext {
|
||||
* @return the message
|
||||
*/
|
||||
public String getThemeMessage(String code, @Nullable List<?> args, String defaultMessage) {
|
||||
return getTheme().getMessageSource().getMessage(code, (args != null ? args.toArray() : null),
|
||||
String msg = getTheme().getMessageSource().getMessage(code, (args != null ? args.toArray() : null),
|
||||
defaultMessage, getLocale());
|
||||
return (msg != null ? msg : "");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -300,6 +300,7 @@ public class MessageTag extends HtmlEscapingAwareTag implements ArgumentAware {
|
||||
this.arguments = null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Resolve the specified message into a concrete message String.
|
||||
* The returned message String should be unescaped.
|
||||
@@ -322,8 +323,9 @@ public class MessageTag extends HtmlEscapingAwareTag implements ArgumentAware {
|
||||
|
||||
if (this.text != null) {
|
||||
// We have a fallback text to consider.
|
||||
return messageSource.getMessage(
|
||||
String msg = messageSource.getMessage(
|
||||
this.code, argumentsArray, this.text, getRequestContext().getLocale());
|
||||
return (msg != null ? msg : "");
|
||||
}
|
||||
else {
|
||||
// We have no fallback text to consider.
|
||||
|
||||
Reference in New Issue
Block a user