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 ma...@apache.org on 2012/09/07 18:15:13 UTC

svn commit: r1382083 - in /db/derby/code/branches/10.5: ./ java/ java/engine/org/apache/derby/impl/store/raw/data/BaseDataFileFactory.java

Author: mamta
Date: Fri Sep  7 16:15:13 2012
New Revision: 1382083

URL: http://svn.apache.org/viewvc?rev=1382083&view=rev
Log:
DERBY-5240 (Log Operating system information to derby.log on boot )

Backporting to 10.5


Modified:
    db/derby/code/branches/10.5/   (props changed)
    db/derby/code/branches/10.5/java/   (props changed)
    db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/store/raw/data/BaseDataFileFactory.java

Propchange: db/derby/code/branches/10.5/
------------------------------------------------------------------------------
  Merged /db/derby/code/trunk:r1371041

Propchange: db/derby/code/branches/10.5/java/
------------------------------------------------------------------------------
  Merged /db/derby/code/trunk/java:r1371041

Modified: db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/store/raw/data/BaseDataFileFactory.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/store/raw/data/BaseDataFileFactory.java?rev=1382083&r1=1382082&r2=1382083&view=diff
==============================================================================
--- db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/store/raw/data/BaseDataFileFactory.java (original)
+++ db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/store/raw/data/BaseDataFileFactory.java Fri Sep  7 16:15:13 2012
@@ -146,6 +146,8 @@ public class BaseDataFileFactory
 	
 	private     String          jvmVersion;
 	
+	private     String          osInfo;
+	
 	private     String          jarCPath;
 
 	private     RawStoreFactory	rawStoreFactory; // associated raw store factory
@@ -274,6 +276,8 @@ public class BaseDataFileFactory
 		
 		jvmVersion = buildJvmVersion();
 		
+		osInfo = buildOSinfo();
+		
 		jarCPath = jarClassPath(getClass());
 
 		dataDirectory = startParams.getProperty(PersistentService.ROOT);
@@ -382,6 +386,9 @@ public class BaseDataFileFactory
 		//Log the JVM version info
 		logMsg(jvmVersion);
 
+		//Log the OS info
+		logMsg(osInfo);
+
 		//Log derby.system.home It will have null value if user didn't set it
 		logMsg(Property.SYSTEM_HOME_PROPERTY+"=" + 
 				PropertyUtil.getSystemProperty(Property.SYSTEM_HOME_PROPERTY));
@@ -2215,6 +2222,32 @@ public class BaseDataFileFactory
         });
     }
     
+    /**
+     * Return values of system properties that identify the OS.
+     * Will catch SecurityExceptions and note them for displaying information.
+     * @return the Java system property value for the OS or a string capturing a
+     * security exception.
+     */
+    private static String buildOSinfo () {
+    	return (String)AccessController.doPrivileged(new PrivilegedAction(){
+    		public Object run() {
+    			String osInfo = "";
+    			try {
+    				String currentProp = PropertyUtil.getSystemProperty("os.name");
+    				if (currentProp != null)
+    					osInfo = "os.name="+currentProp+"\n";
+    				if ((currentProp = PropertyUtil.getSystemProperty("os.arch")) != null)
+    					osInfo += "os.arch="+currentProp+"\n";
+    				if ((currentProp = PropertyUtil.getSystemProperty("os.version")) != null)
+    					osInfo += "os.version="+currentProp;
+    			}
+    			catch(SecurityException se){
+    				return se.getMessage();
+    			}
+    			return osInfo;
+    		}
+    	});
+    }
     
     /**
      * Return values of system properties that identify the JVM.