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: 5006540
Votes 0
Synopsis java.sql.Timestamp.valueOf(String) fails to throw an IllegalArgumentException
Category jdbc:implementation
Reported Against b64 , b74 , b75 , 1.4.2
Release Fixed mustang(b78)
State 11-Closed, Verified, bug
Priority: 2-High
Related Bugs 6374053 , 6374055 , 6396111 , 4808845 , 6405742
Submit Date 02-MAR-2004
Description


FULL PRODUCT VERSION :
java version "1.4.1_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_01-b01)
Java HotSpot(TM) Client VM (build 1.4.1_01-b01, mixed mode)

java version "1.4.2"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-b28)
Java HotSpot(TM) Client VM (build 1.4.2-b28, mixed mode)


FULL OS VERSION :
 customer  Windows 2000 [Version 5.00.2195]

A DESCRIPTION OF THE PROBLEM :
According to the API documents of above JDK versions, the static method java.sql.Timestamp.valueOf() should take only JDBC timestamp escape format which is yyyy-mm-dd hh:mm:ss.fffffffff. It throws an IllegalArgumentException if the given argument does not have the format yyyy-mm-dd hh:mm:ss.fffffffff.

In my test with the above versions, I used an invalid argument format "05-2003- customer  0:0:0.0". The expected IllegalArgumentException was not thrown. Instead, the invalid argument was converted to a Timestamp with a String value equals "0171-11- customer  00:00:00.0" under JDK version "1.4.1_01" and "171-11- customer  00:00:00.0" under JDK version "1.3.1_06".



STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile the source code provided below and run under either JDK version "1.4.1_01" or JDK version "1.3.1_06".


EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
An IllegalArgumentException is expected to be thrown.
ACTUAL -
The invalid argument used was converted to a Timestamp with a String value equals "0171-11- customer  00:00:00.0" under JDK version "1.4.1_01" and "171-11- customer  00:00:00.0" under JDK version "1.3.1_06".


REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
public class TestTimestamp {
	public static void main(java.lang.String[] args) {
		System.out.println(java.sql.Timestamp.valueOf("05-2003- customer  0:0:0.0"));
	}
}

---------- END SOURCE ----------
(Incident Review ID: 190668) 
======================================================================
Posted Date : 2005-11-14 19:24:44.0
Work Around
N/A
Evaluation
More checks have been added to check that the String argument if of format 
yyyy-mm-dd hh:mm:ss.fffffffff.

These checks were earlier missing.
Now if the string value is of format e.g. 
yyyy-mm-dd hh:mm:ss.ffffffff i.e. one 'f' less it will throw IllegalArgumentException

It has to be of exactly the same format, if 0's need to be appended or pre pended
they should be appropriately done to match the format.

*** (#1 of 1): [ UNSAVED ]   xxxxx@xxxxx  
Posted Date : 2005-11-15 05:56:22.0

This is being re opened, the behaviour of f's was mandated to be one or more f's now it has been loosened again to 0 or more f's.
Posted Date : 2006-01-02 09:50:48.0

This is strange situation to be in. The fix passes with Derby but fails with Pointbase. It can be that Pointbase doesn't adhere exactly to the spec and at the same time we were not validating the Timestamp string properly.

I have kept the checks for year but have removed the checks for time i.e. checks for yyyy-mm-dd are there but checks for hh:mm:ss.fffffffff have been removed. This removal of check should ensure all are fine. But as of now this is the final check unless verification fails.

After verification, I will close this.
Posted Date : 2006-03-27 05:59:03.0
Comments
  
  Include a link with my name & email   


PLEASE NOTE: JDK6 is formerly known as Project Mustang