JDK-6405742 : Timestamp.valueOf() throws ArrayIndexOutOfBoundsException instead of IllegalArgumentException
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.sql
  • Affected Version: 6
  • Priority: P2
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 2006-03-29
  • Updated: 2011-02-16
  • Resolved: 2006-03-31
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.
JDK 6
6Resolved
Related Reports
Duplicate :  
Description
Try the following code:
package javasoft.sqe.tests.api.java.sql.Timestamp;

import java.io.PrintWriter;
import java.sql.*;
import javasoft.sqe.javatest.Status;
import javasoft.sqe.javatest.lib.MultiTest;


public class ValueOfTests extends MultiTest {

public Status tryValue(String value) {
      String s=null;           //step Create null reference
      try { 
        Timestamp t = Timestamp.valueOf(value);  //step Try to create Timestamp
        ref.println("Test failed, valueOf(null) = " + t);
        return Status.failed( "Failed" );
      }
      catch (IllegalArgumentException e) //step Catch an Exception
      { ref.println(e);
        return Status.passed( "OKAY" );
      }
   }

    /* standalone interface */
    public static void main(String argv[]) {
        ValueOfTests test = new ValueOfTests();
        test.run(argv, System.err, System.out).exit();
    }


    /**
     * Equivalence class partitioning
     * with input values orientation
     * for public Timestamp valueOf(String s),
     * <br><b>s</b>: invalid string (more arguments than needed).
     * <br><b>Expected results</b>: Will return true
     */
    public Status Timestamp0020() {
        String testCaseID = "Timestamp0020";
          ref.println("====== "+testCaseID+" ======");
          return tryValue("1996-10-10 12:30:40:50"); //step Try value
    }

}



Timestamp0017: Passed. OKAY
Timestamp0018: Passed. OKAY
Timestamp0019: Passed. OKAY
java.lang.ArrayIndexOutOfBoundsException: 3
	at java.sql.Timestamp.valueOf(Timestamp.java:202)
	at javasoft.sqe.tests.api.java.sql.Timestamp.ValueOfTests.tryValue(ValueOfTests.java:28)
	at javasoft.sqe.tests.api.java.sql.Timestamp.ValueOfTests.Timestamp0020(ValueOfTests.java:100)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:589)
	at javasoft.sqe.javatest.lib.MultiTest.invokeTestCase(MultiTest.java:399)
	at javasoft.sqe.javatest.lib.MultiTest.run(MultiTest.java:195)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:589)
	at com.sun.jck.lib.ExecJCKTestSameJVMCmd$Version2Test.execute(ExecJCKTestSameJVMCmd.java:437)
	at com.sun.jck.lib.ExecJCKTestSameJVMCmd$StandardTest.run(ExecJCKTestSameJVMCmd.java:349)
	at com.sun.jck.lib.ExecJCKTestSameJVMCmd.execute(ExecJCKTestSameJVMCmd.java:226)
	at com.sun.jck.lib.ExecJCKTestSameJVMCmd.run(ExecJCKTestSameJVMCmd.java:140)
	at com.sun.javatest.agent.Agent$Task.executeCommand(Agent.java:818)
	at com.sun.javatest.agent.Agent$Task.execute(Agent.java:749)
	at com.sun.javatest.agent.Agent$Task.handleRequest(Agent.java:610)
	at com.sun.javatest.agent.Agent.handleRequestsUntilClosed(Agent.java:377)
	at com.sun.javatest.agent.Agent.access$000(Agent.java:41)
	at com.sun.javatest.agent.Agent$1.run(Agent.java:253)
	at java.lang.Thread.run(Thread.java:626)
Timestamp0020: Failed. Test case throws exception: java.lang.ArrayIndexOutOfBoundsException: 3
Timestamp0021: Passed. OKAY