db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Van Couvering (JIRA)" <derby-...@db.apache.org>
Subject [jira] Updated: (DERBY-1629) StandardException.unexpectedUserException() does not correctly catch internally generated exceptions as of JDK 1.6
Date Wed, 02 Aug 2006 19:42:14 GMT
     [ http://issues.apache.org/jira/browse/DERBY-1629?page=all ]

David Van Couvering updated DERBY-1629:
---------------------------------------

    Description: In Java SE 6 runtime environments, an application may not get the SQL Exception
with SQL State 38000 when execution of a trigger or procedure fails with an exception caused
by Derby internals.  Instead, they will get the underlying exception with it's SQL State.
 For an example of this, see lang/procedureInTrigger.sql, which has different output for Java
SE 6 (encoded in the master/jdk16/procedureInTrigger.out file) than for other Java SE runtimes.
 (was: In non-JDK 1.6 builds, the exceptions Derby throws are all of class EmbedSQLException.
 As of JDK 1.6, that is no longer true.  Instead we throw a "native" SQL Exception.

That makes the following code incorrect:

	public static StandardException unexpectedUserException(Throwable t)
	{
		/*
		** If we have a SQLException that isn't a Util
		** (i.e. it didn't come from cloudscape), then we check
		** to see if it is a valid user defined exception range 
		** (38001-38XXX).  If so, then we convert it into a 
		** StandardException without further ado.
		*/ 
		if ((t instanceof SQLException) &&
		    !(t instanceof EmbedSQLException)) 
		{
			SQLException sqlex  = (SQLException)t;
			String state = sqlex.getSQLState();
			if ((state != null) && 
				(state.length() == 5) &&
				state.startsWith("38") &&
				!state.equals("38000"))
			{
				StandardException se = new StandardException(state, sqlex.getMessage());
				if (sqlex.getNextException() != null)		
				{	
					se.setNestedException(sqlex.getNextException());
				}
				return se;
			}
		}

I am not sure how we can detect internally-thrown SQL Exceptions and distinguish them from
user exceptions, but this does need to be looked at.

Right now procedureInTrigger.sql is failing for JDK 1.6 due to this error.  I may check in
a jdk16-specific version of this file so at least derbyall can pass.
)
     Derby Info: [Existing Application Impact, Regression]

Fixed this to describe user-perceived behavior.  Here is the original comment, which provides
useful implementation details:

In non-JDK 1.6 builds, the exceptions Derby throws are all of class EmbedSQLException. As
of JDK 1.6, that is no longer true. Instead we throw a "native" SQL Exception.

That makes the following code incorrect:

public static StandardException unexpectedUserException(Throwable t)
{
/*
** If we have a SQLException that isn't a Util
** (i.e. it didn't come from cloudscape), then we check
** to see if it is a valid user defined exception range
** (38001-38XXX). If so, then we convert it into a
** StandardException without further ado.
*/
if ((t instanceof SQLException) &&
!(t instanceof EmbedSQLException))
{
SQLException sqlex = (SQLException)t;
String state = sqlex.getSQLState();
if ((state != null) &&
(state.length() == 5) &&
state.startsWith("38") &&
!state.equals("38000"))
{
StandardException se = new StandardException(state, sqlex.getMessage());
if (sqlex.getNextException() != null)
{
se.setNestedException(sqlex.getNextException());
}
return se;
}
}

I am not sure how we can detect internally-thrown SQL Exceptions and distinguish them from
user exceptions, but this does need to be looked at.

Right now procedureInTrigger.sql is failing for JDK 1.6 due to this error. I may check in
a jdk16-specific version of this file so at least derbyall can pass. 

> StandardException.unexpectedUserException() does not correctly catch internally generated
exceptions as of JDK 1.6
> ------------------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-1629
>                 URL: http://issues.apache.org/jira/browse/DERBY-1629
>             Project: Derby
>          Issue Type: Bug
>            Reporter: David Van Couvering
>            Priority: Minor
>             Fix For: 10.2.0.0
>
>
> In Java SE 6 runtime environments, an application may not get the SQL Exception with
SQL State 38000 when execution of a trigger or procedure fails with an exception caused by
Derby internals.  Instead, they will get the underlying exception with it's SQL State.  For
an example of this, see lang/procedureInTrigger.sql, which has different output for Java SE
6 (encoded in the master/jdk16/procedureInTrigger.out file) than for other Java SE runtimes.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message