Author: remm Date: Wed Feb 24 09:57:14 2016 New Revision: 1732051 URL: http://svn.apache.org/viewvc?rev=1732051&view=rev Log: Port storeconfig fixes from trunk (cookie processor, socket properties, more compact XML output).
Modified: tomcat/tc8.0.x/trunk/java/org/apache/catalina/storeconfig/ConnectorStoreAppender.java tomcat/tc8.0.x/trunk/java/org/apache/catalina/storeconfig/StoreAppender.java tomcat/tc8.0.x/trunk/java/org/apache/catalina/storeconfig/StoreRegistry.java tomcat/tc8.0.x/trunk/java/org/apache/catalina/storeconfig/server-registry.xml tomcat/tc8.0.x/trunk/java/org/apache/tomcat/util/IntrospectionUtils.java tomcat/tc8.0.x/trunk/java/org/apache/tomcat/util/net/AbstractEndpoint.java tomcat/tc8.0.x/trunk/webapps/docs/changelog.xml Modified: tomcat/tc8.0.x/trunk/java/org/apache/catalina/storeconfig/ConnectorStoreAppender.java URL: http://svn.apache.org/viewvc/tomcat/tc8.0.x/trunk/java/org/apache/catalina/storeconfig/ConnectorStoreAppender.java?rev=1732051&r1=1732050&r2=1732051&view=diff ============================================================================== --- tomcat/tc8.0.x/trunk/java/org/apache/catalina/storeconfig/ConnectorStoreAppender.java (original) +++ tomcat/tc8.0.x/trunk/java/org/apache/catalina/storeconfig/ConnectorStoreAppender.java Wed Feb 24 09:57:14 2016 @@ -31,6 +31,7 @@ import java.util.List; import org.apache.catalina.connector.Connector; import org.apache.coyote.ProtocolHandler; import org.apache.tomcat.util.IntrospectionUtils; +import org.apache.tomcat.util.net.SocketProperties; /** * Store the Connector attributes. Connector has really special design. A @@ -93,7 +94,6 @@ public class ConnectorStoreAppender exte while (propertyIterator.hasNext()) { String key = propertyIterator.next(); Object value = IntrospectionUtils.getProperty(bean, key); - if (desc.isTransientAttribute(key)) { continue; // Skip the specified exceptions } @@ -135,20 +135,20 @@ public class ConnectorStoreAppender exte if (descriptors == null) { descriptors = new PropertyDescriptor[0]; } - for (int i = 0; i < descriptors.length; i++) { - if (descriptors[i] instanceof IndexedPropertyDescriptor) { + for (PropertyDescriptor descriptor : descriptors) { + if (descriptor instanceof IndexedPropertyDescriptor) { continue; // Indexed properties are not persisted } - if (!isPersistable(descriptors[i].getPropertyType()) - || (descriptors[i].getReadMethod() == null) - || (descriptors[i].getWriteMethod() == null)) { + if (!isPersistable(descriptor.getPropertyType()) + || (descriptor.getReadMethod() == null) + || (descriptor.getWriteMethod() == null)) { continue; // Must be a read-write primitive or String } - if ("protocol".equals(descriptors[i].getName()) - || "protocolHandlerClassName".equals(descriptors[i] + if ("protocol".equals(descriptor.getName()) + || "protocolHandlerClassName".equals(descriptor .getName())) continue; - propertyKeys.add(descriptors[i].getName()); + propertyKeys.add(descriptor.getName()); } // Add the properties of the protocol handler descriptors = Introspector.getBeanInfo( @@ -156,16 +156,16 @@ public class ConnectorStoreAppender exte if (descriptors == null) { descriptors = new PropertyDescriptor[0]; } - for (int i = 0; i < descriptors.length; i++) { - if (descriptors[i] instanceof IndexedPropertyDescriptor) { + for (PropertyDescriptor descriptor : descriptors) { + if (descriptor instanceof IndexedPropertyDescriptor) { continue; // Indexed properties are not persisted } - if (!isPersistable(descriptors[i].getPropertyType()) - || (descriptors[i].getReadMethod() == null) - || (descriptors[i].getWriteMethod() == null)) { + if (!isPersistable(descriptor.getPropertyType()) + || (descriptor.getReadMethod() == null) + || (descriptor.getWriteMethod() == null)) { continue; // Must be a read-write primitive or String } - String key = descriptors[i].getName(); + String key = descriptor.getName(); if (replacements.get(key) != null) { key = replacements.get(key); } @@ -173,6 +173,32 @@ public class ConnectorStoreAppender exte propertyKeys.add(key); } } + // Add the properties for the socket + final String socketName = "socket."; + descriptors = Introspector.getBeanInfo( + SocketProperties.class).getPropertyDescriptors(); + if (descriptors == null) { + descriptors = new PropertyDescriptor[0]; + } + for (PropertyDescriptor descriptor : descriptors) { + if (descriptor instanceof IndexedPropertyDescriptor) { + continue; // Indexed properties are not persisted + } + if (!isPersistable(descriptor.getPropertyType()) + || (descriptor.getReadMethod() == null) + || (descriptor.getWriteMethod() == null)) { + continue; // Must be a read-write primitive or String + } + String key = descriptor.getName(); + if (replacements.get(key) != null) { + key = replacements.get(key); + } + if (!propertyKeys.contains(key)) { + // Add socket.[original name] if this is not a property + // that could be set elsewhere + propertyKeys.add(socketName + descriptor.getName()); + } + } return propertyKeys; } Modified: tomcat/tc8.0.x/trunk/java/org/apache/catalina/storeconfig/StoreAppender.java URL: http://svn.apache.org/viewvc/tomcat/tc8.0.x/trunk/java/org/apache/catalina/storeconfig/StoreAppender.java?rev=1732051&r1=1732050&r2=1732051&view=diff ============================================================================== --- tomcat/tc8.0.x/trunk/java/org/apache/catalina/storeconfig/StoreAppender.java (original) +++ tomcat/tc8.0.x/trunk/java/org/apache/catalina/storeconfig/StoreAppender.java Wed Feb 24 09:57:14 2016 @@ -41,6 +41,8 @@ public class StoreAppender { Float.class, Float.TYPE, Long.class, Long.TYPE, Short.class, Short.TYPE, InetAddress.class }; + private static int pos = 0; + /** * print the closing tag * @@ -167,6 +169,7 @@ public class StoreAppender { for (int i = 0; i < indent; i++) { aWriter.print(' '); } + pos = indent; } /** @@ -336,11 +339,16 @@ public class StoreAppender { if (!(value instanceof String)) { value = value.toString(); } - writer.println(); - printIndent(writer, indent + 4); + String strValue = convertStr((String) value); + pos = pos + name.length() + strValue.length(); + if (pos > 60) { + writer.println(); + printIndent(writer, indent + 4); + } else { + writer.print(' '); + } writer.print(name); writer.print("=\""); - String strValue = convertStr((String) value); writer.print(strValue); writer.print("\""); } Modified: tomcat/tc8.0.x/trunk/java/org/apache/catalina/storeconfig/StoreRegistry.java URL: http://svn.apache.org/viewvc/tomcat/tc8.0.x/trunk/java/org/apache/catalina/storeconfig/StoreRegistry.java?rev=1732051&r1=1732050&r2=1732051&view=diff ============================================================================== --- tomcat/tc8.0.x/trunk/java/org/apache/catalina/storeconfig/StoreRegistry.java (original) +++ tomcat/tc8.0.x/trunk/java/org/apache/catalina/storeconfig/StoreRegistry.java Wed Feb 24 09:57:14 2016 @@ -42,6 +42,7 @@ import org.apache.catalina.tribes.Messag import org.apache.catalina.tribes.transport.DataSender; import org.apache.juli.logging.Log; import org.apache.juli.logging.LogFactory; +import org.apache.tomcat.util.http.CookieProcessor; /** * Central StoreRegistry for all server.xml elements @@ -65,7 +66,7 @@ public class StoreRegistry { Valve.class, ClusterListener.class, MessageListener.class, DataSender.class, ChannelInterceptor.class, Member.class, WebResourceRoot.class, WebResourceSet.class, - CredentialHandler.class }; + CredentialHandler.class, CookieProcessor.class }; /** * @return Returns the name. Modified: tomcat/tc8.0.x/trunk/java/org/apache/catalina/storeconfig/server-registry.xml URL: http://svn.apache.org/viewvc/tomcat/tc8.0.x/trunk/java/org/apache/catalina/storeconfig/server-registry.xml?rev=1732051&r1=1732050&r2=1732051&view=diff ============================================================================== --- tomcat/tc8.0.x/trunk/java/org/apache/catalina/storeconfig/server-registry.xml (original) +++ tomcat/tc8.0.x/trunk/java/org/apache/catalina/storeconfig/server-registry.xml Wed Feb 24 09:57:14 2016 @@ -438,9 +438,9 @@ </Description> <Description tag="CookieProcessor" - standard="true" + standard="false" default="false" - tagClass="org.apache.tomcat.util.http.LegacyCookieProcessor" + tagClass="org.apache.tomcat.util.http.CookieProcessor" storeFactoryClass="org.apache.catalina.storeconfig.StoreFactoryBase"> </Description> <Description Modified: tomcat/tc8.0.x/trunk/java/org/apache/tomcat/util/IntrospectionUtils.java URL: http://svn.apache.org/viewvc/tomcat/tc8.0.x/trunk/java/org/apache/tomcat/util/IntrospectionUtils.java?rev=1732051&r1=1732050&r2=1732051&view=diff ============================================================================== --- tomcat/tc8.0.x/trunk/java/org/apache/tomcat/util/IntrospectionUtils.java (original) +++ tomcat/tc8.0.x/trunk/java/org/apache/tomcat/util/IntrospectionUtils.java Wed Feb 24 09:57:14 2016 @@ -214,6 +214,10 @@ public final class IntrospectionUtils { log.warn("IntrospectionUtils: IllegalAccessException for " + o.getClass() + " " + name + ")", iae); } catch (InvocationTargetException ie) { + if (ie.getCause() instanceof NullPointerException) { + // Assume the underlying object uses a storage to represent an unset property + return null; + } ExceptionUtils.handleThrowable(ie.getCause()); log.warn("IntrospectionUtils: InvocationTargetException for " + o.getClass() + " " + name + ")", ie); Modified: tomcat/tc8.0.x/trunk/java/org/apache/tomcat/util/net/AbstractEndpoint.java URL: http://svn.apache.org/viewvc/tomcat/tc8.0.x/trunk/java/org/apache/tomcat/util/net/AbstractEndpoint.java?rev=1732051&r1=1732050&r2=1732051&view=diff ============================================================================== --- tomcat/tc8.0.x/trunk/java/org/apache/tomcat/util/net/AbstractEndpoint.java (original) +++ tomcat/tc8.0.x/trunk/java/org/apache/tomcat/util/net/AbstractEndpoint.java Wed Feb 24 09:57:14 2016 @@ -519,7 +519,15 @@ public abstract class AbstractEndpoint<S } } public String getProperty(String name) { - return (String) getAttribute(name); + String value = (String) getAttribute(name); + final String socketName = "socket."; + if (value == null && name.startsWith(socketName)) { + Object result = IntrospectionUtils.getProperty(socketProperties, name.substring(socketName.length())); + if (result != null) { + value = result.toString(); + } + } + return value; } /** Modified: tomcat/tc8.0.x/trunk/webapps/docs/changelog.xml URL: http://svn.apache.org/viewvc/tomcat/tc8.0.x/trunk/webapps/docs/changelog.xml?rev=1732051&r1=1732050&r2=1732051&view=diff ============================================================================== --- tomcat/tc8.0.x/trunk/webapps/docs/changelog.xml (original) +++ tomcat/tc8.0.x/trunk/webapps/docs/changelog.xml Wed Feb 24 09:57:14 2016 @@ -103,6 +103,12 @@ does not trigger an error when the Valve registers itself in the session. (markt) </fix> + <fix> + Storeconfig handling of alternate cookie processors. (markt/remm) + </fix> + <fix> + Storeconfig handling for socket properties. (remm) + </fix> </changelog> </subsection> <subsection name="Coyote"> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org