lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andreas W (JIRA)" <j...@apache.org>
Subject [jira] [Created] (SOLR-3395) FieldStreamDataSource should handle null fields
Date Mon, 23 Apr 2012 07:22:39 GMT
Andreas W created SOLR-3395:
-------------------------------

             Summary: FieldStreamDataSource should handle null fields
                 Key: SOLR-3395
                 URL: https://issues.apache.org/jira/browse/SOLR-3395
             Project: Solr
          Issue Type: Improvement
          Components: contrib - DataImportHandler
    Affects Versions: 3.5
            Reporter: Andreas W
            Priority: Minor


The {{FieldStreamDataSource}} currently throws a {{DataImportHandlerException}} if a field
value is null.
IMHO this is not appropriate: It is legal for field values to be null (like no {{Blob}} exists
in a particular row).
I suggest to return an empty InputStream rather than throwing a {{DataImportHandlerException}}.

{code}
  public InputStream getData(String query) {
    Object o = wrapper.getVariableResolver().resolve(dataField);
    if (o == null) {
//better: return new ByteArrayInputStream(new byte[0]);
      throw new DataImportHandlerException(SEVERE, "No field available for name : " + dataField);
    }
    if (o instanceof Blob) {
      Blob blob = (Blob) o;
      try {
        //Most of the JDBC drivers have getBinaryStream defined as public
        // so let us just check it
        Method m = blob.getClass().getDeclaredMethod("getBinaryStream");
        if (Modifier.isPublic(m.getModifiers())) {
          return (InputStream) m.invoke(blob);
        } else {
          // force invoke
          m.setAccessible(true);
          return (InputStream) m.invoke(blob);
        }
      } catch (Exception e) {
        LOG.info("Unable to get data from BLOB");
        return null;

      }
    } else if (o instanceof byte[]) {
      byte[] bytes = (byte[]) o;
      return new ByteArrayInputStream(bytes);
    } else {
      throw new RuntimeException("unsupported type : " + o.getClass());
    } 

  }
{code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


Mime
View raw message