Community
Participate
Working Groups
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'
OK, it seems FindBus has reported a wrong issue.
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!)
New Gerrit change created: https://git.eclipse.org/r/59027
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)
Gerrit change https://git.eclipse.org/r/59027 was merged to [master]. Commit: http://git.eclipse.org/c/xwt/org.eclipse.xwt.git/commit/?id=be824a5237210f10f6512073e6b21d33a0e06ff7