Author: indika
Date: Wed May  6 22:32:01 2009
New Revision: 35247
URL: http://wso2.org/svn/browse/wso2?view=rev&revision=35247

Log:
Fix possible NPE (if programmatically create dsinfor)
Avoid serialization of null values 


Modified:
   
branches/synapse/1.3-wso2v1/modules/utils/src/main/java/org/apache/synapse/commons/util/datasource/serializer/DataSourceInformationSerializer.java

Modified: 
branches/synapse/1.3-wso2v1/modules/utils/src/main/java/org/apache/synapse/commons/util/datasource/serializer/DataSourceInformationSerializer.java
URL: 
http://wso2.org/svn/browse/wso2/branches/synapse/1.3-wso2v1/modules/utils/src/main/java/org/apache/synapse/commons/util/datasource/serializer/DataSourceInformationSerializer.java?rev=35247&r1=35246&r2=35247&view=diff
==============================================================================
--- 
branches/synapse/1.3-wso2v1/modules/utils/src/main/java/org/apache/synapse/commons/util/datasource/serializer/DataSourceInformationSerializer.java
  (original)
+++ 
branches/synapse/1.3-wso2v1/modules/utils/src/main/java/org/apache/synapse/commons/util/datasource/serializer/DataSourceInformationSerializer.java
  Wed May  6 22:32:01 2009
@@ -21,6 +21,7 @@
 import org.apache.synapse.commons.util.datasource.DataSourceConstants;
 import org.apache.synapse.commons.util.datasource.DataSourceInformation;
 import org.apache.synapse.commons.util.secret.SecretConfigurationConstants;
+import org.apache.synapse.commons.util.secret.SecretInformation;
 
 import java.util.Properties;
 
@@ -50,10 +51,24 @@
         String prefix = buffer.toString();
         addProperty(properties, prefix + DataSourceConstants.PROP_DSNAME,
                 information.getDatasourceName());
-        addProperty(properties, prefix + 
SecretConfigurationConstants.PROP_USER_NAME,
-                information.getSecretInformation().getUser());
-        addProperty(properties, prefix + 
SecretConfigurationConstants.PROP_PASSWORD,
-                information.getSecretInformation().getAliasPassword());
+
+        SecretInformation secretInformation = 
information.getSecretInformation();
+        if (secretInformation != null) {
+
+            String user = secretInformation.getUser();
+            if (user != null && !"".equals(user)) {
+                addProperty(properties, prefix + 
SecretConfigurationConstants.PROP_USER_NAME,
+                        user);
+            }
+
+            String password = secretInformation.getAliasPassword();
+            if (password != null && !"".equals(password)) {
+                addProperty(properties, prefix + 
SecretConfigurationConstants.PROP_PASSWORD,
+                        password);
+            }
+
+        }
+
         addProperty(properties, prefix + DataSourceConstants.PROP_MAXACTIVE,
                 String.valueOf(information.getMaxActive()));
         addProperty(properties, prefix + DataSourceConstants.PROP_MAXIDLE,

_______________________________________________
Esb-java-dev mailing list
[email protected]
https://wso2.org/cgi-bin/mailman/listinfo/esb-java-dev

Reply via email to