lucene-solr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From no...@apache.org
Subject svn commit: r886690 - /lucene/solr/trunk/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/EntityProcessorWrapper.java
Date Thu, 03 Dec 2009 07:36:59 GMT
Author: noble
Date: Thu Dec  3 07:36:42 2009
New Revision: 886690

URL: http://svn.apache.org/viewvc?rev=886690&view=rev
Log:
SOLR-1612 use isAssignablefrom() and catch noSuchmethodException

Modified:
    lucene/solr/trunk/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/EntityProcessorWrapper.java

Modified: lucene/solr/trunk/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/EntityProcessorWrapper.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/EntityProcessorWrapper.java?rev=886690&r1=886689&r2=886690&view=diff
==============================================================================
--- lucene/solr/trunk/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/EntityProcessorWrapper.java
(original)
+++ lucene/solr/trunk/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/EntityProcessorWrapper.java
Thu Dec  3 07:36:42 2009
@@ -101,24 +101,21 @@
       }
       try {
         Class clazz = DocBuilder.loadClass(trans, context.getSolrCore());
-        if (clazz.newInstance() instanceof Transformer) {
+        if (Transformer.class.isAssignableFrom(clazz)) {
           transformers.add((Transformer) clazz.newInstance());
         } else {
-          final Method meth = clazz.getMethod(TRANSFORM_ROW, Map.class);
-          if (meth == null) {
-            String msg = "Transformer :"
-                    + trans
-                    + "does not implement Transformer interface or does not have a transformRow(Map
m)method";
-            log.error(msg);
-            throw new DataImportHandlerException(
-                    SEVERE, msg);
-          }
+          Method meth = clazz.getMethod(TRANSFORM_ROW, Map.class);
           transformers.add(new ReflectionTransformer(meth, clazz, trans));
         }
+      } catch (NoSuchMethodException nsme){
+         String msg = "Transformer :"
+                    + trans
+                    + "does not implement Transformer interface or does not have a transformRow(Map<String.Object>
m)method";
+            log.error(msg);
+            wrapAndThrow(SEVERE, nsme,msg);        
       } catch (Exception e) {
         log.error("Unable to load Transformer: " + aTransArr, e);
-        throw new DataImportHandlerException(SEVERE,
-                e);
+        wrapAndThrow(SEVERE, e,"Unable to load Transformer: " + trans);
       }
     }
 



Mime
View raw message