Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 4667036
Votes 1
Synopsis StringTokenizer constructor does not catch null delimiter string
Category java:classes_util
Reported Against 1.4
Release Fixed 1.4.2(mantis)
State 10-Fix Delivered, Verified, bug
Priority: 4-Low
Related Bugs
Submit Date 12-APR-2002
Description




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  customer .

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) 
======================================================================
Work Around
N/A
Evaluation
The specification is not clear about where the NPE should be thrown.  Neither
the constructor or countTokens() is specified to throw it.

--   xxxxx@xxxxx   2002-04-11

This oddity will be mentioned in the spec. We won't change the behavior of this legacy class.

  xxxxx@xxxxx   2002-10-15
Comments
  
  Include a link with my name & email   


PLEASE NOTE: JDK6 is formerly known as Project Mustang