Skip to main content


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 21:16 Go to next message
Ray Braithwood is currently offline Ray BraithwoodFriend
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] Fri, 28 December 2012 04:28 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6690
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 16:37 Go to previous message
Ray Braithwood is currently offline Ray BraithwoodFriend
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: Thu Sep 19 17:15:05 GMT 2024

Powered by FUDForum. Page generated in 0.03431 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top