Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 351067 - Exception adding the same Blob data
Summary: Exception adding the same Blob data
Status: CLOSED FIXED
Alias: None
Product: EMF
Classification: Modeling
Component: cdo.core (show other bugs)
Version: 4.1   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Egidijus Vaisnora CLA
QA Contact: Eike Stepper CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-07-04 06:47 EDT by Egidijus Vaisnora CLA
Modified: 2012-09-21 07:18 EDT (History)
0 users

See Also:
stepper: review+


Attachments
test case v1 (2.42 KB, patch)
2011-07-04 06:49 EDT, Egidijus Vaisnora CLA
no flags Details | Diff
test case+patch (3.76 KB, patch)
2011-07-04 09:16 EDT, Egidijus Vaisnora CLA
no flags Details | Diff
Alternative fix v1 (7.33 KB, patch)
2011-07-04 13:56 EDT, Eike Stepper CLA
no flags Details | Diff
fix v2 (5.89 KB, patch)
2011-07-05 06:07 EDT, Egidijus Vaisnora CLA
no flags Details | Diff
Alternative fix v3 (7.85 KB, patch)
2011-07-05 06:38 EDT, Eike Stepper CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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.