Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 351569 - [validator] warn of iteration over null
Summary: [validator] warn of iteration over null
Status: NEW
Alias: None
Product: OCL
Classification: Modeling
Component: Core (show other bugs)
Version: 3.2.0   Edit
Hardware: PC Windows Vista
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: OCL Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 507628
  Show dependency tree
 
Reported: 2011-07-08 09:20 EDT by Ed Willink CLA
Modified: 2016-11-16 13:28 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ed Willink CLA 2011-07-08 09:20:06 EDT
An iteration such as a->collect(b)->collect(c) is required to crash (return invalid) if any b is a null valued object, whereas the same traversal would just skip over the 'problem' wherever b is an empty collection. This is confusing to users since the failure is a data-dependent run-time phenomenon.

The iteration should be rewritten as a->collect(b)->excluding(null)->collect(c).

This hazard can be statically detected and so should provoke a compiler warning. However suppression of the warning is not so easy since for aCollection->collect(c) a warning may be required unless it can be statically determined that aCollection is null-free, which will not always be possible.

Probably better to warn. User can put in a gratuitous excluding(null) particularly if we optimize it to execute in place or even cache non-nullness.