You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ibatis.apache.org by "Larry Meadors (JIRA)" <ib...@incubator.apache.org> on 2005/06/04 14:33:45 UTC

[jira] Resolved: (IBATIS-138) NullPointerException when mapping BLOB to byte[] if BLOB is null

     [ http://issues.apache.org/jira/browse/IBATIS-138?page=all ]
     
Larry Meadors resolved IBATIS-138:
----------------------------------

    Fix Version: 2.1.1
     Resolution: Fixed

> 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
>     Assignee: Larry Meadors
>      Fix For: 2.1.1

>
> 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