db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmars...@apache.org
Subject svn commit: r592192 - in /db/derby/code/branches/10.3/java: drda/org/apache/derby/impl/drda/ drda/org/apache/derby/loc/drda/ testing/org/apache/derbyTesting/functionTests/tests/derbynet/
Date Mon, 05 Nov 2007 23:52:22 GMT
Author: kmarsden
Date: Mon Nov  5 15:52:21 2007
New Revision: 592192

URL: http://svn.apache.org/viewvc?rev=592192&view=rev
Log:
DERBY-3110 server hangs after trace on command fails

merge from trunk revision 592111


Added:
    db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NetworkServerControlApiTest.java
      - copied, changed from r592111, db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NetworkServerControlApiTest.java
    db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NetworkServerControlApiTest.policy
      - copied unchanged from r592111, db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NetworkServerControlApiTest.policy
Modified:
    db/derby/code/branches/10.3/java/drda/org/apache/derby/impl/drda/DssTrace.java
    db/derby/code/branches/10.3/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java
    db/derby/code/branches/10.3/java/drda/org/apache/derby/impl/drda/Session.java
    db/derby/code/branches/10.3/java/drda/org/apache/derby/loc/drda/messages_en.properties
    db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/_Suite.java

Modified: db/derby/code/branches/10.3/java/drda/org/apache/derby/impl/drda/DssTrace.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/drda/org/apache/derby/impl/drda/DssTrace.java?rev=592192&r1=592191&r2=592192&view=diff
==============================================================================
--- db/derby/code/branches/10.3/java/drda/org/apache/derby/impl/drda/DssTrace.java (original)
+++ db/derby/code/branches/10.3/java/drda/org/apache/derby/impl/drda/DssTrace.java Mon Nov
 5 15:52:21 2007
@@ -20,6 +20,13 @@
  */
 package org.apache.derby.impl.drda;
 
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+
+
 // Generic process and error tracing encapsulation.
 // This class also traces a DRDA communications buffer.
 // The value of the hex bytes are traced along with
@@ -97,7 +104,7 @@
 
 
   // An array of characters representing hex numbers.
-  private static final char hexDigit [] = {
+ private static final char hexDigit [] = {
     '0','1','2','3','4','5','6','7',
     '8','9','A','B','C','D','E','F'
   };
@@ -160,14 +167,28 @@
   // Start the communications buffer trace.
   // The name of the file to place the trace is passed to this method.
   // After calling this method, calls to isComBufferTraceOn() will return true.
-  protected void startComBufferTrace (String fileName)
+  protected void startComBufferTrace (final String fileName) throws IOException 
   {
     synchronized (comBufferSync) {
-      try {
         // Only start the trace if it is off.
         if (comBufferTraceOn == false) {
           // The writer will be buffered for effeciency.
-          comBufferWriter = new java.io.PrintWriter (new java.io.BufferedWriter (new java.io.FileWriter
(fileName), 4096));
+            try {
+                
+                comBufferWriter =  ((PrintWriter)AccessController.doPrivileged(
+                            new PrivilegedExceptionAction() {
+                                public Object run() throws SecurityException, IOException
{
+                                    return new  PrintWriter (new java.io.BufferedWriter (new
java.io.FileWriter (fileName), 4096));
+                                }
+                            }));
+            } catch (PrivilegedActionException pae) {
+               Exception e = pae.getException();
+               if (e instanceof SecurityException)
+                   throw (SecurityException)pae.getException();
+               else
+                   throw (IOException) pae.getException();
+            }
+          
           // Turn on the trace flag.
           comBufferTraceOn = true;
           // initialize the codepoint name table if it is null.
@@ -181,11 +202,8 @@
           }
         }
       }
-      catch (java.io.IOException e) {
-        // The IOException is currently ignored.  Handling should be added.
-      }
     }
-  }
+  
 
   // Stop the communications buffer trace.
   // The trace file is flushed and closed.  After calling this method,
@@ -198,8 +216,11 @@
         // Turn of the trace flag.
         comBufferTraceOn = false;
         // Flush and close the writer used for tracing.
