Author: remm
Date: Thu Dec 13 14:27:51 2012
New Revision: 1421310

URL: http://svn.apache.org/viewvc?rev=1421310&view=rev
Log:
Avoid replacement creating a duplicate.

Modified:
    
tomcat/sandbox/storeconfig6/trunk/src/main/java/org/apache/catalina/storeconfig/ConnectorStoreAppender.java
    
tomcat/sandbox/storeconfig7/trunk/src/main/java/org/apache/catalina/storeconfig/ConnectorStoreAppender.java

Modified: 
tomcat/sandbox/storeconfig6/trunk/src/main/java/org/apache/catalina/storeconfig/ConnectorStoreAppender.java
URL: 
http://svn.apache.org/viewvc/tomcat/sandbox/storeconfig6/trunk/src/main/java/org/apache/catalina/storeconfig/ConnectorStoreAppender.java?rev=1421310&r1=1421309&r2=1421310&view=diff
==============================================================================
--- 
tomcat/sandbox/storeconfig6/trunk/src/main/java/org/apache/catalina/storeconfig/ConnectorStoreAppender.java
 (original)
+++ 
tomcat/sandbox/storeconfig6/trunk/src/main/java/org/apache/catalina/storeconfig/ConnectorStoreAppender.java
 Thu Dec 13 14:27:51 2012
@@ -93,9 +93,6 @@ public class ConnectorStoreAppender exte
         for (Iterator propertyIterator = propertyKeys.iterator(); 
propertyIterator
                 .hasNext();) {
             String key = (String) propertyIterator.next();
-            if (replacements.get(key) != null) {
-                key = (String) replacements.get(key);
-            }
             Object value = (Object) IntrospectionUtils.getProperty(bean, key);
 
             if (desc.isTransientAttribute(key)) {
@@ -158,12 +155,28 @@ public class ConnectorStoreAppender exte
                 continue;
             propertyKeys.add(descriptors[i].getName());
         }
-        for (Iterator propertyIterator = protocolHandler.getAttributeNames(); 
propertyIterator
-                .hasNext();) {
-            Object key = propertyIterator.next();
-            if (propertyKeys.contains(key))
-                continue;
-            propertyKeys.add(key);
+        // Add the properties of the protocol handler
+        descriptors = Introspector.getBeanInfo(
+                protocolHandler.getClass()).getPropertyDescriptors();
+        if (descriptors == null) {
+            descriptors = new PropertyDescriptor[0];
+        }
+        for (int i = 0; i < descriptors.length; i++) {
+            if (descriptors[i] instanceof IndexedPropertyDescriptor) {
+                continue; // Indexed properties are not persisted
+            }
+            if (!isPersistable(descriptors[i].getPropertyType())
+                    || (descriptors[i].getReadMethod() == null)
+                    || (descriptors[i].getWriteMethod() == null)) {
+                continue; // Must be a read-write primitive or String
+            }
+            String key = descriptors[i].getName();
+            if (replacements.get(key) != null) {
+                key = (String) replacements.get(key);
+            }
+            if (!propertyKeys.contains(key)) {
+                propertyKeys.add(key);
+            }
         }
         return propertyKeys;
     }

Modified: 
tomcat/sandbox/storeconfig7/trunk/src/main/java/org/apache/catalina/storeconfig/ConnectorStoreAppender.java
URL: 
http://svn.apache.org/viewvc/tomcat/sandbox/storeconfig7/trunk/src/main/java/org/apache/catalina/storeconfig/ConnectorStoreAppender.java?rev=1421310&r1=1421309&r2=1421310&view=diff
==============================================================================
--- 
tomcat/sandbox/storeconfig7/trunk/src/main/java/org/apache/catalina/storeconfig/ConnectorStoreAppender.java
 (original)
+++ 
tomcat/sandbox/storeconfig7/trunk/src/main/java/org/apache/catalina/storeconfig/ConnectorStoreAppender.java
 Thu Dec 13 14:27:51 2012
@@ -90,12 +90,9 @@ public class ConnectorStoreAppender exte
         List propertyKeys = getPropertyKeys((Connector) bean);
         // Create blank instance
         Object bean2 = defaultInstance(bean);
-        for (Iterator propertyIterator = propertyKeys.iterator(); 
propertyIterator
-                .hasNext();) {
+        Iterator propertyIterator = propertyKeys.iterator();
+        while (propertyIterator.hasNext()) {
             String key = (String) propertyIterator.next();
-            if (replacements.get(key) != null) {
-                key = (String) replacements.get(key);
-            }
             Object value = (Object) IntrospectionUtils.getProperty(bean, key);
 
             if (desc.isTransientAttribute(key)) {
@@ -116,8 +113,9 @@ public class ConnectorStoreAppender exte
                 // The property has its default value
                 continue;
             }
-            if (isPrintValue(bean, bean2, key, desc))
+            if (isPrintValue(bean, bean2, key, desc)) {
                 printValue(writer, indent, key, value);
+            }
         }
         String protocol = ((Connector) bean).getProtocol();
         if (protocol != null && !"HTTP/1.1".equals(protocol))
@@ -173,8 +171,12 @@ public class ConnectorStoreAppender exte
                     || (descriptors[i].getWriteMethod() == null)) {
                 continue; // Must be a read-write primitive or String
             }
-            if (!propertyKeys.contains(descriptors[i].getName())) {
-                propertyKeys.add(descriptors[i].getName());
+            String key = descriptors[i].getName();
+            if (replacements.get(key) != null) {
+                key = (String) replacements.get(key);
+            }
+            if (!propertyKeys.contains(key)) {
+                propertyKeys.add(key);
             }
         }
         return propertyKeys;



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to