db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r808479 - in /db/derby/code/branches/10.5: ./ java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java
Date Thu, 27 Aug 2009 16:08:17 GMT
Author: mamta
Date: Thu Aug 27 16:08:15 2009
New Revision: 808479

URL: http://svn.apache.org/viewvc?rev=808479&view=rev
Log:
DERBY-4304

Merging changes from trunk into 10.5 codelines. The revisions being merged are as follows
   Merged /db/derby/code/trunk:r794303,796316,796372,798347,798742,803548


Modified:
    db/derby/code/branches/10.5/   (props changed)
    db/derby/code/branches/10.5/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java

Propchange: db/derby/code/branches/10.5/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Aug 27 16:08:15 2009
@@ -1 +1 @@
-/db/derby/code/trunk:769596,769602,769606,769962,772090,772337,772449,772534,774281,777105,779681,782991,785131,785139,785163,785570,785662,788369,788670,788674,788968,789264,790218,792434,793089,793588,794106,794955,795166,796020,796027,797147,800523,803948,805696
+/db/derby/code/trunk:769596,769602,769606,769962,772090,772337,772449,772534,774281,777105,779681,782991,785131,785139,785163,785570,785662,788369,788670,788674,788968,789264,790218,792434,793089,793588,794106,794303,794955,795166,796020,796027,796316,796372,797147,798347,798742,800523,803548,803948,805696

Modified: db/derby/code/branches/10.5/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.5/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java?rev=808479&r1=808478&r2=808479&view=diff
==============================================================================
--- db/derby/code/branches/10.5/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java
(original)
+++ db/derby/code/branches/10.5/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java
Thu Aug 27 16:08:15 2009
@@ -793,111 +793,156 @@
                             NetworkServerMBean.class,
                             "type=NetworkServer");
                 			
