directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kayyag...@apache.org
Subject svn commit: r1592007 - /directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/BTreeFactory.java
Date Fri, 02 May 2014 18:45:37 GMT
Author: kayyagari
Date: Fri May  2 18:45:36 2014
New Revision: 1592007

URL: http://svn.apache.org/r1592007
Log:
create a new instance if the INSTANCE field is not found

Modified:
    directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/BTreeFactory.java

Modified: directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/BTreeFactory.java
URL: http://svn.apache.org/viewvc/directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/BTreeFactory.java?rev=1592007&r1=1592006&r2=1592007&view=diff
==============================================================================
--- directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/BTreeFactory.java
(original)
+++ directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/BTreeFactory.java
Fri May  2 18:45:36 2014
@@ -20,6 +20,7 @@
 package org.apache.directory.mavibot.btree;
 
 
+import java.lang.reflect.Field;
 import java.util.LinkedList;
 
 import org.apache.directory.mavibot.btree.serializer.ElementSerializer;
@@ -613,7 +614,21 @@ public class BTreeFactory<K, V>
     {
         Class<?> keySerializer = Class.forName( keySerializerFqcn );
         @SuppressWarnings("unchecked")
-        ElementSerializer<K> instance = ( ElementSerializer<K> ) keySerializer.getDeclaredField(
"INSTANCE" ).get( null );
+        ElementSerializer<K> instance = null;
+        try
+        {
+            instance = ( ElementSerializer<K> ) keySerializer.getDeclaredField( "INSTANCE"
).get( null );
+        }
+        catch( NoSuchFieldException e )
+        {
+            // ignore
+        }
+
+        if ( instance == null )
+        {
+            instance = ( ElementSerializer<K> ) keySerializer.newInstance();
+        }
+
         btree.setKeySerializer( instance );
     }
 
@@ -635,7 +650,21 @@ public class BTreeFactory<K, V>
     {
         Class<?> valueSerializer = Class.forName( valueSerializerFqcn );
         @SuppressWarnings("unchecked")
-        ElementSerializer<V> instance = ( ElementSerializer<V> ) valueSerializer.getDeclaredField(
"INSTANCE" ).get( null );
+        ElementSerializer<V> instance = null;
+        try
+        {
+            instance = ( ElementSerializer<V> ) valueSerializer.getDeclaredField( "INSTANCE"
).get( null );
+        }
+        catch( NoSuchFieldException e )
+        {
+            // ignore
+        }
+        
+        if ( instance == null )
+        {
+            instance = ( ElementSerializer<V> ) valueSerializer.newInstance();
+        }
+        
         btree.setValueSerializer( instance );
     }
 



Mime
View raw message