Empty Blobs cause exception with DB2 9.5

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Empty Blobs cause exception with DB2 9.5

Frauke
Hello,
 
with DB2 driver version 9.5 we get an array out of bounds exception when reading an empty or null blob.
With DB2 9.7 it works fine for some reasons. We are currently using DBUnit version 2.4.4
 
To solve this problem, we patched the file org.dbunit.dataset.datatype.BytesDataType in function typeCast (line 149...).
May be you could solve the problem in the next version, if not done so already.
 
if (value instanceof Blob)
{
    try
    {
        Blob blobValue = (Blob)value;
        // patch start
        if (blobValue == null || blobValue.length() == 0) {
            return null;
        }
        // patch end
       return blobValue.getBytes(1, (int)blobValue.length());
    }
    catch (SQLException e)
    {
        throw new TypeCastException(value, this, e);
    }
}
 
 
Thank you and best regards
Frauke
 
 

------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
dbunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/dbunit-user
Reply | Threaded
Open this post in threaded view
|

Re: Empty Blobs cause exception with DB2 9.5

Matthias Gommeringer

Hi,

I applied your patch to the current trunk with a small modification (instanceof already implies that an object cannot be null).

Can you build the current trunk and let me know if it is okay now?

thx,

matthias



Von: Frauke Heyl <[hidden email]>
Gesendet: 25.03.2010 08:55:49
An: [hidden email]
Betreff: [dbunit-user] Empty Blobs cause exception with DB2 9.5

Hello,
  
with DB2 driver version 9.5 we get an array out of bounds exception when reading an empty or null blob.
With DB2 9.7 it works fine for some reasons. We are currently using DBUnit version 2.4.4
  
To solve this problem, we patched the file org.dbunit.dataset.datatype.BytesDataType in function typeCast (line 149...).
May be you could solve the problem in the next version, if not done so already.
  
if (value instanceof Blob)
{
    try
    {
        Blob blobValue = (Blob)value;
        // patch start
        if (blobValue == null || blobValue.length() == 0) {
            return null;
        }
        // patch end
       return blobValue.getBytes(1, (int)blobValue.length());
    }
    catch (SQLException e)
    {
        throw new TypeCastException(value, this, e);
    }
}
 
 
Thank you and best regards
Frauke
 
 

------------------------------------------------------------------------------ Download Intel&#174; Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev
_______________________________________________ dbunit-user mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/dbunit-user  

GRATIS für alle WEB.DE-Nutzer: Die maxdome Movie-FLAT!   
Jetzt freischalten unter http://movieflat.web.de

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
dbunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/dbunit-user
Reply | Threaded
Open this post in threaded view
|

Re: Empty Blobs cause exception with DB2 9.5

Frauke
Hi Matthias,
 
I finally managed to check the current version with your correction and it works fine.
Thank you
 
Frauke


Von: Matthias Gommeringer [mailto:[hidden email]]
Gesendet: Donnerstag, 25. März 2010 23:10
An: [hidden email]
Betreff: Re: [dbunit-user] Empty Blobs cause exception with DB2 9.5

Hi,

I applied your patch to the current trunk with a small modification (instanceof already implies that an object cannot be null).

Can you build the current trunk and let me know if it is okay now?

thx,

matthias



Von: Frauke Heyl <[hidden email]>
Gesendet: 25.03.2010 08:55:49
An: [hidden email]
Betreff: [dbunit-user] Empty Blobs cause exception with DB2 9.5

Hello,
  
with DB2 driver version 9.5 we get an array out of bounds exception when reading an empty or null blob.
With DB2 9.7 it works fine for some reasons. We are currently using DBUnit version 2.4.4
  
To solve this problem, we patched the file org.dbunit.dataset.datatype.BytesDataType in function typeCast (line 149...).
May be you could solve the problem in the next version, if not done so already.
  
if (value instanceof Blob)
{
    try
    {
        Blob blobValue = (Blob)value;
        // patch start
        if (blobValue == null || blobValue.length() == 0) {
            return null;
        }
        // patch end
       return blobValue.getBytes(1, (int)blobValue.length());
    }
    catch (SQLException e)
    {
        throw new TypeCastException(value, this, e);
    }
}
 
 
Thank you and best regards
Frauke
 
 

------------------------------------------------------------------------------ Download Intel&#174; Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev
_______________________________________________ dbunit-user mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/dbunit-user  

GRATIS für alle WEB.DE-Nutzer: Die maxdome Movie-FLAT!   
Jetzt freischalten unter http://movieflat.web.de

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
dbunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/dbunit-user
Reply | Threaded
Open this post in threaded view
|

Re: Empty Blobs cause exception with DB2 9.5

John Hurst-2
In reply to this post by Matthias Gommeringer
Would it not be better to return a zero-length array of bytes, rather than null? It seems to me that this is what Blob#getBytes() is supposed to do when length is 0 (according to Javadoc).