-        comBufferWriter.flush();
-        comBufferWriter.close();
+        if (comBufferWriter != null)
+        {
+            comBufferWriter.flush();
+            comBufferWriter.close();
+        }
       }
     }
   }

Modified: db/derby/code/branches/10.3/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java?rev=592192&r1=592191&r2=592192&view=diff
==============================================================================
--- db/derby/code/branches/10.3/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java
(original)
+++ db/derby/code/branches/10.3/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java
Mon Nov  5 15:52:21 2007
@@ -1396,10 +1396,14 @@
 					}
 					else
 					{
-						sendMessage(writer, ERROR,  
-							localizeMessage("DRDA_SessionNotFound.U", 
-							(session.langUtil == null) ? langUtil : session.langUtil,
-							new String [] {new Integer(sessionArg).toString()}));
+					    if (sessionArg != 0)
+							sendMessage(writer, ERROR,  
+							    localizeMessage("DRDA_SessionNotFound.U", 
+									    (session.langUtil == null) ? langUtil : session.langUtil,
+									    new String [] {new Integer(sessionArg).toString()}));
+					    else
+							sendMessage(writer, ERROR,  
+										localizeMessage("DRDA_ErrorStartingTracing.S",null));          
 					}
 					break;
 				case COMMAND_TRACEDIRECTORY:
@@ -3273,18 +3277,27 @@
 	 */
 	private boolean setTrace(boolean on)
 	{
+        boolean setTraceSuccessful = true;
 		if (sessionArg == 0)
 		{
-			setTraceAll(on);
 			synchronized(sessionTable) {
 				for (Enumeration e = sessionTable.elements(); e.hasMoreElements(); )
-				{	
-					Session session = (Session) e.nextElement();
+				{
+                   
+				    Session session = (Session) e.nextElement();
 					if (on)
-						session.setTraceOn(traceDirectory);
+						try {
+							session.setTraceOn(traceDirectory);
+						} catch (Exception te ) {
+							consoleExceptionPrintTrace(te);
+							setTraceSuccessful = false;
+							session.setTraceOff();
+						}
 					else
 						session.setTraceOff();
 				}
+				if (setTraceSuccessful)
+					setTraceAll(on);
 			}
 		}
 		else
@@ -3293,14 +3306,20 @@
 			if (session != null)
 			{	
 				if (on)
-					session.setTraceOn(traceDirectory);
+					try {                         
+						session.setTraceOn(traceDirectory);
+					}catch (Exception te) {
+						consoleExceptionPrintTrace(te);
+						setTraceSuccessful = false;
+						session.setTraceOff();
+					}
 				else
 					session.setTraceOff();
 			}
 			else
 				return false;
 		}
-		return true;
+		return setTraceSuccessful;
 	}
 
 

Modified: db/derby/code/branches/10.3/java/drda/org/apache/derby/impl/drda/Session.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/drda/org/apache/derby/impl/drda/Session.java?rev=592192&r1=592191&r2=592192&view=diff
==============================================================================
--- db/derby/code/branches/10.3/java/drda/org/apache/derby/impl/drda/Session.java (original)
+++ db/derby/code/branches/10.3/java/drda/org/apache/derby/impl/drda/Session.java Mon Nov
 5 15:52:21 2007
@@ -123,31 +123,35 @@
 	 * initialize a server trace for the DRDA protocol
 	 * 
 	 * @param traceDirectory - directory for trace file
+	 * @throws IOException 
 	 */
-	protected void initTrace(String traceDirectory)
+	protected void initTrace(String traceDirectory) throws IOException 
 	{
 		if (traceDirectory != null)
 			traceFileName = traceDirectory + "/" + TRACENAME_PREFIX+
 				connNum+ TRACENAME_SUFFIX;
 		else
 			traceFileName = TRACENAME_PREFIX +connNum+ TRACENAME_SUFFIX;
-		traceOn = true;
+		
 		if (dssTrace == null)
 			dssTrace = new DssTrace();
 		dssTrace.startComBufferTrace (traceFileName);
+		traceOn = true;
 	}
 
 	/**
 	 * Set tracing on
 	 * 
 	 * @param traceDirectory 	directory for trace files
+	 * @throws IOException 
 	 */
