Avoid potential NPE in toString()
Issue: SPR-1528
This commit is contained in:
@@ -49,7 +49,7 @@ public class SimpleLocaleContext implements LocaleContext {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.locale.toString();
|
||||
return (this.locale != null ? this.locale.toString() : "-");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ import java.util.TimeZone;
|
||||
* a Locale but no TimeZone.
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
* @author Nicholas Williams
|
||||
* @since 4.0
|
||||
* @see LocaleContextHolder#setLocaleContext
|
||||
* @see LocaleContextHolder#getTimeZone()
|
||||
@@ -55,7 +56,7 @@ public class SimpleTimeZoneAwareLocaleContext extends SimpleLocaleContext implem
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return super.toString() + " " + this.timeZone.toString();
|
||||
return super.toString() + " " + (this.timeZone != null ? this.timeZone.toString() : "-");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user