You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by dg...@apache.org on 2003/04/19 21:06:02 UTC

cvs commit: jakarta-struts/src/share/org/apache/struts/util PropertyMessageResources.java

dgraham     2003/04/19 12:06:02

  Modified:    src/share/org/apache/struts/util
                        PropertyMessageResources.java
  Log:
  Improved exception handling.
  
  Revision  Changes    Path
  1.8       +29 -25    jakarta-struts/src/share/org/apache/struts/util/PropertyMessageResources.java
  
  Index: PropertyMessageResources.java
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/util/PropertyMessageResources.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- PropertyMessageResources.java	13 Mar 2003 01:44:47 -0000	1.7
  +++ PropertyMessageResources.java	19 Apr 2003 19:06:02 -0000	1.8
  @@ -62,6 +62,7 @@
   
   package org.apache.struts.util;
   
  +import java.io.IOException;
   import java.io.InputStream;
   import java.util.HashMap;
   import java.util.Iterator;
  @@ -86,6 +87,7 @@
    * the same locale + key combination.
    *
    * @author Craig R. McClanahan
  + * @author David Graham
    * @version $Revision$ $Date$
    */
   public class PropertyMessageResources extends MessageResources {
  @@ -283,38 +285,40 @@
           Properties props = new Properties();
   
           // Load the specified property resource
  -        try {
  -            if (log.isTraceEnabled()) {
  -                log.trace("  Loading resource '" + name + "'");
  -            }
  -            ClassLoader classLoader =
  -                Thread.currentThread().getContextClassLoader();
  -            if (classLoader == null) {
  -                classLoader = this.getClass().getClassLoader();
  -            }
  -            is = classLoader.getResourceAsStream(name);
  -            if (is != null) {
  +        if (log.isTraceEnabled()) {
  +            log.trace("  Loading resource '" + name + "'");
  +        }
  +        
  +        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
  +        if (classLoader == null) {
  +            classLoader = this.getClass().getClassLoader();
  +        }
  +        
  +        is = classLoader.getResourceAsStream(name);
  +        if (is != null) {
  +            try {
                   props.load(is);
  -                is.close();
  -            }
  -            if (log.isTraceEnabled()) {
  -                log.trace("  Loading resource completed");
  -            }
  -        } catch (Throwable t) {
  -            log.error("loadLocale()", t);
  -            if (is != null) {
  +                
  +            } catch (IOException e) {
  +                log.error("loadLocale()", e);
  +            } finally {
                   try {
                       is.close();
  -                } catch (Throwable u) {
  -                    ;
  +                } catch (IOException e) {
  +                    log.error("loadLocale()", e);
                   }
               }
           }
  +        
  +        if (log.isTraceEnabled()) {
  +            log.trace("  Loading resource completed");
  +        }
   
           // Copy the corresponding values into our cache
           if (props.size() < 1) {
               return;
           }
  +        
           synchronized (messages) {
               Iterator names = props.keySet().iterator();
               while (names.hasNext()) {
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-dev-help@jakarta.apache.org