You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by Klaus Kiehne <ki...@struktur.de> on 2000/11/08 12:27:04 UTC

[Bug] in static initializer of SerializerFactory ? !

Hi,

I think i've found an bug in the static initializer of class
org.apache.xml.serialize.SerializerFactory.

I'm trying to install my own srializerFactory for HTML to avoid 
the entities for non ANSI Characters, which are not defined in HTML 3.2.
Therefore I define the system property "org.apache.xml.serialize.factories"
but unfortunately my factory is not used.

A closer look to the static initializer of org.apache.xml.serialize.SerializerFactory shows the code

01      list = System.getProperty( FactoriesProperty );
02      if ( list != null ) {
03              token = new StringTokenizer( list, " ;,:" );
04              while ( token.hasMoreTokens() ) {
05                      className = token.nextToken();
06                      try {
07                              factory = (SerializerFactory) Class.forName( className ).newInstance();
08                              if ( _factories.contains( factory.getSupportedMethod() ) )
09                                      _factories.put( factory.getSupportedMethod(), factory );
10                      } catch ( Exception except ) { }
11              }
12      }

I think there is a bug in line 8 . The test should be _factories.containsKey(... and not
_factories.contains(...  . The Hashtable _factories will never contain a _value_ like
the supported method of the new Factory since it holds the methods as keys and the Factories
as values.

BTW: I don't understand the sense of this test, even if fixed. Why shouldn't it be possible
to create SerializerFactorys for any additional method? If really intended, a comment would be nice.

Klaus