Avoid potential NPE in toString()

Issue: SPR-1528
This commit is contained in:
Juergen Hoeller
2013-11-01 22:42:17 +01:00
parent 7b2ac6d194
commit 7ed108e974
2 changed files with 3 additions and 2 deletions

View File

@@ -49,7 +49,7 @@ public class SimpleLocaleContext implements LocaleContext {
@Override
public String toString() {
return this.locale.toString();
return (this.locale != null ? this.locale.toString() : "-");
}
}

View File

@@ -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() : "-");
}
}