-		// wait until we are told to shutdown or someone sends an InterruptedException
-        synchronized(shutdownSync) {
-            try {
-				shutdownSync.wait();
-            }
-            catch (InterruptedException e)
-            {
-                shutdown = true;
-            }
-        }
-        
-        AccessController.doPrivileged(
-                new PrivilegedAction() {
-                    public Object run()  {
-                    // Need to interrupt the memcheck thread if it is sleeping.
-                        if (mc != null)
-                            mc.interrupt();
-
-                        //interrupt client thread
-                        clientThread.interrupt();
-
-                        return null;
-                    }
-                });
-		
- 		// Close out the sessions
- 		synchronized(sessionTable) {
- 			for (Enumeration e = sessionTable.elements(); e.hasMoreElements(); )
- 			{	
- 				Session session = (Session) e.nextElement();
- 				session.close();
- 			}
- 		}
-
-		synchronized (threadList)
-		{
- 			//interupt any connection threads still active
- 			for (int i = 0; i < threadList.size(); i++)
- 			{
-				final DRDAConnThread threadi = (DRDAConnThread)threadList.get(i);
-                
- 				threadi.close();
-				AccessController.doPrivileged(
-							new PrivilegedAction() {
-								public Object run() {
-									threadi.interrupt();
-									return null;
-								}
-							});
- 			}
- 			threadList.clear();
-		}
-	   	
-	    // close the listener socket
-	    try{
-	       serverSocket.close();
-	    }catch(IOException e){
-			consolePropertyMessage("DRDA_ListenerClose.S", true);
-	    }
-
-
-		// Wake up those waiting on sessions, so
-		// they can close down
-		synchronized (runQueue) {
-			runQueue.notifyAll();
-		}	
-        
-        // And now unregister any MBeans.
-        mgmtService.unregisterMBean(versionMBean);
-        mgmtService.unregisterMBean(networkServerMBean);
+		try {
+			// wait until we are told to shutdown or someone sends an InterruptedException
+	        synchronized(shutdownSync) {
+	            try {
+					shutdownSync.wait();
+	            }
+	            catch (InterruptedException e)
+	            {
+	                shutdown = true;
+	            }
+	        }
+	        
+	        try {
+	            AccessController.doPrivileged(
+	                    new PrivilegedAction() {
+	                        public Object run()  {
+	                        // Need to interrupt the memcheck thread if it is sleeping.
+	                            if (mc != null)
+	                                mc.interrupt();
+
+	                            //interrupt client thread
+	                            clientThread.interrupt();
+
+	                            return null;
+	                       }
+	                    });
+	        } catch (Exception exception) {
+	        	consolePrintAndIgnore("DRDA_UnexpectedException.S", exception, true);
+	        }
+			
+	 		// Close out the sessions
+	 		synchronized(sessionTable) {
+	 			for (Enumeration e = sessionTable.elements(); e.hasMoreElements(); )
+	 			{	
+	 				Session session = (Session) e.nextElement();
+	 				try {
+	 					session.close();
+	 				} catch (Exception exception) {
+	 		        	consolePrintAndIgnore("DRDA_UnexpectedException.S", exception, true);
+	 				}
+	 			}
+	 		}
+
+			synchronized (threadList)
+			{
+	 			//interupt any connection threads still active
+	 			for (int i = 0; i < threadList.size(); i++)
+	 			{
+	 				try {
+	 					final DRDAConnThread threadi = (DRDAConnThread)threadList.get(i);
+	 	                
+	 	 				threadi.close();
+	 					AccessController.doPrivileged(
+	 								new PrivilegedAction() {
+	 									public Object run() {
+	 										threadi.interrupt();
+	 										return null;
+	 									}
+	 								});
+	 				} catch (Exception exception) {
+	 		        	consolePrintAndIgnore("DRDA_UnexpectedException.S", exception, true);
+	 				}
+	 			}
+	 			threadList.clear();
+			}
+		   	
+		    // close the listener socket
+		    try{
+		       serverSocket.close();
+		    }catch(IOException e){
+				consolePropertyMessage("DRDA_ListenerClose.S", true);
+		    } catch (Exception exception) {
+	        	consolePrintAndIgnore("DRDA_UnexpectedException.S", exception, true);
+		    }
+
+			// Wake up those waiting on sessions, so
+			// they can close down
+		    try{
+				synchronized (runQueue) {
+					runQueue.notifyAll();
+				}	
+		    } catch (Exception exception) {
+	        	consolePrintAndIgnore("DRDA_UnexpectedException.S", exception, true);
+		    }
+	        
+	        // And now unregister any MBeans.
+		    try {
+		        mgmtService.unregisterMBean(versionMBean);
+		        mgmtService.unregisterMBean(networkServerMBean);
+		    } catch (Exception exception) {
+	        	consolePrintAndIgnore("DRDA_UnexpectedException.S", exception, true);
+		    }
 
-		if (shutdownDatabasesOnShutdown) {
+			if (shutdownDatabasesOnShutdown) {
 
-			// Shutdown Derby
-			try {
-				// tell driver to shutdown the engine
-				if (cloudscapeDriver != null) {
-					// DERBY-2109: pass user credentials for driver shutdown
-					final Properties p = new Properties();
-					if (userArg != null) {
-						p.setProperty("user", userArg);
+				// Shutdown Derby
+				try {
+					// tell driver to shutdown the engine
+					if (cloudscapeDriver != null) {
+						// DERBY-2109: pass user credentials for driver shutdown
+						final Properties p = new Properties();
+						if (userArg != null) {
+							p.setProperty("user", userArg);
+						}
+						if (passwordArg != null) {
+							p.setProperty("password", passwordArg);
+						}
+						cloudscapeDriver.connect("jdbc:derby:;shutdown=true", p);
 					}
-					if (passwordArg != null) {
-						p.setProperty("password", passwordArg);
+				} catch (SQLException sqle) {
+					// If we can't shutdown Derby, perhaps, authentication has
+					// failed or System Privileges weren't granted. We will just
+					// print a message to the console and proceed.
+					String expectedState =
+						StandardException.getSQLStateFromIdentifier(
+								SQLState.CLOUDSCAPE_SYSTEM_SHUTDOWN);
+					if (!expectedState.equals(sqle.getSQLState())) {
+						consolePropertyMessage("DRDA_ShutdownWarning.I",
+											   sqle.getMessage());
 					}
-					cloudscapeDriver.connect("jdbc:derby:;shutdown=true", p);
-				}
-			} catch (SQLException sqle) {
-				// If we can't shutdown Derby, perhaps, authentication has
-				// failed or System Privileges weren't granted. We will just
-				// print a message to the console and proceed.
-				String expectedState =
-					StandardException.getSQLStateFromIdentifier(
-							SQLState.CLOUDSCAPE_SYSTEM_SHUTDOWN);
-				if (!expectedState.equals(sqle.getSQLState())) {
-					consolePropertyMessage("DRDA_ShutdownWarning.I",
-										   sqle.getMessage());
+				} catch (Exception exception) {
+					consolePrintAndIgnore("DRDA_UnexpectedException.S", exception, true);
 				}
 			}
-		}
 
-		consolePropertyMessage("DRDA_ShutdownSuccess.I", new String [] 
-						        {att_srvclsnm, versionString});
+			consolePropertyMessage("DRDA_ShutdownSuccess.I", new String [] 
+							        {att_srvclsnm, versionString});
+			
+		} catch (Exception ex) {
+			try {
+				//If the console printing is not available,  then we have
+				//a simple stack trace print below to atleast print some
+				//exception info
+	        	consolePrintAndIgnore("DRDA_UnexpectedException.S", ex, true);				
+			} catch (Exception e) {}
+			ex.printStackTrace();
+		}
     }
 	
+	//Print the passed exception on the console and ignore it after that
+	private void consolePrintAndIgnore(String msgProp, 
+			Exception e, boolean printTimeStamp) {
+		// catch the exception consolePropertyMessage will throw since we
+		// just want to print information about it and move on.
+		try {
+			consolePropertyMessage(msgProp, true);
+		} catch (Exception ce) {} 
+		consoleExceptionPrintTrace(e);		
+	}
+	
 	/** 
 	 * Load Derby and save driver for future use.
 	 * We can't call Driver Manager when the client connects, 



Mime
View raw message