manifoldcf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwri...@apache.org
Subject svn commit: r1696600 - in /manifoldcf/trunk: CHANGES.txt connectors/forcedmetadata/connector/src/main/java/org/apache/manifoldcf/agents/transformation/forcedmetadata/FieldSource.java
Date Wed, 19 Aug 2015 14:47:15 GMT
Author: kwright
Date: Wed Aug 19 14:47:14 2015
New Revision: 1696600

URL: http://svn.apache.org/r1696600
Log:
Fix for CONNECTORS-1229.

Modified:
    manifoldcf/trunk/CHANGES.txt
    manifoldcf/trunk/connectors/forcedmetadata/connector/src/main/java/org/apache/manifoldcf/agents/transformation/forcedmetadata/FieldSource.java

Modified: manifoldcf/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/CHANGES.txt?rev=1696600&r1=1696599&r2=1696600&view=diff
==============================================================================
--- manifoldcf/trunk/CHANGES.txt (original)
+++ manifoldcf/trunk/CHANGES.txt Wed Aug 19 14:47:14 2015
@@ -3,6 +3,9 @@ $Id$
 
 ======================= 2.2-dev =====================
 
+CONNECTORS-1229: Fix NPE in metadata adjuster.
+(Mike Caceres, Karl Wright)
+
 CONNECTORS-1226: PostgreSQL does not implement the isValid()
 JDBC method in the driver we include, so make sure when we call it
 we don't fail if we get an exception.  Related to CONNECTORS-1202.

Modified: manifoldcf/trunk/connectors/forcedmetadata/connector/src/main/java/org/apache/manifoldcf/agents/transformation/forcedmetadata/FieldSource.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/forcedmetadata/connector/src/main/java/org/apache/manifoldcf/agents/transformation/forcedmetadata/FieldSource.java?rev=1696600&r1=1696599&r2=1696600&view=diff
==============================================================================
--- manifoldcf/trunk/connectors/forcedmetadata/connector/src/main/java/org/apache/manifoldcf/agents/transformation/forcedmetadata/FieldSource.java
(original)
+++ manifoldcf/trunk/connectors/forcedmetadata/connector/src/main/java/org/apache/manifoldcf/agents/transformation/forcedmetadata/FieldSource.java
Wed Aug 19 14:47:14 2015
@@ -31,6 +31,9 @@ public class FieldSource implements IDat
   protected final static int CASE_LOWER = 1;
   protected final static int CASE_UPPER = 2;
   
+  protected final static Object[] EMPTY_OBJECT_ARRAY = new Object[0];
+  protected final static String[] EMPTY_STRING_ARRAY = new String[0];
+  
   protected final FieldDataFactory rd;
   protected final String fieldName;
   protected final Pattern regExpPattern;
@@ -84,10 +87,7 @@ public class FieldSource implements IDat
   @Override
   public int getSize()
     throws IOException, ManifoldCFException {
-    Object[] rawForm = getRawForm();
-    if (rawForm == null)
-      return 0;
-    return rawForm.length;
+    return getRawForm().length;
   }
     
   @Override
@@ -96,7 +96,10 @@ public class FieldSource implements IDat
     if (regExpPattern != null) {
       return calculateExtractedResult();
     }
-    return rd.getField(fieldName);
+    final Object[] rval = rd.getField(fieldName);
+    if (rval == null)
+      return EMPTY_OBJECT_ARRAY;
+    return rval;
   }
     
   @Override
@@ -105,7 +108,10 @@ public class FieldSource implements IDat
     if (regExpPattern != null) {
       return calculateExtractedResult();
     }
-    return rd.getFieldAsStrings(fieldName);
+    final String[] rval = rd.getFieldAsStrings(fieldName);
+    if (rval == null)
+      return EMPTY_STRING_ARRAY;
+    return rval;
   }
   
   protected String[] calculateExtractedResult()
@@ -131,7 +137,7 @@ public class FieldSource implements IDat
           resultList.add(result);
         }
       }
-      cachedValue = resultList.toArray(new String[0]);
+      cachedValue = resultList.toArray(EMPTY_STRING_ARRAY);
     }
     return cachedValue;
   }



Mime
View raw message