Return-Path: Delivered-To: apmail-harmony-commits-archive@www.apache.org Received: (qmail 69355 invoked from network); 27 Apr 2009 11:42:01 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 27 Apr 2009 11:42:01 -0000 Received: (qmail 39004 invoked by uid 500); 27 Apr 2009 11:42:01 -0000 Delivered-To: apmail-harmony-commits-archive@harmony.apache.org Received: (qmail 38949 invoked by uid 500); 27 Apr 2009 11:42:01 -0000 Mailing-List: contact commits-help@harmony.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@harmony.apache.org Delivered-To: mailing list commits@harmony.apache.org Received: (qmail 38940 invoked by uid 99); 27 Apr 2009 11:42:01 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 27 Apr 2009 11:42:00 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 27 Apr 2009 11:41:58 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id A56CE23889DE; Mon, 27 Apr 2009 11:41:37 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r768935 - in /harmony/enhanced/classlib/trunk/modules/luni/src: main/java/java/util/StringTokenizer.java test/api/common/org/apache/harmony/luni/tests/java/util/StringTokenizerTest.java Date: Mon, 27 Apr 2009 11:41:37 -0000 To: commits@harmony.apache.org From: tellison@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090427114137.A56CE23889DE@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: tellison Date: Mon Apr 27 11:41:37 2009 New Revision: 768935 URL: http://svn.apache.org/viewvc?rev=768935&view=rev Log: Apply patch for HARMONY-6142 ([classlib][luni] java.util.StringTokenizer.nextToken(String delim) should throw NullPointerException when the given delim is null) Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/StringTokenizer.java harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/StringTokenizerTest.java Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/StringTokenizer.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/StringTokenizer.java?rev=768935&r1=768934&r2=768935&view=diff ============================================================================== --- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/StringTokenizer.java (original) +++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/StringTokenizer.java Mon Apr 27 11:41:37 2009 @@ -124,6 +124,9 @@ * @return true if unprocessed tokens remain */ public boolean hasMoreTokens() { + if (delimiters == null) { + throw new NullPointerException(); + } int length = string.length(); if (position < length) { if (returnDelimiters) @@ -157,6 +160,9 @@ * if no tokens remain */ public String nextToken() { + if (delimiters == null) { + throw new NullPointerException(); + } int i = position; int length = string.length(); Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/StringTokenizerTest.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/StringTokenizerTest.java?rev=768935&r1=768934&r2=768935&view=diff ============================================================================== --- harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/StringTokenizerTest.java (original) +++ harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/StringTokenizerTest.java Mon Apr 27 11:41:37 2009 @@ -167,6 +167,92 @@ "es", st.nextToken()); } + public void test_hasMoreElements_NPE() { + StringTokenizer stringTokenizer = new StringTokenizer(new String(), + (String) null, true); + try { + stringTokenizer.hasMoreElements(); + fail("should throw NullPointerException"); + } catch (NullPointerException e) { + // Expected + } + + stringTokenizer = new StringTokenizer(new String(), (String) null); + try { + stringTokenizer.hasMoreElements(); + fail("should throw NullPointerException"); + } catch (NullPointerException e) { + // Expected + } + } + + public void test_hasMoreTokens_NPE() { + StringTokenizer stringTokenizer = new StringTokenizer(new String(), + (String) null, true); + try { + stringTokenizer.hasMoreTokens(); + fail("should throw NullPointerException"); + } catch (NullPointerException e) { + // Expected + } + + stringTokenizer = new StringTokenizer(new String(), (String) null); + try { + stringTokenizer.hasMoreTokens(); + fail("should throw NullPointerException"); + } catch (NullPointerException e) { + // Expected + } + } + + public void test_nextElement_NPE() { + StringTokenizer stringTokenizer = new StringTokenizer(new String(), + (String) null, true); + try { + stringTokenizer.nextElement(); + fail("should throw NullPointerException"); + } catch (NullPointerException e) { + // Expected + } + + stringTokenizer = new StringTokenizer(new String(), (String) null); + try { + stringTokenizer.nextElement(); + fail("should throw NullPointerException"); + } catch (NullPointerException e) { + // Expected + } + } + + public void test_nextToken_NPE() { + StringTokenizer stringTokenizer = new StringTokenizer(new String(), + (String) null, true); + try { + stringTokenizer.nextToken(); + fail("should throw NullPointerException"); + } catch (NullPointerException e) { + // Expected + } + + stringTokenizer = new StringTokenizer(new String(), (String) null); + try { + stringTokenizer.nextToken(); + fail("should throw NullPointerException"); + } catch (NullPointerException e) { + // Expected + } + } + + public void test_nextTokenLjava_lang_String_NPE() { + StringTokenizer stringTokenizer = new StringTokenizer(new String()); + try { + stringTokenizer.nextToken(null); + fail("should throw NullPointerException"); + } catch (NullPointerException e) { + // Expected + } + } + /** * Sets up the fixture, for example, open a network connection. This method * is called before a test is executed.