NullPointerException when mapping BLOB to byte[] if BLOB is null ----------------------------------------------------------------
Key: IBATIS-138 URL: http://issues.apache.org/jira/browse/IBATIS-138 Project: iBatis for Java Type: Bug Components: SQL Maps Versions: 2.1.0 Environment: any Reporter: Paul Barry com.ibatis.sqlmap.engine.type.BlobTypeHandlerCallback throws a NullPointerException when the blob is null. I believe this patch solves the problem: --- orig.txt 2005-05-25 17:04:44.957125000 -0400 +++ new.txt 2005-05-25 17:04:48.394625000 -0400 @@ -24,14 +24,21 @@ public Object getResult(ResultGetter getter) throws SQLException { Blob blob = getter.getBlob(); - int size = (int) blob.length(); - return blob.getBytes(1, size); + if(blob != null) { + int size = (int) blob.length(); + return blob.getBytes(1, size); + } else { + return null; + } + } public void setParameter(ParameterSetter setter, Object parameter) throws SQLException { - byte[] bytes = (byte[]) parameter; - setter.setBytes(bytes); + if(parameter != null) { + byte[] bytes = (byte[]) parameter; + setter.setBytes(bytes); + } } public Object valueOf(String s) { -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira