Return-Path: Delivered-To: apmail-incubator-harmony-commits-archive@www.apache.org Received: (qmail 69251 invoked from network); 14 Sep 2006 10:49:17 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 14 Sep 2006 10:49:17 -0000 Received: (qmail 67277 invoked by uid 500); 14 Sep 2006 10:49:17 -0000 Delivered-To: apmail-incubator-harmony-commits-archive@incubator.apache.org Received: (qmail 67179 invoked by uid 500); 14 Sep 2006 10:49:16 -0000 Mailing-List: contact harmony-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: harmony-dev@incubator.apache.org Delivered-To: mailing list harmony-commits@incubator.apache.org Received: (qmail 67168 invoked by uid 99); 14 Sep 2006 10:49:16 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 14 Sep 2006 03:49:16 -0700 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [140.211.166.113] (HELO eris.apache.org) (140.211.166.113) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 14 Sep 2006 03:49:16 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id D86461A981A; Thu, 14 Sep 2006 03:48:49 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r443309 - in /incubator/harmony/enhanced/classlib/trunk/modules/luni/src: main/java/java/util/Collections.java test/java/org/apache/harmony/luni/tests/java/util/CollectionsTest.java Date: Thu, 14 Sep 2006 10:48:49 -0000 To: harmony-commits@incubator.apache.org From: hindessm@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20060914104849.D86461A981A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: hindessm Date: Thu Sep 14 03:48:45 2006 New Revision: 443309 URL: http://svn.apache.org/viewvc?view=rev&rev=443309 Log: Applied patch from "[#HARMONY-1367] [classlib][util] unexpected ClassCastException for Collections.binarySearch(..)". Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Collections.java incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/util/CollectionsTest.java Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Collections.java URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Collections.java?view=diff&rev=443309&r1=443308&r2=443309 ============================================================================== --- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Collections.java (original) +++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Collections.java Thu Sep 14 03:48:45 2006 @@ -1411,6 +1411,10 @@ if (list == null) { throw new NullPointerException(); } + if(list.isEmpty()){ + return -1; + } + Comparable key = (Comparable)object; if (!(list instanceof RandomAccess)) { ListIterator it = (ListIterator)list.listIterator(); Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/util/CollectionsTest.java URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/util/CollectionsTest.java?view=diff&rev=443309&r1=443308&r2=443309 ============================================================================== --- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/util/CollectionsTest.java (original) +++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/util/CollectionsTest.java Thu Sep 14 03:48:45 2006 @@ -61,6 +61,23 @@ int index = Collections.binarySearch(lst, new Integer(2), null); assertEquals(-1, index); } + + /** + * @tests java.util.Collections#binarySearch(java.util.List, + * java.lang.Object) + */ + public void test_binarySearchLjava_util_ListLjava_lang_Object() { + // regression for Harmony-1367 + List localList = new LinkedList(); + assertEquals(-1, Collections.binarySearch(localList, new Object())); + localList.add(new Object()); + try { + Collections.binarySearch(localList, new Integer(1)); + fail("Should throw ClassCastException"); + } catch (ClassCastException e) { + // expected + } + } /** * @tests java.util.Collections#rotate(java.util.List, int)