You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Lo...@lotus.com on 2001/03/08 20:50:35 UTC

Re: xalan 2 in applet - comment on where to put try...catch

One question about this particular patch (which is definitely needed):
shouldn't there be separate try...catch blocks around each call to
System.getProperty(), instead of having a big one around the whole thing?
That way if an exception is thrown, it only results in that particular
property not getting overidden from the System, not all of them (or all
following ones).

- Shane

----- you Edwin Goei <Ed...@eng.sun.com> proposed this *new* code
patch: ----
      props.load(bis);

!     // Catch SecurityException so code will run in an applet
!     try { // SC this should be moved later
!         // Note that we're working at the HashTable level here,
!         // and not at the Properties level!  This is important
!         // because we don't want to modify the default properties.
!         Enumeration keys = props.keys();
!         while(keys.hasMoreElements())
!             {
!                 String key = (String)keys.nextElement();
!                 // Now check if the given key was specified as a
!                 // System property. If so, the system property
!                 // overides the default value in the propery file.
!                 String value;

     // SC don't we just want to surround this statement...
!                 if ((value = System.getProperty(key)) == null)
!                     value = (String)props.get(key);


!                 String newKey = fixupPropertyString(key, true);
!                 String newValue;

     // SC ... and this statement with try...catch blocks?
!                 if ((newValue = System.getProperty(newKey)) == null)
!                     newValue = fixupPropertyString(value, false);
!                 else
!                     newValue = fixupPropertyString(newValue, false);

!                 if(key != newKey || value != newValue)
!                     {
!                         props.remove(key);
!                         props.put(newKey, newValue);
!                     }

+             }
+     } catch (SecurityException se) {
      }

      return props;