You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commons-dev@ws.apache.org by "Davanum Srinivas (JIRA)" <ji...@apache.org> on 2007/06/19 04:57:26 UTC
[jira] Commented: (WSCOMMONS-189) NamespaceImpl and OMNamespaceImpl
violate hashCode contract
[ https://issues.apache.org/jira/browse/WSCOMMONS-189?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12506011 ]
Davanum Srinivas commented on WSCOMMONS-189:
--------------------------------------------
Fixed in svn revision 548566
thanks,
dims
> NamespaceImpl and OMNamespaceImpl violate hashCode contract
> -----------------------------------------------------------
>
> Key: WSCOMMONS-189
> URL: https://issues.apache.org/jira/browse/WSCOMMONS-189
> Project: WS-Commons
> Issue Type: Bug
> Components: AXIOM
> Reporter: Alexander Veit
>
> As the following test case shows, NamespaceImpl and OMNamespaceImpl violate the java.lang.Object contract between equals and hashCode.
> Additionally, if the test would turn from red to green, it would suggest to deprecate NamespaceImpl and OMNamespaceImpl, and to make OMNamespace a concrete class that would eventually replace NamespaceImpl and OMNamespaceImpl.
> public final class NamespaceImplTestCase extends junit.framework.TestCase
> {
> public void testEqualsHashCodeContract()
> {
> assertEquals(
> new org.apache.axiom.om.impl.dom.NamespaceImpl("anyURI"),
> new org.apache.axiom.om.impl.dom.NamespaceImpl("anyURI"));
> assertEquals(
> new org.apache.axiom.om.impl.dom.NamespaceImpl("anyURI", "prefix"),
> new org.apache.axiom.om.impl.dom.NamespaceImpl("anyURI", "prefix"));
> assertEquals(
> new org.apache.axiom.om.impl.OMNamespaceImpl("anyURI", "prefix"),
> new org.apache.axiom.om.impl.OMNamespaceImpl("anyURI", "prefix"));
> assertEquals(
> new org.apache.axiom.om.impl.dom.NamespaceImpl("anyURI", "prefix"),
> new org.apache.axiom.om.impl.OMNamespaceImpl("anyURI", "prefix"));
> assertEquals(
> new org.apache.axiom.om.impl.OMNamespaceImpl("anyURI", "prefix"),
> new org.apache.axiom.om.impl.dom.NamespaceImpl("anyURI", "prefix"));
> assertEquals(
> new org.apache.axiom.om.impl.dom.NamespaceImpl("anyURI").hashCode(),
> new org.apache.axiom.om.impl.dom.NamespaceImpl("anyURI").hashCode());
> assertEquals(
> new org.apache.axiom.om.impl.dom.NamespaceImpl("anyURI", "prefix").hashCode(),
> new org.apache.axiom.om.impl.dom.NamespaceImpl("anyURI", "prefix").hashCode());
> assertEquals(
> new org.apache.axiom.om.impl.OMNamespaceImpl("anyURI", "prefix").hashCode(),
> new org.apache.axiom.om.impl.OMNamespaceImpl("anyURI", "prefix").hashCode());
> }
> }
> Patch: add
> public int hashCode() {
> return uri.hashCode() ^ (prefix != null ? prefix.hashCode() : 0);
> }
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: commons-dev-help@ws.apache.org