United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-4667036 : StringTokenizer constructor does not catch null delimiter string

Details
Type:
Bug
Submit Date:
2002-04-12
Status:
Closed
Updated Date:
2002-11-11
Project Name:
JDK
Resolved Date:
2002-10-26
Component:
core-libs
OS:
linux
Sub-Component:
java.util
CPU:
x86
Priority:
P4
Resolution:
Fixed
Affected Versions:
1.4.0
Fixed Versions:
1.4.2 (mantis)

Related Reports

Sub Tasks

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



Hardware and Software, Engineered to Work Together