pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
NPE in BlobInputStream
4+ messages / 2 participants
[nested] [flat]

* NPE in BlobInputStream
@ 2006-11-24 18:56  matrixx <matrixx@freenet.de>
  0 siblings, 1 reply; 4+ messages in thread

From: matrixx @ 2006-11-24 18:56 UTC (permalink / raw)
  To: pgsql-jdbc

Hi,

im using the postgresql-8.1-407.jdbc3.jar driver over hibernate 3 to 
access databases.

Our application currently runs with mysql and mssql drivers without any 
problems. With the postgresql driver i get the following exception:

[ModuleProfile.deserialize@AWT-EventQueue-0] ERROR: Error deserializing 
blob.
java.lang.NullPointerException
	at 
org.postgresql.largeobject.BlobInputStream.close(BlobInputStream.java:115)
	at java.beans.XMLDecoder.close(XMLDecoder.java:152)
	...

I dont know if its a driver bug, or a hibernate issue.


Thanks for any help
JR






^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: NPE in BlobInputStream
@ 2006-11-26 11:36  Kris Jurka <books@ejurka.com>
  parent: matrixx <matrixx@freenet.de>
  0 siblings, 2 replies; 4+ messages in thread

From: Kris Jurka @ 2006-11-26 11:36 UTC (permalink / raw)
  To: matrixx <matrixx@freenet.de>; +Cc: pgsql-jdbc



On Fri, 24 Nov 2006, matrixx wrote:

> im using the postgresql-8.1-407.jdbc3.jar driver over hibernate 3 to access 
> databases.
>
> Our application currently runs with mysql and mssql drivers without any 
> problems. With the postgresql driver i get the following exception:
>
> [ModuleProfile.deserialize@AWT-EventQueue-0] ERROR: Error deserializing blob.
> java.lang.NullPointerException
> 	at 
> org.postgresql.largeobject.BlobInputStream.close(BlobInputStream.java:115)
> 	at java.beans.XMLDecoder.close(XMLDecoder.java:152)
> 	...
>
> I dont know if its a driver bug, or a hibernate issue.
>

It's a driver bug that's caused by one of two possible issues.  It's 
impossible to tell which from this stacktrace alone.

1) The BlobInputStream is violating the contract of the close method that 
allows you to call it more than once.

2) You've called getInputStream more than once on a Blob and it can't 
handle two streams simultaneously.

I've produced a fix for 1 and a very simple version of 2.  Could you try 
out this jar file and let me know if it works:

http://www.ejurka.com/pgsql/jars/mx/

Kris Jurka

Attachments:

blob.patch (text/plain, 2.5K) download ? built ? unchanged-isolation.patch Index: org/postgresql/jdbc2/AbstractJdbc2BlobClob.java =================================================================== RCS file: /usr/local/cvsroot/pgjdbc/pgjdbc/org/postgresql/jdbc2/AbstractJdbc2BlobClob.java,v retrieving revision 1.3 diff -c -r1.3 AbstractJdbc2BlobClob.java *** org/postgresql/jdbc2/AbstractJdbc2BlobClob.java 9 May 2005 03:17:18 -0000 1.3 --- org/postgresql/jdbc2/AbstractJdbc2BlobClob.java 26 Nov 2006 11:34:17 -0000 *************** *** 54,59 **** --- 54,60 ---- public InputStream getBinaryStream() throws SQLException { + lo.seek(0); return lo.getInputStream(); } Index: org/postgresql/largeobject/BlobInputStream.java =================================================================== RCS file: /usr/local/cvsroot/pgjdbc/pgjdbc/org/postgresql/largeobject/BlobInputStream.java,v retrieving revision 1.10 diff -c -r1.10 BlobInputStream.java *** org/postgresql/largeobject/BlobInputStream.java 11 Jan 2005 08:25:47 -0000 1.10 --- org/postgresql/largeobject/BlobInputStream.java 26 Nov 2006 11:34:19 -0000 *************** *** 110,124 **** */ public void close() throws IOException { ! try ! { ! lo.close(); ! lo = null; ! } ! catch (SQLException se) ! { ! throw new IOException(se.toString()); ! } } /** --- 110,116 ---- */ public void close() throws IOException { ! lo = null; } /** Index: org/postgresql/largeobject/BlobOutputStream.java =================================================================== RCS file: /usr/local/cvsroot/pgjdbc/pgjdbc/org/postgresql/largeobject/BlobOutputStream.java,v retrieving revision 1.11 diff -c -r1.11 BlobOutputStream.java *** org/postgresql/largeobject/BlobOutputStream.java 11 Jan 2005 08:25:47 -0000 1.11 --- org/postgresql/largeobject/BlobOutputStream.java 26 Nov 2006 11:34:19 -0000 *************** *** 133,148 **** */ public void close() throws IOException { ! try ! { ! flush(); ! lo.close(); ! lo = null; ! } ! catch (SQLException se) ! { ! throw new IOException(se.toString()); ! } } } --- 133,140 ---- */ public void close() throws IOException { ! flush(); ! lo = null; } }
^ permalink raw reply [nested|flat] 4+ messages in thread

