You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by ka...@apache.org on 2006/08/18 07:47:10 UTC
svn commit: r432493 -
/db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java
Author: kahatlen
Date: Thu Aug 17 22:47:07 2006
New Revision: 432493
URL: http://svn.apache.org/viewvc?rev=432493&view=rev
Log:
DERBY-1710: Unchecked casts from SQLException to EmbedSQLException
cause ClassCastException in NetworkServerControlImpl when running
Java SE 6
The attached patch makes NetworkServerControlImpl use
SQLException.getSQLState() instead of EmbedSQLException.getMessageId()
where possible. Where it is not possible, check that the exception is
EmbedSQLException before casting, and fall back to a more generic
approach if it is not.
Modified:
db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java
Modified: db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java?rev=432493&r1=432492&r2=432493&view=diff
==============================================================================
--- db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java (original)
+++ db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java Thu Aug 17 22:47:07 2006
@@ -50,6 +50,7 @@
import java.util.Vector;
import org.apache.derby.drda.NetworkServerControl;
+import org.apache.derby.iapi.error.StandardException;
import org.apache.derby.iapi.jdbc.DRDAServerStarter;
import org.apache.derby.iapi.reference.Attribute;
import org.apache.derby.iapi.reference.DRDAConstants;
@@ -662,10 +663,13 @@
// If we can't shutdown cloudscape. Perhaps authentication is
// set to true or some other reason. We will just print a
// message to the console and proceed.
- if (((EmbedSQLException)sqle).getMessageId() !=
- SQLState.CLOUDSCAPE_SYSTEM_SHUTDOWN)
+ String expectedState =
+ StandardException.getSQLStateFromIdentifier(
+ SQLState.CLOUDSCAPE_SYSTEM_SHUTDOWN);
+ if (!expectedState.equals(sqle.getSQLState())) {
consolePropertyMessage("DRDA_ShutdownWarning.I",
sqle.getMessage());
+ }
}
}
@@ -1555,7 +1559,8 @@
//localize message if necessary
while (se != null)
{
- if (currentSession != null && currentSession.langUtil != null)
+ if (currentSession != null && currentSession.langUtil != null &&
+ se instanceof EmbedSQLException)
{
locMsg.append(se.getSQLState()+":"+
MessageService.getLocalizedMessage(
@@ -3235,7 +3240,10 @@
conn.close();
} catch (SQLException se) {
//ignore shutdown error
- if (!(((EmbedSQLException)se).getMessageId() == SQLState.SHUTDOWN_DATABASE))
+ String expectedState =
+ StandardException.
+ getSQLStateFromIdentifier(SQLState.SHUTDOWN_DATABASE);
+ if (!expectedState.equals(se.getSQLState()))
{
sendSQLMessage(writer, se, SQLERROR);
return;