JDK-4667036 : StringTokenizer constructor does not catch null delimiter string
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util
  • Affected Version: 1.4.0
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: linux
  • CPU: x86
  • Submitted: 2002-04-12
  • Updated: 2002-11-11
  • Resolved: 2002-10-26
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
1.4.2 mantisFixed
Description

Name: gm110360			Date: 04/11/2002


FULL PRODUCT VERSION :
bash-2.04$ java -version
java version "1.3.1"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1-b24)
Java HotSpot(TM) Client VM (build 1.3.1-b24, mixed mode)



FULL OPERATING SYSTEM VERSION :

Linux niall.rococosoft.com 2.4.17 #4 SMP Tue Jan 29 15:28:00
GMT 2002 i686 unknown

A DESCRIPTION OF THE PROBLEM :

The StringTokenizers constructors which take a delimiter
string do not check if the string is null, causing an
unexpected and inappropriate NullPointerException later when
one of the string tokeniser methods are called.

The javadocs also need to be updated to record this exception.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. javac test.java
2. java -cp . test
3.

EXPECTED VERSUS ACTUAL BEHAVIOR :

I expect a NullPointerException from the constructor,
prevening creation of the object.

This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.util.*;

public class test
{
        public static void main(String[] args)
                throws Throwable
        {
                StringTokenizer st = new StringTokenizer("foo", null, false);

                System.err.println(st.countTokens());
        }
}

---------- END SOURCE ----------
(Review ID: 145287) 
======================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: mantis FIXED IN: mantis INTEGRATED IN: mantis mantis-b05 VERIFIED IN: mantis
2004-06-14

EVALUATION The specification is not clear about where the NPE should be thrown. Neither the constructor or countTokens() is specified to throw it. -- iag@sfbay 2002-04-11 This oddity will be mentioned in the spec. We won't change the behavior of this legacy class. ###@###.### 2002-10-15
2002-04-11