db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmars...@apache.org
Subject svn commit: r395416 - in /db/derby/code/trunk/java: drda/org/apache/derby/impl/drda/DRDAConnThread.java engine/org/apache/derby/catalog/SystemProcedures.java
Date Wed, 19 Apr 2006 22:40:27 GMT
Author: kmarsden
Date: Wed Apr 19 15:40:25 2006
New Revision: 395416

URL: http://svn.apache.org/viewcvs?rev=395416&view=rev
Log:
DERBY-901
Remove use of String(byte[]) constructors in network server leading to non-portable behaviour

Contributed by Sunitha Kambhampati

I am attaching the patch ( derby901.p2.diff.txt, derby901.p2.stat.txt) to fix the remaining
places that the String(byte[]) constructor is used in Network Server.

remove use of default String(byte[]) constructor in
-- trace method in DRDAConnThread.readAndSetParams to print out the hex string of the bytes
.
-- use SQLERRMC_TOKEN_DELIMITER in SQLDIAGCI .

some cleanup
 -- define the SQLERRMC_MESSAGE_DELIMITER in SystemProcedures and use that in DRDAConnThread.



Modified:
    db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java
    db/derby/code/trunk/java/engine/org/apache/derby/catalog/SystemProcedures.java

Modified: db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java?rev=395416&r1=395415&r2=395416&view=diff
==============================================================================
--- db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java (original)
+++ db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java Wed Apr 19
15:40:25 2006
@@ -44,6 +44,7 @@
 import java.util.Properties;
 import java.util.Vector;
 
+import org.apache.derby.catalog.SystemProcedures;
 import org.apache.derby.iapi.error.ExceptionSeverity;
 import org.apache.derby.iapi.reference.Attribute;
 import org.apache.derby.iapi.reference.DRDAConstants;
@@ -4206,7 +4207,7 @@
 			{
 				byte[] paramVal = reader.readBytes();
 				if (SanityManager.DEBUG) 
-					trace("fix bytes parameter value is: "+new String(paramVal));
+					trace("fix bytes parameter value is: "+ convertToHexString(paramVal));
 				ps.setBytes(i+1, paramVal);
 				break;
 			}
@@ -5327,15 +5328,6 @@
 	 */
 	private static String SQLERRMC_TOKEN_DELIMITER = new String(new char[] {(char)20});
 
-    
-    // This token delimiter value is used to separate the tokens for multiple 
-    // error messages.  This is used in SystemProcedures.SQLCAMESSAGE.
-    /**
-	 * <code>SQLERRMC_MESSAGE_DELIMITER</code> When message argument tokes are sent,
-	 * this value separates the tokens for mulitiple error messages 
-	 */
-	private static String SQLERRMC_MESSAGE_DELIMITER = new String(new char[] {(char)20,(char)20,(char)20});
-	
 	/**
 	 * <code>SQLERRMC_PREFORMATTED_MESSAGE_DELIMITER</code>, When full message text
is 
 	 * sent for severe errors. This value separates the messages. 
@@ -5424,7 +5416,7 @@
 	 * Build Tokenized SQLERRMC to just send the tokenized arguments to the client.
 	 * for a Derby SQLException
 	 * Message argument tokens are separated by SQLERRMC_TOKEN_DELIMITER 
-	 * Multiple messages are separated by SQLERRMC_MESSAGE_DELIMITER
+	 * Multiple messages are separated by SystemProcedures.SQLERRMC_MESSAGE_DELIMITER
 	 * 
 	 *                 ...
 	 * @param se   SQLException to print
@@ -5443,7 +5435,7 @@
 			se = (EmbedSQLException) se.getNextException();
 			if (se != null)
 			{
-				sqlerrmc += SQLERRMC_MESSAGE_DELIMITER + se.getSQLState() + ":";				
+				sqlerrmc += SystemProcedures.SQLERRMC_MESSAGE_DELIMITER + se.getSQLState() + ":";			

 			}
 		} while (se != null);
 		return sqlerrmc;
@@ -5602,13 +5594,11 @@
 			String sqlState = se.getSQLState();
 			int sqlCode = getSqlCode(getExceptionSeverity(se));
 			String sqlerrmc = "";
-			byte[] sep = {20};	// use it as separator of sqlerrmc tokens
-			String separator = new String(sep);
 				
 			// arguments are variable part of a message
 			Object[] args = ((EmbedSQLException)se).getArguments();
 			for (int i = 0; args != null &&  i < args.length; i++)
-				sqlerrmc += args[i].toString() + separator;
+				sqlerrmc += args[i].toString() + SQLERRMC_TOKEN_DELIMITER;
 
 			String dbname = null;
 			if (database != null)

Modified: db/derby/code/trunk/java/engine/org/apache/derby/catalog/SystemProcedures.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/catalog/SystemProcedures.java?rev=395416&r1=395415&r2=395416&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/catalog/SystemProcedures.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/catalog/SystemProcedures.java Wed Apr
19 15:40:25 2006
@@ -67,6 +67,14 @@
 	private final static String DRIVER_TYPE_OPTION = "DATATYPE";
 	private final static String ODBC_DRIVER_OPTION = "'ODBC'";
 
+    // This token delimiter value is used to separate the tokens for multiple 
+    // error messages.  This is used in DRDAConnThread
+    /**
+     * <code>SQLERRMC_MESSAGE_DELIMITER</code> When message argument tokes are
sent,
+     * this value separates the tokens for mulitiple error messages 
+     */
+    public  static String SQLERRMC_MESSAGE_DELIMITER = new String(new char[] {(char)20,(char)20,(char)20});
+
 	/**
 	  Method used by Cloudscape Network Server to get localized message (original call
 	  from jcc.
@@ -97,18 +105,15 @@
 	{
 		int numMessages = 1;
         
-        // This corresponds to the DRDAConnThread.SQLERRMC_MESSAGE_DELIMITER
-        // delimiter for multiple messages that are set in sqlerrmc.
-		char[] b = {(char)20, (char)20, (char)20};
-		String errSeparator = new String(b);
 
 		// Figure out if there are multiple exceptions in sqlerrmc. If so get each one
 		// translated and append to make the final result.
 		for (int index=0; ; numMessages++)
 		{
-			if (sqlerrmc.indexOf(errSeparator, index) == -1)
+			if (sqlerrmc.indexOf(SQLERRMC_MESSAGE_DELIMITER, index) == -1)
 				break;
-			index = sqlerrmc.indexOf(errSeparator, index) + errSeparator.length();
+			index = sqlerrmc.indexOf(SQLERRMC_MESSAGE_DELIMITER, index) + 
+                        SQLERRMC_MESSAGE_DELIMITER.length();
 		}
 
 		// Putting it here instead of prepareCall it directly is because inter-jar reference tool
@@ -124,7 +129,7 @@
 			String[] errMsg = new String[2];
 			for (int i=0; i<numMessages; i++)
 			{
-				endIdx = sqlerrmc.indexOf(errSeparator, startIdx);
+				endIdx = sqlerrmc.indexOf(SQLERRMC_MESSAGE_DELIMITER, startIdx);
 				if (i == numMessages-1)				// last error message
 					sqlError = sqlerrmc.substring(startIdx);
 				else sqlError = sqlerrmc.substring(startIdx, endIdx);
@@ -147,7 +152,7 @@
 						msg[0] = errMsg[0];
 					else msg[0] += errMsg[0];	// append the new message
 				}
-				startIdx = endIdx + errSeparator.length();
+				startIdx = endIdx + SQLERRMC_MESSAGE_DELIMITER.length();
 			}
 		}
 	}



Mime
View raw message