* Re: NPE in BlobInputStream
@ 2006-11-26 22:21  matrixx <matrixx@freenet.de>
  parent: Kris Jurka <books@ejurka.com>
  1 sibling, 0 replies; 4+ messages in thread

From: matrixx @ 2006-11-26 22:21 UTC (permalink / raw)
  To: Kris Jurka <books@ejurka.com>; +Cc: pgsql-jdbc

Kris Jurka schrieb:
> 
> 
> On Fri, 24 Nov 2006, matrixx wrote:
> 
>> im using the postgresql-8.1-407.jdbc3.jar driver over hibernate 3 to 
>> access databases.
>>
>> Our application currently runs with mysql and mssql drivers without 
>> any problems. With the postgresql driver i get the following exception:
>>
>> [ModuleProfile.deserialize@AWT-EventQueue-0] ERROR: Error 
>> deserializing blob.
>> java.lang.NullPointerException
>>     at 
>> org.postgresql.largeobject.BlobInputStream.close(BlobInputStream.java:115) 
>>
>>     at java.beans.XMLDecoder.close(XMLDecoder.java:152)
>>     ...
>>
>> I dont know if its a driver bug, or a hibernate issue.
>>
> 
> It's a driver bug that's caused by one of two possible issues.  It's 
> impossible to tell which from this stacktrace alone.
> 
> 1) The BlobInputStream is violating the contract of the close method 
> that allows you to call it more than once.
> 
> 2) You've called getInputStream more than once on a Blob and it can't 
> handle two streams simultaneously.
> 
> I've produced a fix for 1 and a very simple version of 2.  Could you try 
> out this jar file and let me know if it works:
> 

building the 8.1_407 failed cause i'm using jdk1.6.
But i was able to apply and build the patch on 8.2devel.

The NPE is gone there.

The getBinaryStream() is called only once from my side.
The code for accessing the blob simply is:

  ...
  InputStream is = blob.getBinaryStream();
  XMLDecoder decoder = new XMLDecoder(is);
  config = (ModuleProfile) decoder.readObject();
  decoder.close();
  ...

(The blob is from a Hibernate data object).

JR



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: NPE in BlobInputStream
@ 2007-02-19 18:37  Kris Jurka <books@ejurka.com>
  parent: Kris Jurka <books@ejurka.com>
  1 sibling, 0 replies; 4+ messages in thread

From: Kris Jurka @ 2007-02-19 18:37 UTC (permalink / raw)
  To: matrixx <matrixx@freenet.de>; +Cc: pgsql-jdbc



On Sun, 26 Nov 2006, Kris Jurka wrote:

> On Fri, 24 Nov 2006, matrixx wrote:
>
>> im using the postgresql-8.1-407.jdbc3.jar driver over hibernate 3 to access 
>> databases.
>> 
>> Our application currently runs with mysql and mssql drivers without any 
>> problems. With the postgresql driver i get the following exception:
>> 
>> [ModuleProfile.deserialize@AWT-EventQueue-0] ERROR: Error deserializing 
>> blob.
>> java.lang.NullPointerException
>> 	at 
>> org.postgresql.largeobject.BlobInputStream.close(BlobInputStream.java:115)
>> 	at java.beans.XMLDecoder.close(XMLDecoder.java:152)
>> 	...
>> 
>> I dont know if its a driver bug, or a hibernate issue.
>> 
>
> It's a driver bug that's caused by one of two possible issues.  It's 
> impossible to tell which from this stacktrace alone.
>
> 1) The BlobInputStream is violating the contract of the close method that 
> allows you to call it more than once.
>
> 2) You've called getInputStream more than once on a Blob and it can't handle 
> two streams simultaneously.
>

I've applied a more complete fix for these issues to CVS HEAD.

Kris Jurka



^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2007-02-19 18:37 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-11-24 18:56 NPE in BlobInputStream matrixx <matrixx@freenet.de>
2006-11-26 11:36 ` Kris Jurka <books@ejurka.com>
2006-11-26 22:21   ` matrixx <matrixx@freenet.de>
2007-02-19 18:37   ` Kris Jurka <books@ejurka.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox