Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 351067

Summary: Exception adding the same Blob data
Product: [Modeling] EMF Reporter: Egidijus Vaisnora <vaisegid>
Component: cdo.coreAssignee: Egidijus Vaisnora <vaisegid>
Status: CLOSED FIXED QA Contact: Eike Stepper <stepper>
Severity: normal    
Priority: P3 Flags: stepper: review+
Version: 4.1   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
test case v1
none
test case+patch
none
Alternative fix v1
none
fix v2
none
Alternative fix v3 none

Description Egidijus Vaisnora CLA 2011-07-04 06:47:07 EDT
Adding the same image second time exception is thrown from DB:

"The statement was aborted because it would have caused a duplicate key value in a unique or primary key constraint or unique index identified by 'CDO_LOBS_IDX0' defined on 'CDO_LOBS'."
Comment 1 Egidijus Vaisnora CLA 2011-07-04 06:49:04 EDT
Created attachment 199039 [details]
test case v1

Test case illustrating problem
Comment 2 Egidijus Vaisnora CLA 2011-07-04 09:16:05 EDT
Created attachment 199048 [details]
test case+patch

Byte array was used as map key. Array by itselv doesn't construct hashcode from the arrays values. It means values are the same but array object is different
Comment 3 Eike Stepper CLA 2011-07-04 13:56:43 EDT
Created attachment 199066 [details]
Alternative fix v1
Comment 4 Eike Stepper CLA 2011-07-04 13:59:10 EDT
While my alternative version of a fix is slightly more code but I think it's cleaner because duplicates are already prevented in the "lobs" map.

That said, both our fixes make the reading cases in LobTest fail. Can you have a look at it?
Comment 5 Egidijus Vaisnora CLA 2011-07-05 02:57:22 EDT
Patch seems to be good :)
Comment 6 Eike Stepper CLA 2011-07-05 02:58:18 EDT
What about the test failures?
Comment 7 Egidijus Vaisnora CLA 2011-07-05 06:07:06 EDT
Created attachment 199105 [details]
fix v2

Includes MEMStore fix
Comment 8 Egidijus Vaisnora CLA 2011-07-05 06:13:18 EDT
There are lines in test: "new java.io.File(CDOLobStoreImpl.INSTANCE.getFolder(), "5ef5685c7036c7fc8cafac1d54b91b4e06d9de4e.clob").delete();" Eike, could you take a look to this line. If it is still makes what expected? For me such file doesn't exist always
Comment 9 Eike Stepper CLA 2011-07-05 06:31:48 EDT
Committed revision 8597

I've enhanced the test case so that it uses the lob ID actually computed for a Lob rather than a fixed ID that was valid at the time when the test was originally developed.
Comment 10 Eike Stepper CLA 2011-07-05 06:38:46 EDT
Created attachment 199106 [details]
Alternative fix v3

With ByteArrayWrapper
Comment 11 Egidijus Vaisnora CLA 2011-07-05 06:48:34 EDT
Committed to trunk, revision 8598
Comment 12 Eike Stepper CLA 2012-09-21 07:18:51 EDT
Closing.