db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r929085 - in /db/derby/code/trunk/java: client/org/apache/derby/client/net/NetConnection.java testing/org/apache/derbyTesting/functionTests/tests/derbynet/DRDAProtocolTest.java
Date Tue, 30 Mar 2010 11:22:35 GMT
Author: kahatlen
Date: Tue Mar 30 11:22:35 2010
New Revision: 929085

URL: http://svn.apache.org/viewvc?rev=929085&view=rev
Log:
DERBY-4584: Unable to connect to network server if client thread name has Japanese characters

Patch contributed by Tiago R. Espinha.

Modified:
    db/derby/code/trunk/java/client/org/apache/derby/client/net/NetConnection.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/DRDAProtocolTest.java

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/net/NetConnection.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/net/NetConnection.java?rev=929085&r1=929084&r2=929085&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/net/NetConnection.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/net/NetConnection.java Tue Mar
30 11:22:35 2010
@@ -1298,7 +1298,14 @@ public class NetConnection extends org.a
 
 
     private void constructExtnam() throws SqlException {
-        extnam_ = "derbydnc" + java.lang.Thread.currentThread().getName();
+        /* Construct the EXTNAM based on the thread name */
+        char[] chars = java.lang.Thread.currentThread().getName().toCharArray();
+
+        /* DERBY-4584: Replace non-EBCDIC characters (> 0xff) with '?' */
+        for (int i = 0; i < chars.length; i++) {
+            if (chars[i] > 0xff) chars[i] = '?';
+        }
+        extnam_ = "derbydnc" + new String(chars);
     }
 
     private void constructPrddta() throws SqlException {

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/DRDAProtocolTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/DRDAProtocolTest.java?rev=929085&r1=929084&r2=929085&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/DRDAProtocolTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/DRDAProtocolTest.java
Tue Mar 30 11:22:35 2010
@@ -38,6 +38,34 @@ import org.apache.derbyTesting.junit.Tes
  */
 public class DRDAProtocolTest extends BaseJDBCTestCase {
     
+    private String threadName;
+
+    public void setUp() {
+        /* Save the thread name as it gets changed in one of the fixtures */
+        threadName = Thread.currentThread().getName();
+    }
+
+    public void tearDown() throws Exception {
+        /* Restore the original thread name */
+
+        super.tearDown();
+
+        Thread.currentThread().setName(threadName);
+    }
+
+    /**
+     * Tests the support for threads with characters not supported by EBCDIC
+     *
+     * @throws SQLException
+     */
+    public void testNonEBCDICCharacters() throws SQLException {
+        Thread.currentThread().setName("\u4e10");
+
+        /* Open a connection while the thread name has Japanese characters */
+        Connection conn2 = openConnection("FIRSTDB1");
+        conn2.close();
+    }
+
     /** 
      * Tests whether multiple connections to different databases
      * on the same Derby instance are working without exceptions.



Mime
View raw message