Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [CDO] StringIndexOutOfBoundsException thrown for a column containing a single space using H2
[CDO] StringIndexOutOfBoundsException thrown for a column containing a single space using H2 [message #994617] Thu, 27 December 2012 16:16 Go to next message
Ray Braithwood is currently offline Ray Braithwood
Messages: 5
Registered: November 2012
Junior Member
I believe I have found a bug in the H2 JDBC driver and have already created a bug against H2 about this. Unfortunately I cannot post a link to the bug until I have 5 posts to the forums.

The reason for the forum post here is that CDO will throw a StringIndexOutOfBoundException with the following situation.

1) Define a model object that has a field with an EChar
2) When CDO creates the table it creates a column for the EChar that is CHAR(1)
3) Write data using CDO that will put a space (unicode-32) as the char
4) shut down the "cdo server" and H2 database (to clear caches)
5) Restart everything and use CDO to retrieve the value from the DB

What happens now is that TMCharacter will get the data from the ResultSet. Because of the driver bug, all space chars are stripped from the data returning an empty String. TMCharacter will now call charAt(0) causing the exception.

We have a workaround in that we changed the model from EChar to EString and use a CDO annotation to make the column a VARCHAR(1) which does not get stripped by the JDBC driver.

Thanks
Re: [CDO] StringIndexOutOfBoundsException thrown for a column containing a single space using H2 [message #994714 is a reply to message #994617] Thu, 27 December 2012 23:28 Go to previous messageGo to next message
Eike Stepper is currently offline Eike Stepper
Messages: 5486
Registered: July 2009
Senior Member
Am 27.12.2012 22:16, schrieb Ray Braithwood:
> I believe I have found a bug in the H2 JDBC driver and have already created a bug against H2 about this.
> Unfortunately I cannot post a link to the bug until I have 5 posts to the forums.
I think you can post it if you obfuscate it a little bit, for example by putting a space after http:

>
> The reason for the forum post here is that CDO will throw a StringIndexOutOfBoundException with the following situation.
>
> 1) Define a model object that has a field with an EChar
> 2) When CDO creates the table it creates a column for the EChar that is CHAR(1)
> 3) Write data using CDO that will put a space (unicode-32) as the char
> 4) shut down the "cdo server" and H2 database (to clear caches)
> 5) Restart everything and use CDO to retrieve the value from the DB
>
> What happens now is that TMCharacter will get the data from the ResultSet. Because of the driver bug, all space chars
> are stripped from the data returning an empty String. TMCharacter will now call charAt(0) causing the exception.
>
> We have a workaround in that we changed the model from EChar to EString and use a CDO annotation to make the column a
> VARCHAR(1) which does not get stripped by the JDBC driver.
I hate to add workarounds for bugs in downstream dependencies but this one seems simple: as empty chars do not exist we
could return a space char if the string is empty. Please submit a bugzilla.

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
Re: [CDO] StringIndexOutOfBoundsException thrown for a column containing a single space using H2 [message #996665 is a reply to message #994714] Wed, 02 January 2013 11:37 Go to previous message
Ray Braithwood is currently offline Ray Braithwood
Messages: 5
Registered: November 2012
Junior Member
Thanks.

I have created https://bugs.eclipse.org/bugs/show_bug.cgi?id=397318 as requested.

Also the H2 bug I created is http: //code.google.com/p/h2database/issues/detail?id=432

Ray
Previous Topic:Usage of "org.eclipse.emf.ecore.factory_override"
Next Topic:Perm Gen Error with EMF Classes on Tomcat
Goto Forum:
  


Current Time: Tue Jul 29 10:48:02 EDT 2014

Powered by FUDForum. Page generated in 0.02785 seconds