Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 344391 - [evaluator] Tuples containing null values cause exceptions
Summary: [evaluator] Tuples containing null values cause exceptions
Status: CLOSED FIXED
Alias: None
Product: OCL
Classification: Modeling
Component: Core (show other bugs)
Version: 3.0.0   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 3.1.0   Edit
Assignee: OCL Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 342644
Blocks:
  Show dependency tree
 
Reported: 2011-05-01 04:38 EDT by Axel Uhl CLA
Modified: 2012-05-29 13:21 EDT (History)
1 user (show)

See Also:


Attachments
GIT patch fixing the Tuple-null problem, with tests (260.22 KB, patch)
2011-05-01 05:32 EDT, Axel Uhl CLA
no flags Details | Diff
CVS patch containing the same fix as 194440 (7.15 KB, patch)
2011-05-01 06:59 EDT, Axel Uhl CLA
no flags Details | Diff
Patch for underlying EMF bug (2.01 KB, patch)
2011-05-01 07:57 EDT, Ed Willink CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Axel Uhl CLA 2011-05-01 04:38:44 EDT
Here's an additional test case for TupleTest that fails so far.

        public void test_tupleLiteral_nullValues() {
                // one part
                assertEquals(null, evaluate(parse(
                        "package ocltest context Fruit " +
                        "inv: Tuple{a = null}.a " +
                        "endpackage")));
                assertEquals(null, evaluate(parse(
                        "package ocltest context Fruit " +
                        "inv: Tuple{a:OclVoid = null}.a " +
                        "endpackage")));
                assertEquals(null, evaluate(parse(
                        "package ocltest context Fruit " +
                        "inv: Tuple{a:String = null}.a " +
                        "endpackage")));
                assertEquals(null, evaluate(parse(
                        "package ocltest context Fruit " +
                        "inv: Tuple{a:Fruit = null}.a " +
                        "endpackage")));

                // multiple parts
                assertEquals(1, evaluate(parse(
                        "package ocltest context Fruit " +
                        "inv: Tuple{a = null, b=1}.b " +
                        "endpackage")));
                assertEquals(null, evaluate(parse(
                        "package ocltest context Fruit " +
                        "inv: Tuple{a = null, b=1}.a " +
                        "endpackage")));
                assertEquals(null, evaluate(parse(
                        "package ocltest context Fruit " +
                        "inv: Tuple{a:String = null, b='abc'}.a " +
                        "endpackage")));
                assertEquals("abc", evaluate(parse(
                        "package ocltest context Fruit " +
                        "inv: Tuple{a:String = null, b='abc'}.b " +
                        "endpackage")));
                assertEquals(null, evaluate(parse(
                        "package ocltest context Fruit " +
                        "inv: Tuple{a:Fruit = null, b:String='abc'}.a " +
                        "endpackage")));
                assertEquals(null, evaluate(parse(
                        "package ocltest context Fruit " +
                        "inv: Tuple{a:Fruit = null, b:OclVoid=null}.b " +
                        "endpackage")));
        }

The null values cause ClassCastExceptions with VoidTypeImpl not conforming to EClass. A fix has to avoid actually invoking the setting delegate for OclVoid-typed tuple components, for both reading and creating.
Comment 1 Axel Uhl CLA 2011-05-01 04:39:54 EDT
Adding dependency on 342644 because a patch will be relative to the patch for 342644
Comment 2 Axel Uhl CLA 2011-05-01 05:32:03 EDT
Created attachment 194440 [details]
GIT patch fixing the Tuple-null problem, with tests

Extracts the now reverted changes of 342644 that fix the issue, including new and now again uncommented tests.

Apply the fix after applying attachment 194438 [details] of 342644, ignoring the first two path elements.
Comment 3 Axel Uhl CLA 2011-05-01 06:59:11 EDT
Created attachment 194443 [details]
CVS patch containing the same fix as 194440

Fixes the Tuple/null issue, includes test cases
Comment 4 Ed Willink CLA 2011-05-01 07:57:49 EDT
Created attachment 194447 [details]
Patch for underlying EMF bug

The VoidType guard is indeed a fix for the wrong bug.

The true bug is in EMF that assumes that setting delegates are for EClass, when setting delegates for EAttributes may have EClassifier types to which VoidType conforms.

Please raise the EMF bug, then +1 to commit after re-commenting the eSet and eGet guards as workarounds for the EMF Bug number.
Comment 5 Axel Uhl CLA 2011-05-01 08:12:17 EDT
Enhanced comment, pointing to new EMF bug 344395. Committed to CVS HEAD.
Comment 6 Ed Willink CLA 2012-05-29 13:21:34 EDT
Closing all bugs resolved in Indigo.