Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 312293 - Spurious assertion failures ("Element namespace is defined")
Summary: Spurious assertion failures ("Element namespace is defined")
Status: NEW
Alias: None
Product: XWT
Classification: Technology
Component: Core (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-05-10 12:21 EDT by Peter Keller CLA
Modified: 2016-02-23 16:51 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Peter Keller CLA 2010-05-10 12:21:00 EDT
Build Identifier: Trunk

Some assert statements have the inverse of the required condition. The cases that I have identified (in org.eclipse.e4.xwt.internal.xml) are:

cvs diff: Diffing .
Index: DocumentObject.java
===================================================================
RCS file: /cvsroot/eclipse/e4/org.eclipse.e4.xwt/bundles/org.eclipse.e4.xwt/src/org/eclipse/e4/xwt/internal/xml/DocumentObject.java,v
retrieving revision 1.2
diff -u -r1.2 DocumentObject.java
--- DocumentObject.java	22 Apr 2010 00:59:15 -0000	1.2
+++ DocumentObject.java	10 May 2010 16:16:31 -0000
@@ -195,7 +195,7 @@
 	 */
 	protected void setNamespace(String namespace) {
 		assert namespace != null : "Element namespace is null";
-		assert this.namespace != null : "Element namepsace is defined";
+		assert this.namespace == null : "Element namepsace is defined";
 
 		this.namespace = namespace;
 	}
@@ -207,7 +207,7 @@
 	 */
 	protected void setName(String name) {
 		assert name != null : "Element name is null";
-		assert this.name != null : "Element name is defined";
+		assert this.name == null : "Element name is defined";
 
 		this.name = name;
 	}
Index: ElementManager.java
===================================================================
RCS file: /cvsroot/eclipse/e4/org.eclipse.e4.xwt/bundles/org.eclipse.e4.xwt/src/org/eclipse/e4/xwt/internal/xml/ElementManager.java,v
retrieving revision 1.4
diff -u -r1.4 ElementManager.java
--- ElementManager.java	3 May 2010 22:01:50 -0000	1.4
+++ ElementManager.java	10 May 2010 16:16:32 -0000
@@ -320,7 +320,7 @@
 	 */
 	protected void preElement(Element element) {
 		assert element != null;
-		assert elements.containsKey(element.getId()) : "Element already exists in registry: "
+		assert !elements.containsKey(element.getId()) : "Element already exists in registry: "
 				+ element.getId();
 
 		// Add to cache.
@@ -337,7 +337,7 @@
 	 */
 	protected void postElement(Element element) {
 		assert element != null;
-		assert !elements.containsKey(element.getId()) : "Element not found in registry: "
+		assert elements.containsKey(element.getId()) : "Element not found in registry: "
 				+ element.getId();
 		if ("xdata".equalsIgnoreCase(element.getName())
 				&& IConstants.XWT_X_NAMESPACE.equals(element.getNamespace())) {


Reproducible: Always

Steps to Reproduce:
1. Launch an application that uses *.xwt files with 'java -ea'
Comment 1 Yves YANG CLA 2010-05-10 13:01:35 EDT
OK, it seems FindBus has reported a wrong issue.
Comment 2 Peter Keller CLA 2010-05-11 05:36:04 EDT
Comparing these two files with earlier revisions in the CVS repository, the four assertions I picked out have always been the wrong way round. It seems to me that FindBugs thought that they were correct and did not suggest changing them (although FindBugs obviously found other cases that did need changing).

IMO testing for correctness of assertions should always include running applications with assertions enabled :-)

(I don't want to sound too critical by the way: I think that XWT and associated work is superb!)
Comment 3 Eclipse Genie CLA 2015-10-27 11:49:50 EDT
New Gerrit change created: https://git.eclipse.org/r/59027
Comment 4 Camille Letavernier CLA 2015-10-27 11:50:18 EDT
Hi,

It seems that these 4 assertions are still inverted, and keep failing whenever the assertions are enabled

https://git.eclipse.org/r/59027 fixes them (+ a typo)