If value is null, then typeCast(value) returns null.

If value is a zero-length BLOB, would that not be different from NULL in most databases? (Forget about Oracle ... grrr!  I live with it.)

I think I should try to add some integration tests for this sort of corner case, to see what happens with different databases.

Frauke, perhaps you could try with "new byte[0]" instead of "null"?

JH

On Fri, Mar 26, 2010 at 10:10 AM, Matthias Gommeringer <[hidden email]> wrote:

Hi,

I applied your patch to the current trunk with a small modification (instanceof already implies that an object cannot be null).

Can you build the current trunk and let me know if it is okay now?

thx,

matthias



Von: Frauke Heyl <[hidden email]>
Gesendet: 25.03.2010 08:55:49
An: [hidden email]
Betreff: [dbunit-user] Empty Blobs cause exception with DB2 9.5


Hello,
  
with DB2 driver version 9.5 we get an array out of bounds exception when reading an empty or null blob.
With DB2 9.7 it works fine for some reasons. We are currently using DBUnit version 2.4.4
  
To solve this problem, we patched the file org.dbunit.dataset.datatype.BytesDataType in function typeCast (line 149...).
May be you could solve the problem in the next version, if not done so already.
  
if (value instanceof Blob)
{
    try
    {
        Blob blobValue = (Blob)value;
        // patch start
        if (blobValue == null || blobValue.length() == 0) {
            return null;
        }
        // patch end
       return blobValue.getBytes(1, (int)blobValue.length());
    }
    catch (SQLException e)
    {
        throw new TypeCastException(value, this, e);
    }
}
 
 
Thank you and best regards
Frauke
 
 

------------------------------------------------------------------------------ Download Intel&#174; Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev
_______________________________________________ dbunit-user mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/dbunit-user  

GRATIS für alle WEB.DE-Nutzer: Die maxdome Movie-FLAT!   
Jetzt freischalten unter http://movieflat.web.de

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
dbunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/dbunit-user




--
Life is interfering with my game

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
dbunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/dbunit-user
Reply | Threaded
Open this post in threaded view
|

Re: Empty Blobs cause exception with DB2 9.5

Matthias Gommeringer
In reply to this post by Frauke

Hi Frauke,

you're very welcome :-)

matthias




Von: Frauke Heyl <[hidden email]>
Gesendet: 13.04.2010 10:24:54
An: [hidden email]
Betreff: Re: [dbunit-user] Empty Blobs cause exception with DB2 9.5

Hi Matthias,
 
I finally managed to check the current version with your correction and it works fine.
Thank you
 
Frauke


Von: Matthias Gommeringer [mailto:[hidden email]]
Gesendet: Donnerstag, 25. März 2010 23:10
An: [hidden email]
Betreff: Re: [dbunit-user] Empty Blobs cause exception with DB2 9.5

Hi,

I applied your patch to the current trunk with a small modification (instanceof already implies that an object cannot be null).

Can you build the current trunk and let me know if it is okay now?

thx,

matthias



Von: Frauke Heyl <[hidden email]>
Gesendet: 25.03.2010 08:55:49
An: [hidden email]
Betreff: [dbunit-user] Empty Blobs cause exception with DB2 9.5

Hello,
  
with DB2 driver version 9.5 we get an array out of bounds exception when reading an empty or null blob.
With DB2 9.7 it works fine for some reasons. We are currently using DBUnit version 2.4.4
  
To solve this problem, we patched the file org.dbunit.dataset.datatype.BytesDataType in function typeCast (line 149...).
May be you could solve the problem in the next version, if not done so already.
  
if (value instanceof Blob)
{
    try
    {
        Blob blobValue = (Blob)value;
        // patch start
         if (blobValue == null || blobValue.length() == 0) {
            return null;
        }
        // patch end
       return blobValue.getBytes(1, (int)blobValue.length());
    }
    catch (SQLException e)
    {
        throw new TypeCastException(value, this, e);
    }
}
  
   
Thank you and best regards
Frauke
  
  

------------------------------------------------------------------------------ Download Intel&#174; Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev
_______________________________________________ dbunit-user mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/dbunit-user  

GRATIS für alle WEB.DE-Nutzer: Die maxdome Movie-FLAT!   
Jetzt freischalten unter http://movieflat.web.de
  

GRATIS: Movie-Flat mit über 300 Top-Videos. Für WEB.DE Nutzer   
dauerhaft kostenlos! Jetzt freischalten unter http://movieflat.web.de

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___________________________________________________________
GRATIS: Movie-Flat mit über 300 Top-Videos. Für WEB.DE Nutzer
dauerhaft kostenlos! Jetzt freischalten unter http://movieflat.web.de

_______________________________________________
dbunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/dbunit-user

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
dbunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/dbunit-user