You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-user@portals.apache.org by "Kimpton,C (Chris)" <Ki...@rabo-bank.com> on 2001/04/06 17:07:34 UTC

jetspeed 1.3a1 / jdk1.3 bug... setting/getting system properties

Hi,

We have just come across a problem relating to jdk1.3,
System.getProperties() and the org.apache.jetspeed.util.PropertyHolder class
(hidden in SingletonHolder).


PropertyHolder is a subclass of Properties - which replaces the System
properties object with itself.  It overrides the get and put method to allow
extra facilities in this class.

The new version basically puts any new properties into its own hashtable -
only updating the underlying system properties if you are amending an
existing property.

The implementation of the getProperty method in jdk1.3/java.util.Properties
users super.get() to access its internal hashtable. But the setProperty
method just uses the method put (no super).



This means that if you put a new property into the system properties, then
the PropertyHolder will store it in its own internal store.

You can do a get and you will find it - since it uses the PropertyHolder
get, but if you use getProperty, because of the super.get, it will call the
get on the hashtable - but the object has not been stored there - so you get
null returned!


This problem is noticed if you are trying to programmatically set a system
property, and you are finding it is not being set.

The workaround we have used so far has been to define the property on the
command line (-Dname=value) so that it gets into the system properties
before jetspeed takes over.

I have raised this as a bug with Sun - but I guess that will take a while to
get sorted.

I guess a short term fix for now would be to override the getProperty in
PropertyHolder and make it do the correct thing.  Here is a patch for just
that:


Index: SingletonHolder.java
===================================================================
RCS file:
/home/cvspublic/jakarta-jetspeed/src/java/org/apache/jetspeed/util/Singleton
Holder.java,v
retrieving revision 1.7
diff -u -r1.7 SingletonHolder.java
--- SingletonHolder.java        2001/03/07 06:50:05     1.7
+++ SingletonHolder.java        2001/04/06 15:03:31
@@ -225,6 +225,18 @@
         }

     }
+
+    /** HACK TO GET ROUND JDK BUG.
+    * until the Properties.getProperty version of this
+    * method is fixed to not use super.get, this can then be removed
+    **/
+    public String getProperty(String key) {
+        Object oval = get(key);
+        String sval = (oval instanceof String) ? (String)oval : null;
+        return ((sval == null) && (defaults != null)) ?
defaults.getProperty(key) : sval;
+    }
+
+

     /**
     Provide information if this class was finalized









Hope this helps
Chris

================================================================================================
This electronic message (email) and any attachments to it are subject to copyright and are sent for the personal attention of the addressee. Although you may be the named recipient, it may become apparent that this email and its contents are not intended for you and an addressing error has been made. This email may include information that is legally privileged and exempt from disclosure. If you have received this email in error, please advise us immediately and delete this email and any attachments from your computer system.Rabobank International is the trading name of Coöperatieve Centrale Raiffeisen-Boerenleenbank B.A. which is incorporated in the Netherlands. Registered with the Registrar of Companies for England & Wales No. BR002630 and regulated by the SFA for the conduct of investment business in the UK.

The presence of this footnote also confirms that this email has been automatically checked by Rabobank International for the presence of computer viruses prior to it being sent, however, no guarantee is given or implied that this email is virus free upon delivery.



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