-	protected void setTraceOn(String traceDirectory)
+	protected void setTraceOn(String traceDirectory) throws IOException
 	{
 		if (traceOn)
 			return;
-		initTrace(traceDirectory);
+		initTrace(traceDirectory);    
 	}
+
 	/**
 	 * Get whether tracing is on 
 	 *

Modified: db/derby/code/branches/10.3/java/drda/org/apache/derby/loc/drda/messages_en.properties
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/drda/org/apache/derby/loc/drda/messages_en.properties?rev=592192&r1=592191&r2=592192&view=diff
==============================================================================
--- db/derby/code/branches/10.3/java/drda/org/apache/derby/loc/drda/messages_en.properties
(original)
+++ db/derby/code/branches/10.3/java/drda/org/apache/derby/loc/drda/messages_en.properties
Mon Nov  5 15:52:21 2007
@@ -76,7 +76,8 @@
 DRDA_SQLWarning.I={0}
 DRDA_MissingValue.U=Missing required value for {0}.
 DRDA_InvalidPropVal.S=Invalid value for property, {0}, value: {1}.
-DRDA_SessionNotFound.U=Session, {0}, not found.
+DRDA_SessionNotFound.U=Session, {0}, not found or other error occurred starting tracing.
Check runtimeinfo for valid session numbers and derby error log for possible permission errors
or IO errors accesing the trace file.
+DRDA_ErrorStartingTracing.S=Error starting tracing. This can be caused by permission errors
or IO error accessing the trace directory. Check derby error log for details.
 DRDA_MaxThreadsChange.I=Max threads changed to {0}.
 DRDA_TimeSliceChange.I=Time slice changed to {0}.
 DRDA_InvalidValue.U=Invalid value, {0}, for {1}.

Copied: db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NetworkServerControlApiTest.java
(from r592111, db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NetworkServerControlApiTest.java)
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NetworkServerControlApiTest.java?p2=db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NetworkServerControlApiTest.java&p1=db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NetworkServerControlApiTest.java&r1=592111&r2=592192&rev=592192&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NetworkServerControlApiTest.java
(original)
+++ db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NetworkServerControlApiTest.java
Mon Nov  5 15:52:21 2007
@@ -136,12 +136,18 @@
     private static Test decorateTest()
     {
         
-        String serverPolicyName = new NetworkServerControlApiTest("test").makeServerPolicyName();
+        NetworkServerControlApiTest nsapitest = new NetworkServerControlApiTest("test");
+        
+        String serverPolicyName = nsapitest.makeServerPolicyName();
+    
+        
         Test test = TestConfiguration.clientServerSuite(NetworkServerControlApiTest.class);
         //
         // Install a security manager using the initial policy file.
         //
+        
         test = new SecurityManagerSetup( test,serverPolicyName );
+        
         
         
         //

Modified: db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/_Suite.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/_Suite.java?rev=592192&r1=592191&r2=592192&view=diff
==============================================================================
--- db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/_Suite.java
(original)
+++ db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/_Suite.java
Mon Nov  5 15:52:21 2007
@@ -45,7 +45,8 @@
     public static Test suite() {
 
         TestSuite suite = new TestSuite("derbynet");
-             
+        
+        suite.addTest(NetworkServerControlApiTest.suite());     
         suite.addTest(PrepareStatementTest.suite());
         suite.addTest(ShutDownDBWhenNSShutsDownTest.suite());
         suite.addTest(DRDAProtocolTest.suite());
@@ -55,6 +56,7 @@
         suite.addTest(SecureServerTest.suite());
         suite.addTest(SSLTest.suite());
         suite.addTest(NetIjTest.suite());
+        
         
         // Disabled due to "java.sql.SQLSyntaxErrorException: The class
         // 'org.apache.derbyTesting.functionTests.tests.derbynet.checkSecMgr'



Mime
View raw message