Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 348483 - [Validation] UnsupportedOperationException when validating project aggregated binary objects
Summary: [Validation] UnsupportedOperationException when validating project aggregated...
Status: RESOLVED FIXED
Alias: None
Product: Dali JPA Tools
Classification: WebTools
Component: JPA (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 7
: P2 normal (vote)
Target Milestone: 3.2 RC1   Edit
Assignee: Brian Vosburgh CLA
QA Contact:
URL:
Whiteboard: PMC
Keywords:
Depends on:
Blocks:
 
Reported: 2011-06-06 18:41 EDT by Nan Li CLA
Modified: 2012-05-16 17:09 EDT (History)
6 users (show)

See Also:
neil.hauge: pmc_approved? (david_williams)
raghunathan.srinivasan: pmc_approved+
neil.hauge: pmc_approved? (naci.dai)
neil.hauge: pmc_approved? (deboer)
neil.hauge: pmc_approved? (neil.hauge)
neil.hauge: pmc_approved? (kaloyan)
neil.hauge: pmc_approved? (cbridgha)
neil.hauge: review+


Attachments
proposed patch (16.17 KB, patch)
2012-05-16 11:00 EDT, Brian Vosburgh CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Nan Li CLA 2011-06-06 18:41:50 EDT
Build Identifier: I20110526-1708

Currently, we don't support validation for binary sources since we can do nothing to fix the problems reported; however, we can get UnsupportedOperationException with our current code. E.g. if we have two generators with the same name and one of generators is in the jar file, , we'll get the exception below. 

----------------
java.lang.UnsupportedOperationException
	at org.eclipse.jpt.jpa.core.internal.resource.java.binary.BinaryGeneratorAnnotation.getNameTextRange(BinaryGeneratorAnnotation.java:76)
	at org.eclipse.jpt.jpa.core.internal.context.java.AbstractJavaGenerator.getNameTextRange(AbstractJavaGenerator.java:187)
	at org.eclipse.jpt.jpa.core.internal.context.persistence.AbstractPersistenceUnit.extractNameTextRange(AbstractPersistenceUnit.java:2379)
	at org.eclipse.jpt.jpa.core.internal.context.persistence.AbstractPersistenceUnit.checkForDuplicateGenerators(AbstractPersistenceUnit.java:2367)
----------------

The solution could be 1) giving more comprehensive messages to the problems reported against sources indicating the problems co-exist with jar files; 2) making the resource of the problems reported again jar files be the jar file refer entries of the persistence.xml. 

We need a general solution for this.

Reproducible: Always
Comment 1 Neil Hauge CLA 2011-07-01 16:23:46 EDT
Moving JPA specific bugs to new JPA component in bugzilla.
Comment 2 Neil Hauge CLA 2011-10-07 12:52:05 EDT
Targeting to Juno release.
Comment 3 Paul Fullbright CLA 2011-12-14 15:06:01 EST
This happens when creating validation errors for any of our project-aggregated objects:
- queries
- generators
- (eclipselink) converters
Comment 4 Neil Hauge CLA 2012-05-09 11:28:40 EDT
Not sure if there is something easy we can do to improve this situation for Juno.  Perhaps we could change the binary annotations to route these messages to the jar file resource in question, which is I think what we used to do.  It seems to me that it would be nice to report these types of errors, especially errors involving globals that would only be discovered upon specifying a jar file reference.  Perhaps we should only route these types of errors to the jars, and ignore the rest, as there would be little context to work with.  Maybe that was the intent here all along.
Comment 5 Brian Vosburgh CLA 2012-05-16 10:59:35 EDT
The same code (related to queries, generators, and EclipseLink converters) that causes this exception with binary Java objects also puts markers in Java source code in projects that are on the JPA project's build path.
Comment 6 Brian Vosburgh CLA 2012-05-16 11:00:59 EDT
Created attachment 215716 [details]
proposed patch

More hacking, until we figure out how we want to validate binary and extra-project Java classes.
Comment 7 Neil Hauge CLA 2012-05-16 12:37:10 EDT
This case actually prevents the user from getting any validation, and this error message won't be a good clue to figure out what has gone wrong.  This ups the relative severity of this bug.
Comment 8 Neil Hauge CLA 2012-05-16 13:33:23 EDT
Nan...can you do some testing with Brian's patch?
Comment 9 Nan Li CLA 2012-05-16 15:51:45 EDT
Tested the patch and it works fine. We will only get validation message for the
duplicates in the source code and ignore the duplicates in the binary code.
Comment 10 Neil Hauge CLA 2012-05-16 17:03:28 EDT
    Explain why you believe this is a stop-ship defect. Or, if it is a "hotbug" (requested by an adopter) please document it as such. 

In the case were binary content has a Dali error, validation may break, resulting in no Dali validation errors being reported.

    Is there a work-around? If so, why do you believe the work-around is insufficient? 

Workaround is to fix error in binary content, but this would not be obvious.

    How has the fix been tested? Is there a test case attached to the bugzilla record? Has a JUnit Test been added? 

Manual tests have been performed and the automated tests have been run.

    Give a brief technical overview. Who has reviewed this fix? 

This code makes a simple determination on whether a given validation message should be added based on the type of resource involved.  If the resource in binary, we simply don't add the validation message.  

    What is the risk associated with this fix? 

Fix is isolated and fairly low risk.
Comment 11 Brian Vosburgh CLA 2012-05-16 17:09:06 EDT
Patch checked into HEAD for RC1.