[
https://issues.apache.org/jira/browse/WSCOMMONS-189?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12486049
]
Glen Daniels commented on WSCOMMONS-189:
----------------------------------------
>suggest to deprecate NamespaceImpl and OMNamespaceImpl, and to make
>OMNamespace a concrete class that would eventually replace NamespaceImpl and
>OMNamespaceImpl
This is a general direction I WHOLEHEARTEDLY support - the fewer factories and
forests of repeated implementation classes the better (IMHO the current state
of Axiom is a maintenance nightmare). +1 to start with OMNamespace and make it
an easy-to-use concrete class.
> 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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]