[ 
https://issues.apache.org/activemq/browse/AMQ-1254?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_39379
 ] 

solprovider edited comment on AMQ-1254 at 6/13/07 11:25 AM:
------------------------------------------------------------

These issues are both related to locking systems.  The HashSet and HashMap 
contain a list of locked items.  This sounds troublesome because the classes 
are not synchronized.  System.Properties is a HashTable (automatically 
synchronized.)  System.Properties is being violated: "Each key and its 
corresponding value in the property list is a string." from 
http://java.sun.com/j2se/1.4.2/docs/api/java/util/Properties.html

{code:title=Test Code|borderStyle=solid}
   boolean test(){  //true = passes, false = failed.
      boolean test = true;
      java.util.Properties properties = System.getProperties();
      java.util.Enumeration enumeration = properties.elements();
      while(test & enumeration.hasMoreElements()) test= 
String.class.equals(enumeration.nextElement().getClass());
      enumeration = properties.keys();
      while(test & enumeration.hasMoreElements()) test= 
String.class.equals(enumeration.nextElement().getClass());
      return test;
   }
{code}


The typical algorithm for locking is to put an identifier as a key into the 
central location.  No objects are stored; use a static class if necessary, but 
this typically indicates poor design.  The property value is not needed for the 
locking system and typically contains information about the lock such as who 
created it and when. So locking C:Windows\Temp\badcode.java could create:
KEY: 
org.apache.activeio.journal.active.lockMap.C%3aWindows%2cTemp%2cbadcode%2ejava
VALUE: 20070613T122219Z solprovider reason

Set locks with System.setProperty(key, informationString);
Get the information about a lock with System.getProperty(key);
Check locks with System.getProperties().containsKey(key);
Remove locks with System.getProperties().remove(key);






 was:
These issues are both related to locking systems.  The HashSet and HashMap 
contain a list of locked items.  This sounds troublesome because the classes 
are not synchronized.  System.Properties is a HashTable (automatically 
synchronized.)  System.Properties is being violated: "Each key and its 
corresponding value in the property list is a string." from 
http://java.sun.com/j2se/1.4.2/docs/api/java/util/Properties.html

The typical algorithm for locking is to put an identifier as a key into the 
central location.  No objects are stored; use a static class if necessary, but 
this typically indicates poor design.  The property value is not needed for the 
locking system and typically contains information about the lock such as who 
created it and when. So locking C:Windows\Temp\badcode.java could create:
KEY: 
org.apache.activeio.journal.active.lockMap.C%3aWindows%2cTemp%2cbadcode%2ejava
VALUE: 20070613T122219Z solprovider reason

Set locks with System.setProperty(key, informationString);
Get the information about a lock with System.getProperty(key);
Check locks with System.getProperties().containsKey(key);
Remove locks with System.getProperties().remove(key);





> Kaha Store puts a non-string into System properties
> ---------------------------------------------------
>
>                 Key: AMQ-1254
>                 URL: https://issues.apache.org/activemq/browse/AMQ-1254
>             Project: ActiveMQ
>          Issue Type: Bug
>    Affects Versions: 4.1.2
>            Reporter: David Jencks
>         Attachments: Kaha-Store.patch
>
>
> KahaStore puts a hashmap into SystemProperties, which causes problems with 
> programs that expect only strings as properties.  In particular some versions 
> of Hibernate assume all system properties are strings: this is causing 
> difficulties running roller in geronimo 2.0
> Attached is a proposed solution.  I have no idea how to test it.  I get the 
> same 7 failures and one error building amq with and without the change.
> The proposal stores the list of locked directories in a string and converts 
> it back and forth to a map whenever it is accessed.  I use a constant string 
> as the vm-wide lock monitor formerly provided by the HashSet.  According to 
> the String javadoc constant strings are intern()ed and the same instance is 
> provided in any classloader: this makes it suitable for a vm-wide lock 
> monitor.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to