Return-Path: Delivered-To: apmail-directory-dev-archive@www.apache.org Received: (qmail 48643 invoked from network); 5 Jun 2010 15:56:17 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 5 Jun 2010 15:56:17 -0000 Received: (qmail 31264 invoked by uid 500); 5 Jun 2010 15:56:17 -0000 Delivered-To: apmail-directory-dev-archive@directory.apache.org Received: (qmail 31216 invoked by uid 500); 5 Jun 2010 15:56:17 -0000 Mailing-List: contact dev-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Apache Directory Developers List" Delivered-To: mailing list dev@directory.apache.org Received: (qmail 31209 invoked by uid 99); 5 Jun 2010 15:56:17 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 05 Jun 2010 15:56:17 +0000 X-ASF-Spam-Status: No, hits=-1500.2 required=10.0 tests=ALL_TRUSTED,AWL X-Spam-Check-By: apache.org Received: from [140.211.11.22] (HELO thor.apache.org) (140.211.11.22) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 05 Jun 2010 15:56:16 +0000 Received: from thor (localhost [127.0.0.1]) by thor.apache.org (8.13.8+Sun/8.13.8) with ESMTP id o55FtuEO023082 for ; Sat, 5 Jun 2010 15:55:56 GMT Message-ID: <10076004.199171275753356330.JavaMail.jira@thor> Date: Sat, 5 Jun 2010 11:55:56 -0400 (EDT) From: "Felix Knecht (JIRA)" To: dev@directory.apache.org Subject: [jira] Updated: (DIRSERVER-1516) Classes implementing compareTo should also implement equals (and thus hashCode) In-Reply-To: <26337338.197101275718587560.JavaMail.jira@thor> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/DIRSERVER-1516?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Felix Knecht updated DIRSERVER-1516: ------------------------------------ Description: Following classes are lacking this problem [apacheds-protocol-dhcp] org.apache.directory.server.dhcp.messages.MessageType [apacheds-protocol-ntp] org.apache.directory.server.ntp.messages.LeapIndicatorType org.apache.directory.server.ntp.messages.ModeType org.apache.directory.server.ntp.messages.ReferenceIdentifier org.apache.directory.server.ntp.messages.StratumType http://findbugs.sourceforge.net/bugDescriptions.html#EQ_COMPARETO_USE_OBJECT_EQUALS This class defines a compareTo(...) method but inherits its equals() method from java.lang.Object. Generally, the value of compareTo should return zero if and only if equals returns true. If this is violated, weird and unpredictable failures will occur in classes such as PriorityQueue. In Java 5 the PriorityQueue.remove method uses the compareTo method, while in Java 6 it uses the equals method. >From the JavaDoc for the compareTo method in the Comparable interface: It is strongly recommended, but not strictly required that (x.compareTo(y)==0) == (x.equals(y)). Generally speaking, any class that implements the Comparable interface and violates this condition should clearly indicate this fact. The recommended language is "Note: this class has a natural ordering that is inconsistent with equals." was: Following classes are lacking this problem [apacheds-protocol-ntp] org.apache.directory.server.ntp.messages.LeapIndicatorType org.apache.directory.server.ntp.messages.ModeType org.apache.directory.server.ntp.messages.ReferenceIdentifier org.apache.directory.server.ntp.messages.StratumType http://findbugs.sourceforge.net/bugDescriptions.html#EQ_COMPARETO_USE_OBJECT_EQUALS This class defines a compareTo(...) method but inherits its equals() method from java.lang.Object. Generally, the value of compareTo should return zero if and only if equals returns true. If this is violated, weird and unpredictable failures will occur in classes such as PriorityQueue. In Java 5 the PriorityQueue.remove method uses the compareTo method, while in Java 6 it uses the equals method. >From the JavaDoc for the compareTo method in the Comparable interface: It is strongly recommended, but not strictly required that (x.compareTo(y)==0) == (x.equals(y)). Generally speaking, any class that implements the Comparable interface and violates this condition should clearly indicate this fact. The recommended language is "Note: this class has a natural ordering that is inconsistent with equals." > Classes implementing compareTo should also implement equals (and thus hashCode) > ------------------------------------------------------------------------------- > > Key: DIRSERVER-1516 > URL: https://issues.apache.org/jira/browse/DIRSERVER-1516 > Project: Directory ApacheDS > Issue Type: Bug > Environment: All > Reporter: Felix Knecht > > Following classes are lacking this problem > [apacheds-protocol-dhcp] > org.apache.directory.server.dhcp.messages.MessageType > [apacheds-protocol-ntp] > org.apache.directory.server.ntp.messages.LeapIndicatorType > org.apache.directory.server.ntp.messages.ModeType > org.apache.directory.server.ntp.messages.ReferenceIdentifier > org.apache.directory.server.ntp.messages.StratumType > http://findbugs.sourceforge.net/bugDescriptions.html#EQ_COMPARETO_USE_OBJECT_EQUALS > This class defines a compareTo(...) method but inherits its equals() method from java.lang.Object. Generally, the value of compareTo should return zero if and only if equals returns true. If this is violated, weird and unpredictable failures will occur in classes such as PriorityQueue. In Java 5 the PriorityQueue.remove method uses the compareTo method, while in Java 6 it uses the equals method. > From the JavaDoc for the compareTo method in the Comparable interface: > It is strongly recommended, but not strictly required that (x.compareTo(y)==0) == (x.equals(y)). Generally speaking, any class that implements the Comparable interface and violates this condition should clearly indicate this fact. The recommended language is "Note: this class has a natural ordering that is inconsistent with equals." -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.