Issue discovered when adding TCK tests for
Application.{set,get}DefaultLocale().
SECTION: Modified Files
-----------------------------
M src/com/sun/faces/application/ApplicationImpl.java
- setDefaultLocale() must throw NPE if null value provided
M test/com/sun/faces/application/TestApplicationImpl.java
- test coverage
SECTION: Diffs
-----------------------------
Index: src/com/sun/faces/application/ApplicationImpl.java
===================================================================
RCS file:
/cvs/javaserverfaces-sources/jsf-ri/src/com/sun/faces/application/ApplicationImpl.java,v
retrieving revision 1.51
diff -u -r1.51 ApplicationImpl.java
--- src/com/sun/faces/application/ApplicationImpl.java 14 Jul 2004
21:30:53 -0000 1.51
+++ src/com/sun/faces/application/ApplicationImpl.java 15 Jul 2004
17:11:01 -0000
@@ -30,7 +30,6 @@
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.el.MethodBinding;
-import javax.faces.el.PropertyNotFoundException;
import javax.faces.el.PropertyResolver;
import javax.faces.el.ReferenceSyntaxException;
import javax.faces.el.ValueBinding;
@@ -43,10 +42,8 @@
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
-import java.util.List;
import java.util.Locale;
import java.util.Map;
-import java.util.TreeSet;
/**
@@ -578,13 +575,22 @@
}
- public void setDefaultLocale(Locale newLocale) {
+ public void setDefaultLocale(Locale locale) {
+
+ if (locale == null) {
+ String message = Util.getExceptionMessageString
+ (Util.NULL_PARAMETERS_ERROR_MESSAGE_ID);
+ message = message + " locale " + locale;
+ throw new NullPointerException(message);
+ }
+
synchronized (this) {
- defaultLocale = newLocale;
+ defaultLocale = locale;
}
if (log.isTraceEnabled()) {
log.trace("set defaultLocale " + defaultLocale);
}
+
}
Index: test/com/sun/faces/application/TestApplicationImpl.java
===================================================================
RCS file:
/cvs/javaserverfaces-sources/jsf-ri/test/com/sun/faces/application/TestApplicationImpl.java,v
retrieving revision 1.19
diff -u -r1.19 TestApplicationImpl.java
--- test/com/sun/faces/application/TestApplicationImpl.java 7 Apr
2004 17:52:44 -0000 1.19
+++ test/com/sun/faces/application/TestApplicationImpl.java 15 Jul
2004 17:11:02 -0000
@@ -23,6 +23,7 @@
import javax.faces.application.NavigationHandler;
import javax.faces.application.StateManager;
import javax.faces.application.ViewHandler;
+import javax.faces.application.Application;
import javax.faces.component.UIComponent;
import javax.faces.component.UIViewRoot;
import javax.faces.el.PropertyResolver;
@@ -443,6 +444,16 @@
exceptionThrown = true;
}
assertTrue(exceptionThrown);
+ }
+
+ // Ensure ApplicationImpl.setDefaultLocale(null) throws NPE
+ public void testSetDefaultLocaleNPE() throws Exception {
+ try {
+ application.setDefaultLocale(null);
+ assertTrue(false);
+ } catch (NullPointerException npe) {
+ ; // we're ok
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe_at_javaserverfaces.dev.java.net
For additional commands, e-mail: dev-help_at_javaserverfaces.dev.java.net