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 2014/01/22 13:15:46 UTC
svn commit: r1560329 - in /db/derby/code/branches/10.10: ./
java/drda/org/apache/derby/impl/drda/
java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/
Author: kahatlen
Date: Wed Jan 22 12:15:46 2014
New Revision: 1560329
URL: http://svn.apache.org/r1560329
Log:
DERBY-6456: Infinite loop in NetworkServerControlImpl when reply >= 32k
Merged revision 1559943 from trunk.
Modified:
db/derby/code/branches/10.10/ (props changed)
db/derby/code/branches/10.10/java/drda/org/apache/derby/impl/drda/DDMWriter.java
db/derby/code/branches/10.10/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java
db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/RuntimeInfoTest.java
Propchange: db/derby/code/branches/10.10/
------------------------------------------------------------------------------
Merged /db/derby/code/trunk:r1559943
Modified: db/derby/code/branches/10.10/java/drda/org/apache/derby/impl/drda/DDMWriter.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.10/java/drda/org/apache/derby/impl/drda/DDMWriter.java?rev=1560329&r1=1560328&r2=1560329&view=diff
==============================================================================
--- db/derby/code/branches/10.10/java/drda/org/apache/derby/impl/drda/DDMWriter.java (original)
+++ db/derby/code/branches/10.10/java/drda/org/apache/derby/impl/drda/DDMWriter.java Wed Jan 22 12:15:46 2014
@@ -62,7 +62,7 @@ class DDMWriter
* The maximum length in bytes for strings sent by {@code writeLDString()},
* which is the maximum unsigned integer value that fits in two bytes.
*/
- private final static int MAX_VARCHAR_BYTE_LENGTH = 0xFFFF;
+ final static int MAX_VARCHAR_BYTE_LENGTH = 0xFFFF;
/**
* Output buffer.
Modified: db/derby/code/branches/10.10/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.10/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java?rev=1560329&r1=1560328&r2=1560329&view=diff
==============================================================================
--- db/derby/code/branches/10.10/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java (original)
+++ db/derby/code/branches/10.10/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java Wed Jan 22 12:15:46 2014
@@ -167,8 +167,20 @@ public final class NetworkServerControlI
private final static int SHUTDOWN_CHECK_ATTEMPTS = 100;
private final static int SHUTDOWN_CHECK_INTERVAL= 100;
- // maximum reply size
- private final static int MAXREPLY = 32767;
+ /**
+ * Maximum reply size. The reply buffer must be large enough to hold the
+ * largest reply that {@link #readBytesReply(String)} and
+ * {@link #readStringReply(String)} can receive. That is, a reply header
+ * (4 bytes), a status byte (1 byte), a length field (2 bytes) and the
+ * longest value (in bytes) that could be written by
+ * {@link DDMWriter#writeLDBytes(byte[])} or
+ * {@link DDMWriter#writeLDString(String)}.
+ */
+ private final static int MAXREPLY =
+ REPLY_HEADER_LENGTH
+ + 1 // status byte
+ + 2 // length field
+ + DDMWriter.MAX_VARCHAR_BYTE_LENGTH;
// Application Server Attributes.
protected static String att_srvclsnm;
Modified: db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/RuntimeInfoTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/RuntimeInfoTest.java?rev=1560329&r1=1560328&r2=1560329&view=diff
==============================================================================
--- db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/RuntimeInfoTest.java (original)
+++ db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/RuntimeInfoTest.java Wed Jan 22 12:15:46 2014
@@ -80,9 +80,15 @@ public class RuntimeInfoTest extends Bas
*/
public static Test suite() {
TestSuite suite = new TestSuite("RuntimeInfoTest");
-
- suite.addTest(decorateTest(englishLocale));
- suite.addTest(decorateTest(germanLocale));
+
+ // Run testRunTests in both English and German locale
+ suite.addTest(decorateTest(englishLocale, "testRunTests"));
+ suite.addTest(decorateTest(germanLocale, "testRunTests"));
+
+ // Other test cases, only tested in a single locale.
+ suite.addTest(
+ decorateTest(englishLocale, "testRuntimeInfoWithLongValues"));
+
return suite;
}
@@ -191,6 +197,33 @@ public class RuntimeInfoTest extends Bas
assertEquals("Output doesn't match", expectedOutput, s);
}
+ /**
+ * Regression test case for DERBY-6456, which caused an infinite loop if
+ * the runtimeinfo output was more than 32KB.
+ */
+ public void testRuntimeInfoWithLongValues() throws Exception {
+ // First open many connections on the server, so that the reply from
+ // getRuntimeInfo() will be long.
+ for (int i = 0; i < 200; i++) {
+ prepareAndExecuteQuery(openDefaultConnection(),
+ "VALUES 'Hello, World! How are you today?',\n"
+ + "'Not that bad today, actually. Thanks for asking.'\n"
+ + "-- Let's add some more text to increase the output length.\n"
+ + "-- And even more here... The statement text, including this\n"
+ + "-- comment, will be included in the runtimeinfo output.\n");
+ }
+
+ // This call used to hang.
+ String runtimeinfo =
+ NetworkServerTestSetup.getNetworkServerControl().getRuntimeInfo();
+
+ // For debugging:
+ println(runtimeinfo);
+
+ // Output gets truncated to 65535 bytes (DERBY-5220).
+ assertEquals(65535, runtimeinfo.length());
+ }
+
public static PreparedStatement prepareAndExecuteQuery(Connection conn,
String sql) throws SQLException {
PreparedStatement ps = conn.prepareStatement(sql);
@@ -255,11 +288,11 @@ public class RuntimeInfoTest extends Bas
*
* @return the decorated test
*/
- private static Test decorateTest(Locale serverLocale) {
+ private static Test decorateTest(Locale serverLocale, String testName) {
String policyName = new RuntimeInfoTest("test").makePolicyName();
- Test test = new TestSuite(RuntimeInfoTest.class);
-
+ Test test = new RuntimeInfoTest(testName);
+
test = TestConfiguration.clientServerDecorator(test);
/* A single use database must be used to ensure the consistent output.