You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-dev@jakarta.apache.org by lu...@apache.org on 2002/04/17 22:48:04 UTC
cvs commit: jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/common/fmt BundleSupport.java SetBundleSupport.java SetLocaleSupport.java
luehe 02/04/17 13:48:04
Modified: standard/src/org/apache/taglibs/standard/tag/common/fmt
BundleSupport.java SetBundleSupport.java
SetLocaleSupport.java
Log:
Fixed 8224: NPE occurs if basename attribute of setBundle is null or empty
Revision Changes Path
1.24 +10 -13 jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/common/fmt/BundleSupport.java
Index: BundleSupport.java
===================================================================
RCS file: /home/cvs/jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/common/fmt/BundleSupport.java,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- BundleSupport.java 17 Apr 2002 18:35:34 -0000 1.23
+++ BundleSupport.java 17 Apr 2002 20:48:03 -0000 1.24
@@ -170,7 +170,7 @@
locCtxt = (LocalizationContext) obj;
} else {
// localization context is a bundle basename
- locCtxt = BundleSupport.getLocalizationContext(pc, (String) obj);
+ locCtxt = getLocalizationContext(pc, (String) obj);
}
return locCtxt;
@@ -199,8 +199,8 @@
*
* @return Localization context containing the resource bundle with the
* given base name for which a match between the preferred (or fallback)
- * and available locales exists, or empty localization context containing
- * the null bundle if no resource bundle match was found
+ * and available locales exists, or null if no resource bundle match was
+ * found
*/
public static LocalizationContext getLocalizationContext(PageContext pc,
String basename) {
@@ -242,16 +242,13 @@
// do nothing
}
}
-
- if (locCtxt == null) {
- // create empty localization context
- locCtxt = new LocalizationContext();
- }
-
- bundle = locCtxt.getResourceBundle();
- if (bundle != null) {
- // set response locale
- SetLocaleSupport.setResponseLocale(pc, bundle.getLocale());
+
+ if (locCtxt != null) {
+ bundle = locCtxt.getResourceBundle();
+ if (bundle != null) {
+ // set response locale
+ SetLocaleSupport.setResponseLocale(pc, bundle.getLocale());
+ }
}
return locCtxt;
1.5 +5 -0 jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/common/fmt/SetBundleSupport.java
Index: SetBundleSupport.java
===================================================================
RCS file: /home/cvs/jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/common/fmt/SetBundleSupport.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- SetBundleSupport.java 16 Apr 2002 15:49:50 -0000 1.4
+++ SetBundleSupport.java 17 Apr 2002 20:48:03 -0000 1.5
@@ -124,6 +124,11 @@
basename);
}
+ if (locCtxt == null) {
+ // create empty localization context
+ locCtxt = new LocalizationContext();
+ }
+
if (var != null) {
pageContext.setAttribute(var, locCtxt, Util.getScope(scope));
} else {
1.6 +8 -6 jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/common/fmt/SetLocaleSupport.java
Index: SetLocaleSupport.java
===================================================================
RCS file: /home/cvs/jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/common/fmt/SetLocaleSupport.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- SetLocaleSupport.java 16 Apr 2002 18:17:51 -0000 1.5
+++ SetLocaleSupport.java 17 Apr 2002 20:48:03 -0000 1.6
@@ -265,13 +265,15 @@
Tag parent = findAncestorWithClass(fromTag, BundleSupport.class);
if (parent != null) {
// use locale from parent <fmt:bundle> tag
- locCtxt = ((BundleSupport) parent).getLocalizationContext();
- ResourceBundle bundle = locCtxt.getResourceBundle();
- if (bundle != null) {
- if (format) {
- setResponseLocale(pc, bundle.getLocale());
+ if ((locCtxt = ((BundleSupport) parent).getLocalizationContext())
+ != null) {
+ ResourceBundle bundle = locCtxt.getResourceBundle();
+ if (bundle != null) {
+ if (format) {
+ setResponseLocale(pc, bundle.getLocale());
+ }
+ return bundle.getLocale();
}
- return bundle.getLocale();
}
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>