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

Bug 351569

Summary: [validator] warn of iteration over null
Product: [Modeling] OCL Reporter: Ed Willink <ed>
Component: CoreAssignee: OCL Inbox <mdt-ocl-inbox>
Status: NEW --- QA Contact:
Severity: enhancement    
Priority: P3    
Version: 3.2.0   
Target Milestone: ---   
Hardware: PC   
OS: Windows Vista   
Whiteboard:
Bug Depends on:    
Bug Blocks: 507628    

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.