From: markt Date: Sat, 24 Jul 2010 11:03:00 +0000 (+0000) Subject: More tab police X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=8da02c9cafdfabe9ad7fceafa190b6ffe81a0bbd;p=tomcat7.0 More tab police git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@978845 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/java/org/apache/coyote/RequestInfo.java b/java/org/apache/coyote/RequestInfo.java index 23c06c112..5df4a4182 100644 --- a/java/org/apache/coyote/RequestInfo.java +++ b/java/org/apache/coyote/RequestInfo.java @@ -52,7 +52,7 @@ public class RequestInfo { this.global=global; global.addRequestProcessor( this ); } else { - if (this.global != null) { + if (this.global != null) { this.global.removeRequestProcessor( this ); this.global = null; } diff --git a/java/org/apache/coyote/ajp/AjpMessage.java b/java/org/apache/coyote/ajp/AjpMessage.java index abb1c3751..f62c705f2 100644 --- a/java/org/apache/coyote/ajp/AjpMessage.java +++ b/java/org/apache/coyote/ajp/AjpMessage.java @@ -144,7 +144,7 @@ public class AjpMessage { public void appendByte(int val) { buf[pos++] = (byte) val; } - + /** * Append an int (4 bytes) to the message. @@ -350,7 +350,7 @@ public class AjpMessage { log.error(sm.getString("ajpmessage.read", "" + length)); return 0; } - + if ((length == 0xFFFF) || (length == -1)) { return 0; } diff --git a/java/org/apache/coyote/http11/filters/SavedRequestInputFilter.java b/java/org/apache/coyote/http11/filters/SavedRequestInputFilter.java index d6b2eda04..afe7467ab 100644 --- a/java/org/apache/coyote/http11/filters/SavedRequestInputFilter.java +++ b/java/org/apache/coyote/http11/filters/SavedRequestInputFilter.java @@ -29,9 +29,9 @@ import org.apache.tomcat.util.buf.ByteChunk; */ public class SavedRequestInputFilter implements InputFilter { - /** + /** * The original request body. - */ + */ protected ByteChunk input = null; /** @@ -53,7 +53,7 @@ public class SavedRequestInputFilter implements InputFilter { if (chunk.getLimit() > 0 && chunk.getLimit() < input.getLength()) { writeLength = chunk.getLimit(); } else { - writeLength = input.getLength(); + writeLength = input.getLength(); } if(input.getOffset()>= input.getEnd()) diff --git a/java/org/apache/naming/NamingContextBindingsEnumeration.java b/java/org/apache/naming/NamingContextBindingsEnumeration.java index f73fcf7a7..3a618f898 100644 --- a/java/org/apache/naming/NamingContextBindingsEnumeration.java +++ b/java/org/apache/naming/NamingContextBindingsEnumeration.java @@ -42,7 +42,7 @@ public class NamingContextBindingsEnumeration public NamingContextBindingsEnumeration(Iterator entries, Context ctx) { - iterator = entries; + iterator = entries; this.ctx = ctx; } diff --git a/java/org/apache/naming/NamingContextEnumeration.java b/java/org/apache/naming/NamingContextEnumeration.java index 1bf2e631d..b1d9ed156 100644 --- a/java/org/apache/naming/NamingContextEnumeration.java +++ b/java/org/apache/naming/NamingContextEnumeration.java @@ -39,7 +39,7 @@ public class NamingContextEnumeration public NamingContextEnumeration(Iterator entries) { - iterator = entries; + iterator = entries; } diff --git a/java/org/apache/naming/factory/MailSessionFactory.java b/java/org/apache/naming/factory/MailSessionFactory.java index d52595532..69289bc65 100644 --- a/java/org/apache/naming/factory/MailSessionFactory.java +++ b/java/org/apache/naming/factory/MailSessionFactory.java @@ -89,11 +89,10 @@ public class MailSessionFactory implements ObjectFactory { * @exception Exception if an error occurs during object creation */ public Object getObjectInstance(Object refObj, Name name, Context context, - Hashtable env) throws Exception - { + Hashtable env) throws Exception { // Return null if we cannot create an object of the requested type - final Reference ref = (Reference) refObj; + final Reference ref = (Reference) refObj; if (!ref.getClassName().equals(factoryType)) return (null); @@ -103,7 +102,7 @@ public class MailSessionFactory implements ObjectFactory { // // Bugzilla 31288, 33077: add support for authentication. return AccessController.doPrivileged(new PrivilegedAction() { - public Session run() { + public Session run() { // Create the JavaMail properties we will use Properties props = new Properties(); @@ -148,10 +147,7 @@ public class MailSessionFactory implements ObjectFactory { Session session = Session.getInstance(props, auth); return (session); - } - } ); - + } + } ); } - - } diff --git a/java/org/apache/naming/factory/SendMailFactory.java b/java/org/apache/naming/factory/SendMailFactory.java index 5dcb5e579..3f57441f5 100644 --- a/java/org/apache/naming/factory/SendMailFactory.java +++ b/java/org/apache/naming/factory/SendMailFactory.java @@ -77,51 +77,50 @@ public class SendMailFactory implements ObjectFactory { // The class name for the javamail MimeMessageDataSource protected final String DataSourceClassName = - "javax.mail.internet.MimePartDataSource"; + "javax.mail.internet.MimePartDataSource"; public Object getObjectInstance(Object RefObj, Name Nm, Context Ctx, - Hashtable Env) throws Exception - { - final Reference Ref = (Reference)RefObj; + Hashtable Env) throws Exception { + final Reference Ref = (Reference)RefObj; - // Creation of the DataSource is wrapped inside a doPrivileged - // so that javamail can read its default properties without - // throwing Security Exceptions - if (Ref.getClassName().equals(DataSourceClassName)) { - return AccessController.doPrivileged( - new PrivilegedAction() - { - public MimePartDataSource run() { - // set up the smtp session that will send the message - Properties props = new Properties(); - // enumeration of all refaddr - Enumeration list = Ref.getAll(); - // current refaddr to be set - RefAddr refaddr; - // set transport to smtp - props.put("mail.transport.protocol", "smtp"); + // Creation of the DataSource is wrapped inside a doPrivileged + // so that javamail can read its default properties without + // throwing Security Exceptions + if (Ref.getClassName().equals(DataSourceClassName)) { + return AccessController.doPrivileged( + new PrivilegedAction() + { + public MimePartDataSource run() { + // set up the smtp session that will send the message + Properties props = new Properties(); + // enumeration of all refaddr + Enumeration list = Ref.getAll(); + // current refaddr to be set + RefAddr refaddr; + // set transport to smtp + props.put("mail.transport.protocol", "smtp"); - while (list.hasMoreElements()) { - refaddr = list.nextElement(); + while (list.hasMoreElements()) { + refaddr = list.nextElement(); - // set property - props.put(refaddr.getType(), refaddr.getContent()); - } - MimeMessage message = new MimeMessage( - Session.getInstance(props)); - try { - String from = (String)Ref.get("mail.from").getContent(); - message.setFrom(new InternetAddress(from)); - message.setSubject(""); - } catch (Exception e) {} - MimePartDataSource mds = new MimePartDataSource( - (MimePart)message); - return mds; - } - } ); - } - else { // We can't create an instance of the DataSource - return null; - } + // set property + props.put(refaddr.getType(), refaddr.getContent()); + } + MimeMessage message = new MimeMessage( + Session.getInstance(props)); + try { + String from = (String)Ref.get("mail.from").getContent(); + message.setFrom(new InternetAddress(from)); + message.setSubject(""); + } catch (Exception e) {} + MimePartDataSource mds = new MimePartDataSource( + (MimePart)message); + return mds; + } + } ); + } + else { // We can't create an instance of the DataSource + return null; + } } } diff --git a/java/org/apache/naming/resources/DirContextURLConnection.java b/java/org/apache/naming/resources/DirContextURLConnection.java index 33d3774b1..428ec0223 100644 --- a/java/org/apache/naming/resources/DirContextURLConnection.java +++ b/java/org/apache/naming/resources/DirContextURLConnection.java @@ -67,7 +67,7 @@ public class DirContextURLConnection ("Directory context can't be null"); if (org.apache.naming.Constants.IS_SECURITY_ENABLED) { this.permission = new JndiPermission(url.toString()); - } + } this.context = context; } diff --git a/java/org/apache/naming/resources/FileDirContext.java b/java/org/apache/naming/resources/FileDirContext.java index d5e09e4de..b69490871 100644 --- a/java/org/apache/naming/resources/FileDirContext.java +++ b/java/org/apache/naming/resources/FileDirContext.java @@ -794,9 +794,9 @@ public class FileDirContext extends BaseDirContext { File file = new File(base, name); if (file.exists() && file.canRead()) { - if (allowLinking) - return file; - + if (allowLinking) + return file; + // Check that this file belongs to our root path String canPath = null; try { diff --git a/java/org/apache/naming/resources/RecyclableNamingEnumeration.java b/java/org/apache/naming/resources/RecyclableNamingEnumeration.java index f22a5515f..83a184c58 100644 --- a/java/org/apache/naming/resources/RecyclableNamingEnumeration.java +++ b/java/org/apache/naming/resources/RecyclableNamingEnumeration.java @@ -105,7 +105,7 @@ public class RecyclableNamingEnumeration * Recycle. */ void recycle() { - enumeration = entries.elements(); + enumeration = entries.elements(); } diff --git a/java/org/apache/naming/resources/WARDirContext.java b/java/org/apache/naming/resources/WARDirContext.java index 37791794d..b4e801c51 100644 --- a/java/org/apache/naming/resources/WARDirContext.java +++ b/java/org/apache/naming/resources/WARDirContext.java @@ -121,26 +121,26 @@ public class WARDirContext extends BaseDirContext { @Override public void setDocBase(String docBase) { - // Validate the format of the proposed document root - if (docBase == null) - throw new IllegalArgumentException - (sm.getString("resources.null")); - if (!(docBase.endsWith(".war"))) - throw new IllegalArgumentException - (sm.getString("warResources.notWar")); - - // Calculate a File object referencing this document base directory - File base = new File(docBase); - - // Validate that the document base is an existing directory - if (!base.exists() || !base.canRead() || base.isDirectory()) - throw new IllegalArgumentException - (sm.getString("warResources.invalidWar", docBase)); + // Validate the format of the proposed document root + if (docBase == null) + throw new IllegalArgumentException + (sm.getString("resources.null")); + if (!(docBase.endsWith(".war"))) + throw new IllegalArgumentException + (sm.getString("warResources.notWar")); + + // Calculate a File object referencing this document base directory + File base = new File(docBase); + + // Validate that the document base is an existing directory + if (!base.exists() || !base.canRead() || base.isDirectory()) + throw new IllegalArgumentException + (sm.getString("warResources.invalidWar", docBase)); try { this.base = new ZipFile(base); } catch (Exception e) { - throw new IllegalArgumentException - (sm.getString("warResources.invalidWar", e.getMessage())); + throw new IllegalArgumentException + (sm.getString("warResources.invalidWar", e.getMessage())); } super.setDocBase(docBase); diff --git a/java/org/apache/tomcat/InstanceManager.java b/java/org/apache/tomcat/InstanceManager.java index 2afc21c83..fcb20bd56 100644 --- a/java/org/apache/tomcat/InstanceManager.java +++ b/java/org/apache/tomcat/InstanceManager.java @@ -30,16 +30,16 @@ import javax.naming.NamingException; public interface InstanceManager { public Object newInstance(String className) - throws IllegalAccessException, InvocationTargetException, NamingException, - InstantiationException, ClassNotFoundException; + throws IllegalAccessException, InvocationTargetException, NamingException, + InstantiationException, ClassNotFoundException; public Object newInstance(String fqcn, ClassLoader classLoader) - throws IllegalAccessException, InvocationTargetException, NamingException, - InstantiationException, ClassNotFoundException; + throws IllegalAccessException, InvocationTargetException, NamingException, + InstantiationException, ClassNotFoundException; public void newInstance(Object o) - throws IllegalAccessException, InvocationTargetException, NamingException; + throws IllegalAccessException, InvocationTargetException, NamingException; public void destroyInstance(Object o) - throws IllegalAccessException, InvocationTargetException; + throws IllegalAccessException, InvocationTargetException; } diff --git a/java/org/apache/tomcat/util/IntrospectionUtils.java b/java/org/apache/tomcat/util/IntrospectionUtils.java index 33bc176d3..83ac8e87a 100644 --- a/java/org/apache/tomcat/util/IntrospectionUtils.java +++ b/java/org/apache/tomcat/util/IntrospectionUtils.java @@ -48,7 +48,7 @@ public final class IntrospectionUtils { Method executeM = null; Class c = proxy.getClass(); Class params[] = new Class[0]; - // params[0]=args.getClass(); + // params[0]=args.getClass(); executeM = findMethod(c, method, params); if (executeM == null) { throw new RuntimeException("No execute in " + proxy.getClass()); @@ -164,7 +164,7 @@ public final class IntrospectionUtils { StringTokenizer st = new StringTokenizer(cpath, pathSep); while (st.hasMoreTokens()) { String path = st.nextToken(); - // log( "path " + path ); + // log( "path " + path ); if (path.endsWith(jarName)) { home = path.substring(0, path.length() - jarName.length()); try { diff --git a/java/org/apache/tomcat/util/bcel/Constants.java b/java/org/apache/tomcat/util/bcel/Constants.java index 2c8ad49ba..c4fca620b 100644 --- a/java/org/apache/tomcat/util/bcel/Constants.java +++ b/java/org/apache/tomcat/util/bcel/Constants.java @@ -494,26 +494,26 @@ public interface Constants { /** Attributes and their corresponding names. */ - public static final byte ATTR_UNKNOWN = -1; - public static final byte ATTR_SOURCE_FILE = 0; - public static final byte ATTR_CONSTANT_VALUE = 1; - public static final byte ATTR_CODE = 2; - public static final byte ATTR_EXCEPTIONS = 3; - public static final byte ATTR_LINE_NUMBER_TABLE = 4; - public static final byte ATTR_LOCAL_VARIABLE_TABLE = 5; - public static final byte ATTR_INNER_CLASSES = 6; - public static final byte ATTR_SYNTHETIC = 7; - public static final byte ATTR_DEPRECATED = 8; - public static final byte ATTR_PMG = 9; - public static final byte ATTR_SIGNATURE = 10; - public static final byte ATTR_STACK_MAP = 11; - public static final byte ATTR_RUNTIME_VISIBLE_ANNOTATIONS = 12; - public static final byte ATTR_RUNTIMEIN_VISIBLE_ANNOTATIONS = 13; - public static final byte ATTR_RUNTIME_VISIBLE_PARAMETER_ANNOTATIONS = 14; + public static final byte ATTR_UNKNOWN = -1; + public static final byte ATTR_SOURCE_FILE = 0; + public static final byte ATTR_CONSTANT_VALUE = 1; + public static final byte ATTR_CODE = 2; + public static final byte ATTR_EXCEPTIONS = 3; + public static final byte ATTR_LINE_NUMBER_TABLE = 4; + public static final byte ATTR_LOCAL_VARIABLE_TABLE = 5; + public static final byte ATTR_INNER_CLASSES = 6; + public static final byte ATTR_SYNTHETIC = 7; + public static final byte ATTR_DEPRECATED = 8; + public static final byte ATTR_PMG = 9; + public static final byte ATTR_SIGNATURE = 10; + public static final byte ATTR_STACK_MAP = 11; + public static final byte ATTR_RUNTIME_VISIBLE_ANNOTATIONS = 12; + public static final byte ATTR_RUNTIMEIN_VISIBLE_ANNOTATIONS = 13; + public static final byte ATTR_RUNTIME_VISIBLE_PARAMETER_ANNOTATIONS = 14; public static final byte ATTR_RUNTIMEIN_VISIBLE_PARAMETER_ANNOTATIONS = 15; public static final byte ATTR_ANNOTATION_DEFAULT = 16; public static final byte ATTR_LOCAL_VARIABLE_TYPE_TABLE = 17; - public static final byte ATTR_ENCLOSING_METHOD = 18; + public static final byte ATTR_ENCLOSING_METHOD = 18; public static final byte ATTR_STACK_MAP_TABLE = 19; public static final short KNOWN_ATTRIBUTES = 20; diff --git a/java/org/apache/tomcat/util/bcel/classfile/AnnotationDefault.java b/java/org/apache/tomcat/util/bcel/classfile/AnnotationDefault.java index eef8e16d9..f1099a9e2 100644 --- a/java/org/apache/tomcat/util/bcel/classfile/AnnotationDefault.java +++ b/java/org/apache/tomcat/util/bcel/classfile/AnnotationDefault.java @@ -31,63 +31,63 @@ import org.apache.tomcat.util.bcel.Constants; */ public class AnnotationDefault extends Attribute { - ElementValue default_value; + ElementValue default_value; - /** - * @param annotation_type - * the subclass type of the annotation - * @param name_index - * Index pointing to the name Code - * @param length - * Content length in bytes - * @param file - * Input stream - * @param constant_pool - * Array of constants - */ - public AnnotationDefault(int name_index, int length, - DataInputStream file, ConstantPool constant_pool) - throws IOException - { - this(name_index, length, (ElementValue) null, - constant_pool); - default_value = ElementValue.readElementValue(file, constant_pool); - } + /** + * @param annotation_type + * the subclass type of the annotation + * @param name_index + * Index pointing to the name Code + * @param length + * Content length in bytes + * @param file + * Input stream + * @param constant_pool + * Array of constants + */ + public AnnotationDefault(int name_index, int length, + DataInputStream file, ConstantPool constant_pool) + throws IOException + { + this(name_index, length, (ElementValue) null, + constant_pool); + default_value = ElementValue.readElementValue(file, constant_pool); + } - /** - * @param annotation_type - * the subclass type of the annotation - * @param name_index - * Index pointing to the name Code - * @param length - * Content length in bytes - * @param defaultValue - * the annotation's default value - * @param constant_pool - * Array of constants - */ - public AnnotationDefault(int name_index, int length, - ElementValue defaultValue, ConstantPool constant_pool) - { - super(Constants.ATTR_ANNOTATION_DEFAULT, name_index, length, constant_pool); - setDefaultValue(defaultValue); - } + /** + * @param annotation_type + * the subclass type of the annotation + * @param name_index + * Index pointing to the name Code + * @param length + * Content length in bytes + * @param defaultValue + * the annotation's default value + * @param constant_pool + * Array of constants + */ + public AnnotationDefault(int name_index, int length, + ElementValue defaultValue, ConstantPool constant_pool) + { + super(Constants.ATTR_ANNOTATION_DEFAULT, name_index, length, constant_pool); + setDefaultValue(defaultValue); + } - /** - * @param defaultValue - * the default value of this methodinfo's annotation - */ - public final void setDefaultValue(ElementValue defaultValue) - { - default_value = defaultValue; - } + /** + * @param defaultValue + * the default value of this methodinfo's annotation + */ + public final void setDefaultValue(ElementValue defaultValue) + { + default_value = defaultValue; + } - + - public Attribute copy(ConstantPool _constant_pool) - { - throw new RuntimeException("Not implemented yet!"); - } + public Attribute copy(ConstantPool _constant_pool) + { + throw new RuntimeException("Not implemented yet!"); + } public final void dump(DataOutputStream dos) throws IOException { diff --git a/java/org/apache/tomcat/util/bcel/classfile/AnnotationElementValue.java b/java/org/apache/tomcat/util/bcel/classfile/AnnotationElementValue.java index 007e24f92..d0ff61179 100644 --- a/java/org/apache/tomcat/util/bcel/classfile/AnnotationElementValue.java +++ b/java/org/apache/tomcat/util/bcel/classfile/AnnotationElementValue.java @@ -22,39 +22,39 @@ import java.io.IOException; public class AnnotationElementValue extends ElementValue { - // For annotation element values, this is the annotation - private AnnotationEntry annotationEntry; + // For annotation element values, this is the annotation + private AnnotationEntry annotationEntry; - public AnnotationElementValue(int type, AnnotationEntry annotationEntry, - ConstantPool cpool) - { - super(type, cpool); - if (type != ANNOTATION) - throw new RuntimeException( - "Only element values of type annotation can be built with this ctor - type specified: " + type); - this.annotationEntry = annotationEntry; - } + public AnnotationElementValue(int type, AnnotationEntry annotationEntry, + ConstantPool cpool) + { + super(type, cpool); + if (type != ANNOTATION) + throw new RuntimeException( + "Only element values of type annotation can be built with this ctor - type specified: " + type); + this.annotationEntry = annotationEntry; + } - public void dump(DataOutputStream dos) throws IOException - { - dos.writeByte(type); // u1 type of value (ANNOTATION == '@') - annotationEntry.dump(dos); - } + public void dump(DataOutputStream dos) throws IOException + { + dos.writeByte(type); // u1 type of value (ANNOTATION == '@') + annotationEntry.dump(dos); + } - public String stringifyValue() - { - StringBuffer sb = new StringBuffer(); - sb.append(annotationEntry.toString()); - return sb.toString(); - } + public String stringifyValue() + { + StringBuffer sb = new StringBuffer(); + sb.append(annotationEntry.toString()); + return sb.toString(); + } - public String toString() - { - return stringifyValue(); - } + public String toString() + { + return stringifyValue(); + } - public AnnotationEntry getAnnotationEntry() - { - return annotationEntry; - } + public AnnotationEntry getAnnotationEntry() + { + return annotationEntry; + } } diff --git a/java/org/apache/tomcat/util/bcel/classfile/AnnotationEntry.java b/java/org/apache/tomcat/util/bcel/classfile/AnnotationEntry.java index ed02e8a84..ad8137ba4 100644 --- a/java/org/apache/tomcat/util/bcel/classfile/AnnotationEntry.java +++ b/java/org/apache/tomcat/util/bcel/classfile/AnnotationEntry.java @@ -55,19 +55,15 @@ public class AnnotationEntry implements Constants, Serializable { public static AnnotationEntry read(DataInputStream file, ConstantPool constant_pool, boolean isRuntimeVisible) throws IOException { - AnnotationEntry annotationEntry = new AnnotationEntry(file.readUnsignedShort(), constant_pool, isRuntimeVisible); - annotationEntry.num_element_value_pairs = (file.readUnsignedShort()); - annotationEntry.element_value_pairs = new ArrayList(); + AnnotationEntry annotationEntry = new AnnotationEntry(file.readUnsignedShort(), constant_pool, isRuntimeVisible); + annotationEntry.num_element_value_pairs = (file.readUnsignedShort()); + annotationEntry.element_value_pairs = new ArrayList(); for (int i = 0; i < annotationEntry.num_element_value_pairs; i++) { - annotationEntry.element_value_pairs.add(new ElementValuePair(file.readUnsignedShort(), ElementValue.readElementValue(file, constant_pool), constant_pool)); + annotationEntry.element_value_pairs.add(new ElementValuePair(file.readUnsignedShort(), ElementValue.readElementValue(file, constant_pool), constant_pool)); } return annotationEntry; } - - - - /** * @return the annotation type name */ @@ -76,36 +72,24 @@ public class AnnotationEntry implements Constants, Serializable { c = (ConstantUtf8) constant_pool.getConstant(type_index, CONSTANT_Utf8); return c.getBytes(); } - - - - - - /** * @return the element value pairs in this annotation entry */ public ElementValuePair[] getElementValuePairs() { - // TOFO return List + // TOFO return List return (ElementValuePair[]) element_value_pairs.toArray(new ElementValuePair[element_value_pairs.size()]); } - public void dump(DataOutputStream dos) throws IOException - { - dos.writeShort(type_index); // u2 index of type name in cpool - dos.writeShort(element_value_pairs.size()); // u2 element_value pair count - for (int i = 0 ; i0) { - buf.append("\nAnnotation(s):\n"); - for (int i=0; i 0) { buf.append("\n").append(fields.length).append(" fields:\n"); diff --git a/java/org/apache/tomcat/util/bcel/classfile/LocalVariableTypeTable.java b/java/org/apache/tomcat/util/bcel/classfile/LocalVariableTypeTable.java index 739e7240f..0607a98db 100644 --- a/java/org/apache/tomcat/util/bcel/classfile/LocalVariableTypeTable.java +++ b/java/org/apache/tomcat/util/bcel/classfile/LocalVariableTypeTable.java @@ -22,16 +22,16 @@ import java.io.*; // The new table is used when generic types are about... //LocalVariableTable_attribute { -// u2 attribute_name_index; -// u4 attribute_length; -// u2 local_variable_table_length; -// { u2 start_pc; -// u2 length; -// u2 name_index; -// u2 descriptor_index; -// u2 index; -// } local_variable_table[local_variable_table_length]; -// } +// u2 attribute_name_index; +// u4 attribute_length; +// u2 local_variable_table_length; +// { u2 start_pc; +// u2 length; +// u2 name_index; +// u2 descriptor_index; +// u2 index; +// } local_variable_table[local_variable_table_length]; +// } //LocalVariableTypeTable_attribute { // u2 attribute_name_index; @@ -51,8 +51,8 @@ public class LocalVariableTypeTable extends Attribute { private LocalVariable[] local_variable_type_table; // variables public LocalVariableTypeTable(int name_index, int length, - LocalVariable[] local_variable_table, - ConstantPool constant_pool) + LocalVariable[] local_variable_table, + ConstantPool constant_pool) { super(Constants.ATTR_LOCAL_VARIABLE_TYPE_TABLE, name_index, length, constant_pool); setLocalVariableTable(local_variable_table); diff --git a/java/org/apache/tomcat/util/bcel/classfile/ParameterAnnotationEntry.java b/java/org/apache/tomcat/util/bcel/classfile/ParameterAnnotationEntry.java index eea482b38..4a1c63cf8 100644 --- a/java/org/apache/tomcat/util/bcel/classfile/ParameterAnnotationEntry.java +++ b/java/org/apache/tomcat/util/bcel/classfile/ParameterAnnotationEntry.java @@ -43,7 +43,7 @@ public class ParameterAnnotationEntry implements Constants { annotation_table_length = (file.readUnsignedShort()); annotation_table = new AnnotationEntry[annotation_table_length]; for (int i = 0; i < annotation_table_length; i++) { -// TODO isRuntimeVisible + // TODO isRuntimeVisible annotation_table[i] = AnnotationEntry.read(file, constant_pool, false); } } diff --git a/java/org/apache/tomcat/util/bcel/classfile/RuntimeInvisibleAnnotations.java b/java/org/apache/tomcat/util/bcel/classfile/RuntimeInvisibleAnnotations.java index e14c23e10..2d138f23c 100644 --- a/java/org/apache/tomcat/util/bcel/classfile/RuntimeInvisibleAnnotations.java +++ b/java/org/apache/tomcat/util/bcel/classfile/RuntimeInvisibleAnnotations.java @@ -32,36 +32,36 @@ import org.apache.tomcat.util.bcel.Constants; */ public class RuntimeInvisibleAnnotations extends Annotations { - /** - * @param name_index - * Index pointing to the name Code - * @param length - * Content length in bytes - * @param file - * Input stream - * @param constant_pool - * Array of constants - */ - RuntimeInvisibleAnnotations(int name_index, int length, - DataInputStream file, ConstantPool constant_pool) - throws IOException - { - super(Constants.ATTR_RUNTIMEIN_VISIBLE_ANNOTATIONS, name_index, length, - file, constant_pool, false); - } + /** + * @param name_index + * Index pointing to the name Code + * @param length + * Content length in bytes + * @param file + * Input stream + * @param constant_pool + * Array of constants + */ + RuntimeInvisibleAnnotations(int name_index, int length, + DataInputStream file, ConstantPool constant_pool) + throws IOException + { + super(Constants.ATTR_RUNTIMEIN_VISIBLE_ANNOTATIONS, name_index, length, + file, constant_pool, false); + } - /** - * @return deep copy of this attribute - */ - public Attribute copy(ConstantPool constant_pool) - { - Annotations c = (Annotations) clone(); - return c; - } + /** + * @return deep copy of this attribute + */ + public Attribute copy(ConstantPool constant_pool) + { + Annotations c = (Annotations) clone(); + return c; + } - public final void dump(DataOutputStream dos) throws IOException - { - super.dump(dos); - writeAnnotations(dos); - } + public final void dump(DataOutputStream dos) throws IOException + { + super.dump(dos); + writeAnnotations(dos); + } } diff --git a/java/org/apache/tomcat/util/bcel/classfile/RuntimeVisibleAnnotations.java b/java/org/apache/tomcat/util/bcel/classfile/RuntimeVisibleAnnotations.java index 419281763..f1d684ec0 100644 --- a/java/org/apache/tomcat/util/bcel/classfile/RuntimeVisibleAnnotations.java +++ b/java/org/apache/tomcat/util/bcel/classfile/RuntimeVisibleAnnotations.java @@ -32,36 +32,36 @@ import org.apache.tomcat.util.bcel.Constants; */ public class RuntimeVisibleAnnotations extends Annotations { - /** - * @param name_index - * Index pointing to the name Code - * @param length - * Content length in bytes - * @param file - * Input stream - * @param constant_pool - * Array of constants - */ - public RuntimeVisibleAnnotations(int name_index, int length, - DataInputStream file, ConstantPool constant_pool) - throws IOException - { - super(Constants.ATTR_RUNTIME_VISIBLE_ANNOTATIONS, name_index, length, - file, constant_pool, true); - } + /** + * @param name_index + * Index pointing to the name Code + * @param length + * Content length in bytes + * @param file + * Input stream + * @param constant_pool + * Array of constants + */ + public RuntimeVisibleAnnotations(int name_index, int length, + DataInputStream file, ConstantPool constant_pool) + throws IOException + { + super(Constants.ATTR_RUNTIME_VISIBLE_ANNOTATIONS, name_index, length, + file, constant_pool, true); + } - /** - * @return deep copy of this attribute - */ - public Attribute copy(ConstantPool constant_pool) - { - Annotations c = (Annotations) clone(); - return c; - } + /** + * @return deep copy of this attribute + */ + public Attribute copy(ConstantPool constant_pool) + { + Annotations c = (Annotations) clone(); + return c; + } - public final void dump(DataOutputStream dos) throws IOException - { - super.dump(dos); - writeAnnotations(dos); - } + public final void dump(DataOutputStream dos) throws IOException + { + super.dump(dos); + writeAnnotations(dos); + } } diff --git a/java/org/apache/tomcat/util/bcel/classfile/SimpleElementValue.java b/java/org/apache/tomcat/util/bcel/classfile/SimpleElementValue.java index 0618271d4..ecd354a65 100644 --- a/java/org/apache/tomcat/util/bcel/classfile/SimpleElementValue.java +++ b/java/org/apache/tomcat/util/bcel/classfile/SimpleElementValue.java @@ -23,118 +23,99 @@ import org.apache.tomcat.util.bcel.Constants; public class SimpleElementValue extends ElementValue { - private int index; - - public SimpleElementValue(int type, int index, ConstantPool cpool) - { - super(type, cpool); - this.index = index; - } - - /** - * @return Value entry index in the cpool - */ - public int getIndex() - { - return index; - } - - - - - - - - - - - - - - - - - - - - - - public String toString() - { - return stringifyValue(); - } - - // Whatever kind of value it is, return it as a string - public String stringifyValue() - { - switch (type) - { - case PRIMITIVE_INT: - ConstantInteger c = (ConstantInteger) cpool.getConstant(getIndex(), - Constants.CONSTANT_Integer); - return Integer.toString(c.getBytes()); - case PRIMITIVE_LONG: - ConstantLong j = (ConstantLong) cpool.getConstant(getIndex(), - Constants.CONSTANT_Long); - return Long.toString(j.getBytes()); - case PRIMITIVE_DOUBLE: - ConstantDouble d = (ConstantDouble) cpool.getConstant(getIndex(), - Constants.CONSTANT_Double); - return Double.toString(d.getBytes()); - case PRIMITIVE_FLOAT: - ConstantFloat f = (ConstantFloat) cpool.getConstant(getIndex(), - Constants.CONSTANT_Float); - return Float.toString(f.getBytes()); - case PRIMITIVE_SHORT: - ConstantInteger s = (ConstantInteger) cpool.getConstant(getIndex(), - Constants.CONSTANT_Integer); - return Integer.toString(s.getBytes()); - case PRIMITIVE_BYTE: - ConstantInteger b = (ConstantInteger) cpool.getConstant(getIndex(), - Constants.CONSTANT_Integer); - return Integer.toString(b.getBytes()); - case PRIMITIVE_CHAR: - ConstantInteger ch = (ConstantInteger) cpool.getConstant( - getIndex(), Constants.CONSTANT_Integer); - return String.valueOf((char)ch.getBytes()); - case PRIMITIVE_BOOLEAN: - ConstantInteger bo = (ConstantInteger) cpool.getConstant( - getIndex(), Constants.CONSTANT_Integer); - if (bo.getBytes() == 0) - return "false"; - if (bo.getBytes() != 0) - return "true"; - case STRING: - ConstantUtf8 cu8 = (ConstantUtf8) cpool.getConstant(getIndex(), - Constants.CONSTANT_Utf8); - return cu8.getBytes(); - default: - throw new RuntimeException( - "SimpleElementValue class does not know how to stringify type " - + type); - } - } - - public void dump(DataOutputStream dos) throws IOException - { - dos.writeByte(type); // u1 kind of value - switch (type) - { - case PRIMITIVE_INT: - case PRIMITIVE_BYTE: - case PRIMITIVE_CHAR: - case PRIMITIVE_FLOAT: - case PRIMITIVE_LONG: - case PRIMITIVE_BOOLEAN: - case PRIMITIVE_SHORT: - case PRIMITIVE_DOUBLE: - case STRING: - dos.writeShort(getIndex()); - break; - default: - throw new RuntimeException( - "SimpleElementValue doesnt know how to write out type " - + type); - } - } + private int index; + + public SimpleElementValue(int type, int index, ConstantPool cpool) + { + super(type, cpool); + this.index = index; + } + + /** + * @return Value entry index in the cpool + */ + public int getIndex() + { + return index; + } + + + public String toString() + { + return stringifyValue(); + } + + // Whatever kind of value it is, return it as a string + public String stringifyValue() + { + switch (type) + { + case PRIMITIVE_INT: + ConstantInteger c = (ConstantInteger) cpool.getConstant(getIndex(), + Constants.CONSTANT_Integer); + return Integer.toString(c.getBytes()); + case PRIMITIVE_LONG: + ConstantLong j = (ConstantLong) cpool.getConstant(getIndex(), + Constants.CONSTANT_Long); + return Long.toString(j.getBytes()); + case PRIMITIVE_DOUBLE: + ConstantDouble d = (ConstantDouble) cpool.getConstant(getIndex(), + Constants.CONSTANT_Double); + return Double.toString(d.getBytes()); + case PRIMITIVE_FLOAT: + ConstantFloat f = (ConstantFloat) cpool.getConstant(getIndex(), + Constants.CONSTANT_Float); + return Float.toString(f.getBytes()); + case PRIMITIVE_SHORT: + ConstantInteger s = (ConstantInteger) cpool.getConstant(getIndex(), + Constants.CONSTANT_Integer); + return Integer.toString(s.getBytes()); + case PRIMITIVE_BYTE: + ConstantInteger b = (ConstantInteger) cpool.getConstant(getIndex(), + Constants.CONSTANT_Integer); + return Integer.toString(b.getBytes()); + case PRIMITIVE_CHAR: + ConstantInteger ch = (ConstantInteger) cpool.getConstant( + getIndex(), Constants.CONSTANT_Integer); + return String.valueOf((char)ch.getBytes()); + case PRIMITIVE_BOOLEAN: + ConstantInteger bo = (ConstantInteger) cpool.getConstant( + getIndex(), Constants.CONSTANT_Integer); + if (bo.getBytes() == 0) + return "false"; + if (bo.getBytes() != 0) + return "true"; + case STRING: + ConstantUtf8 cu8 = (ConstantUtf8) cpool.getConstant(getIndex(), + Constants.CONSTANT_Utf8); + return cu8.getBytes(); + default: + throw new RuntimeException( + "SimpleElementValue class does not know how to stringify type " + + type); + } + } + + public void dump(DataOutputStream dos) throws IOException + { + dos.writeByte(type); // u1 kind of value + switch (type) + { + case PRIMITIVE_INT: + case PRIMITIVE_BYTE: + case PRIMITIVE_CHAR: + case PRIMITIVE_FLOAT: + case PRIMITIVE_LONG: + case PRIMITIVE_BOOLEAN: + case PRIMITIVE_SHORT: + case PRIMITIVE_DOUBLE: + case STRING: + dos.writeShort(getIndex()); + break; + default: + throw new RuntimeException( + "SimpleElementValue doesnt know how to write out type " + + type); + } + } } diff --git a/java/org/apache/tomcat/util/bcel/classfile/StackMapTableEntry.java b/java/org/apache/tomcat/util/bcel/classfile/StackMapTableEntry.java index 88d8df0e8..bf6563810 100644 --- a/java/org/apache/tomcat/util/bcel/classfile/StackMapTableEntry.java +++ b/java/org/apache/tomcat/util/bcel/classfile/StackMapTableEntry.java @@ -35,7 +35,7 @@ import org.apache.tomcat.util.bcel.Constants; */ public final class StackMapTableEntry implements Cloneable { - private int frame_type; + private int frame_type; private int byte_code_offset_delta; private int number_of_locals; private StackMapType[] types_of_locals; @@ -52,43 +52,43 @@ public final class StackMapTableEntry implements Cloneable { this(file.read(), -1, -1, null, -1, null); if (frame_type >= Constants.SAME_FRAME && frame_type <= Constants.SAME_FRAME_MAX) { - byte_code_offset_delta = frame_type - Constants.SAME_FRAME; + byte_code_offset_delta = frame_type - Constants.SAME_FRAME; } else if (frame_type >= Constants.SAME_LOCALS_1_STACK_ITEM_FRAME && frame_type <= Constants.SAME_LOCALS_1_STACK_ITEM_FRAME_MAX) { - byte_code_offset_delta = frame_type - Constants.SAME_LOCALS_1_STACK_ITEM_FRAME; - number_of_stack_items = 1; - types_of_stack_items = new StackMapType[1]; - types_of_stack_items[0] = new StackMapType(file, constant_pool); + byte_code_offset_delta = frame_type - Constants.SAME_LOCALS_1_STACK_ITEM_FRAME; + number_of_stack_items = 1; + types_of_stack_items = new StackMapType[1]; + types_of_stack_items[0] = new StackMapType(file, constant_pool); } else if (frame_type == Constants.SAME_LOCALS_1_STACK_ITEM_FRAME_EXTENDED) { - byte_code_offset_delta = file.readShort(); - number_of_stack_items = 1; - types_of_stack_items = new StackMapType[1]; - types_of_stack_items[0] = new StackMapType(file, constant_pool); + byte_code_offset_delta = file.readShort(); + number_of_stack_items = 1; + types_of_stack_items = new StackMapType[1]; + types_of_stack_items[0] = new StackMapType(file, constant_pool); } else if (frame_type >= Constants.CHOP_FRAME && frame_type <= Constants.CHOP_FRAME_MAX) { - byte_code_offset_delta = file.readShort(); + byte_code_offset_delta = file.readShort(); } else if (frame_type == Constants.SAME_FRAME_EXTENDED) { - byte_code_offset_delta = file.readShort(); + byte_code_offset_delta = file.readShort(); } else if (frame_type >= Constants.APPEND_FRAME && frame_type <= Constants.APPEND_FRAME_MAX) { - byte_code_offset_delta = file.readShort(); - number_of_locals = frame_type - 251; - types_of_locals = new StackMapType[number_of_locals]; - for (int i = 0; i < number_of_locals; i++) { - types_of_locals[i] = new StackMapType(file, constant_pool); - } + byte_code_offset_delta = file.readShort(); + number_of_locals = frame_type - 251; + types_of_locals = new StackMapType[number_of_locals]; + for (int i = 0; i < number_of_locals; i++) { + types_of_locals[i] = new StackMapType(file, constant_pool); + } } else if (frame_type == Constants.FULL_FRAME) { - byte_code_offset_delta = file.readShort(); - number_of_locals = file.readShort(); - types_of_locals = new StackMapType[number_of_locals]; - for (int i = 0; i < number_of_locals; i++) { - types_of_locals[i] = new StackMapType(file, constant_pool); - } - number_of_stack_items = file.readShort(); - types_of_stack_items = new StackMapType[number_of_stack_items]; - for (int i = 0; i < number_of_stack_items; i++) { - types_of_stack_items[i] = new StackMapType(file, constant_pool); - } + byte_code_offset_delta = file.readShort(); + number_of_locals = file.readShort(); + types_of_locals = new StackMapType[number_of_locals]; + for (int i = 0; i < number_of_locals; i++) { + types_of_locals[i] = new StackMapType(file, constant_pool); + } + number_of_stack_items = file.readShort(); + types_of_stack_items = new StackMapType[number_of_stack_items]; + for (int i = 0; i < number_of_stack_items; i++) { + types_of_stack_items[i] = new StackMapType(file, constant_pool); + } } else { - /* Can't happen */ - throw new ClassFormatException ("Invalid frame type found while parsing stack map table: " + frame_type); + /* Can't happen */ + throw new ClassFormatException ("Invalid frame type found while parsing stack map table: " + frame_type); } } @@ -96,7 +96,7 @@ public final class StackMapTableEntry implements Cloneable { public StackMapTableEntry(int tag, int byte_code_offset_delta, int number_of_locals, StackMapType[] types_of_locals, int number_of_stack_items, StackMapType[] types_of_stack_items) { - this.frame_type = tag; + this.frame_type = tag; this.byte_code_offset_delta = byte_code_offset_delta; this.number_of_locals = number_of_locals; this.types_of_locals = types_of_locals; @@ -112,21 +112,21 @@ public final class StackMapTableEntry implements Cloneable { * @throws IOException */ public final void dump( DataOutputStream file ) throws IOException { - file.write(frame_type); - if (frame_type >= Constants.SAME_LOCALS_1_STACK_ITEM_FRAME && frame_type <= Constants.SAME_LOCALS_1_STACK_ITEM_FRAME_MAX) { - types_of_stack_items[0].dump(file); + file.write(frame_type); + if (frame_type >= Constants.SAME_LOCALS_1_STACK_ITEM_FRAME && frame_type <= Constants.SAME_LOCALS_1_STACK_ITEM_FRAME_MAX) { + types_of_stack_items[0].dump(file); } else if (frame_type == Constants.SAME_LOCALS_1_STACK_ITEM_FRAME_EXTENDED) { - file.write(byte_code_offset_delta); - types_of_stack_items[0].dump(file); + file.write(byte_code_offset_delta); + types_of_stack_items[0].dump(file); } else if (frame_type >= Constants.CHOP_FRAME && frame_type <= Constants.CHOP_FRAME_MAX) { - file.write(byte_code_offset_delta); + file.write(byte_code_offset_delta); } else if (frame_type == Constants.SAME_FRAME_EXTENDED) { - file.write(byte_code_offset_delta); + file.write(byte_code_offset_delta); } else if (frame_type >= Constants.APPEND_FRAME && frame_type <= Constants.APPEND_FRAME_MAX) { - file.write(byte_code_offset_delta); - for (int i = 0; i < number_of_locals; i++) { - types_of_locals[i].dump(file); - } + file.write(byte_code_offset_delta); + for (int i = 0; i < number_of_locals; i++) { + types_of_locals[i].dump(file); + } } else if (frame_type == Constants.FULL_FRAME) { file.writeShort(byte_code_offset_delta); file.writeShort(number_of_locals); @@ -138,8 +138,8 @@ public final class StackMapTableEntry implements Cloneable { types_of_stack_items[i].dump(file); } } else { - /* Can't happen */ - throw new ClassFormatException ("Invalid Stack map table tag: " + frame_type); + /* Can't happen */ + throw new ClassFormatException ("Invalid Stack map table tag: " + frame_type); } } @@ -151,21 +151,21 @@ public final class StackMapTableEntry implements Cloneable { StringBuffer buf = new StringBuffer(64); buf.append("("); if (frame_type >= Constants.SAME_FRAME && frame_type <= Constants.SAME_FRAME_MAX) { - buf.append("SAME"); + buf.append("SAME"); } else if (frame_type >= Constants.SAME_LOCALS_1_STACK_ITEM_FRAME && frame_type <= Constants.SAME_LOCALS_1_STACK_ITEM_FRAME_MAX) { - buf.append("SAME_LOCALS_1_STACK"); + buf.append("SAME_LOCALS_1_STACK"); } else if (frame_type == Constants.SAME_LOCALS_1_STACK_ITEM_FRAME_EXTENDED) { - buf.append("SAME_LOCALS_1_STACK_EXTENDED"); + buf.append("SAME_LOCALS_1_STACK_EXTENDED"); } else if (frame_type >= Constants.CHOP_FRAME && frame_type <= Constants.CHOP_FRAME_MAX) { - buf.append("CHOP "+(251-frame_type)); + buf.append("CHOP "+(251-frame_type)); } else if (frame_type == Constants.SAME_FRAME_EXTENDED) { - buf.append("SAME_EXTENDED"); + buf.append("SAME_EXTENDED"); } else if (frame_type >= Constants.APPEND_FRAME && frame_type <= Constants.APPEND_FRAME_MAX) { - buf.append("APPEND "+(frame_type-251)); + buf.append("APPEND "+(frame_type-251)); } else if (frame_type == Constants.FULL_FRAME) { - buf.append("FULL"); + buf.append("FULL"); } else { - buf.append("UNKNOWN"); + buf.append("UNKNOWN"); } buf.append(", offset delta=").append(byte_code_offset_delta); if (number_of_locals > 0) { diff --git a/java/org/apache/tomcat/util/buf/C2BConverter.java b/java/org/apache/tomcat/util/buf/C2BConverter.java index 35ab8c028..d75c6b1cb 100644 --- a/java/org/apache/tomcat/util/buf/C2BConverter.java +++ b/java/org/apache/tomcat/util/buf/C2BConverter.java @@ -42,20 +42,20 @@ public final class C2BConverter { /** Create a converter, with bytes going to a byte buffer */ public C2BConverter(ByteChunk output, String encoding) throws IOException { - this.bb=output; - ios=new IntermediateOutputStream( output ); - conv=new WriteConvertor( ios, encoding ); + this.bb=output; + ios=new IntermediateOutputStream( output ); + conv=new WriteConvertor( ios, encoding ); this.enc=encoding; } /** Create a converter */ public C2BConverter(String encoding) throws IOException { - this( new ByteChunk(1024), encoding ); + this( new ByteChunk(1024), encoding ); } public ByteChunk getByteChunk() { - return bb; + return bb; } public String getEncoding() { @@ -63,40 +63,40 @@ public final class C2BConverter { } public void setByteChunk(ByteChunk bb) { - this.bb=bb; - ios.setByteChunk( bb ); + this.bb=bb; + ios.setByteChunk( bb ); } /** Reset the internal state, empty the buffers. * The encoding remain in effect, the internal buffers remain allocated. */ public final void recycle() { - conv.recycle(); - bb.recycle(); + conv.recycle(); + bb.recycle(); } /** Generate the bytes using the specified encoding */ public final void convert(char c[], int off, int len ) throws IOException { - conv.write( c, off, len ); + conv.write( c, off, len ); } /** Generate the bytes using the specified encoding */ public final void convert(String s, int off, int len ) throws IOException { - conv.write( s, off, len ); + conv.write( s, off, len ); } /** Generate the bytes using the specified encoding */ public final void convert(String s ) throws IOException { - conv.write( s ); + conv.write( s ); } /** Generate the bytes using the specified encoding */ public final void convert(char c ) throws IOException { - conv.write( c ); + conv.write( c ); } /** Convert a message bytes chars to bytes @@ -131,7 +131,7 @@ public final class C2BConverter { * byte[] */ public final void flushBuffer() throws IOException { - conv.flush(); + conv.flush(); } } @@ -160,7 +160,7 @@ public final class C2BConverter { * overhead too. * */ - final class WriteConvertor extends OutputStreamWriter { + final class WriteConvertor extends OutputStreamWriter { // stream with flush() and close(). overridden. private IntermediateOutputStream ios; @@ -169,18 +169,18 @@ public final class C2BConverter { /** Create a converter. */ public WriteConvertor( IntermediateOutputStream out, String enc ) - throws UnsupportedEncodingException + throws UnsupportedEncodingException { - super( out, enc ); - ios=out; + super( out, enc ); + ios=out; } /** Overridden - will do nothing but reset internal state. */ @Override public final void close() throws IOException { - // NOTHING - // Calling super.close() would reset out and cb. + // NOTHING + // Calling super.close() would reset out and cb. } /** @@ -188,28 +188,28 @@ public final class C2BConverter { */ @Override public final void flush() throws IOException { - // Will flushBuffer and out() - // flushBuffer put any remaining chars in the byte[] - super.flush(); + // Will flushBuffer and out() + // flushBuffer put any remaining chars in the byte[] + super.flush(); } @Override public final void write(char cbuf[], int off, int len) throws IOException { - // will do the conversion and call write on the output stream - super.write( cbuf, off, len ); + // will do the conversion and call write on the output stream + super.write( cbuf, off, len ); } /** Reset the buffer */ public final void recycle() { - ios.disable(); - try { - // System.out.println("Reseting writer"); - flush(); - } catch( Exception ex ) { - ex.printStackTrace(); - } - ios.enable(); + ios.disable(); + try { + // System.out.println("Reseting writer"); + flush(); + } catch( Exception ex ) { + ex.printStackTrace(); + } + ios.enable(); } } @@ -226,50 +226,50 @@ final class IntermediateOutputStream extends OutputStream { private boolean enabled=true; public IntermediateOutputStream(ByteChunk tbuff) { - this.tbuff=tbuff; + this.tbuff=tbuff; } @Override public final void close() throws IOException { - // shouldn't be called - we filter it out in writer - throw new IOException("close() called - shouldn't happen "); + // shouldn't be called - we filter it out in writer + throw new IOException("close() called - shouldn't happen "); } @Override public final void flush() throws IOException { - // nothing - write will go directly to the buffer, - // we don't keep any state + // nothing - write will go directly to the buffer, + // we don't keep any state } @Override public final void write(byte cbuf[], int off, int len) throws IOException { - // will do the conversion and call write on the output stream - if( enabled ) { - tbuff.append( cbuf, off, len ); - } + // will do the conversion and call write on the output stream + if( enabled ) { + tbuff.append( cbuf, off, len ); + } } @Override public final void write( int i ) throws IOException { - throw new IOException("write( int ) called - shouldn't happen "); + throw new IOException("write( int ) called - shouldn't happen "); } // -------------------- Internal methods -------------------- void setByteChunk( ByteChunk bb ) { - tbuff=bb; + tbuff=bb; } /** Temporary disable - this is used to recycle the converter without * generating an output if the buffers were not flushed */ final void disable() { - enabled=false; + enabled=false; } /** Reenable - used to recycle the converter */ final void enable() { - enabled=true; + enabled=true; } } diff --git a/java/org/apache/tomcat/util/buf/MessageBytes.java b/java/org/apache/tomcat/util/buf/MessageBytes.java index 73744a501..a11256911 100644 --- a/java/org/apache/tomcat/util/buf/MessageBytes.java +++ b/java/org/apache/tomcat/util/buf/MessageBytes.java @@ -73,36 +73,36 @@ public final class MessageBytes implements Cloneable, Serializable { /** Construct a new MessageBytes instance */ public static MessageBytes newInstance() { - return factory.newInstance(); + return factory.newInstance(); } public MessageBytes getClone() { - try { - return (MessageBytes)this.clone(); - } catch( Exception ex) { - return null; - } + try { + return (MessageBytes)this.clone(); + } catch( Exception ex) { + return null; + } } public boolean isNull() { -// should we check also hasStrValue ??? - return byteC.isNull() && charC.isNull() && ! hasStrValue; - // bytes==null && strValue==null; + // should we check also hasStrValue ??? + return byteC.isNull() && charC.isNull() && ! hasStrValue; + // bytes==null && strValue==null; } /** * Resets the message bytes to an uninitialized (NULL) state. */ public void recycle() { - type=T_NULL; - byteC.recycle(); - charC.recycle(); + type=T_NULL; + byteC.recycle(); + charC.recycle(); - strValue=null; + strValue=null; - hasStrValue=false; - hasHashCode=false; - hasIntValue=false; + hasStrValue=false; + hasHashCode=false; + hasIntValue=false; hasLongValue=false; } @@ -128,12 +128,12 @@ public final class MessageBytes implements Cloneable, Serializable { * If no encoding is set, we'll use 8859-1. */ public void setEncoding( String enc ) { - if( !byteC.isNull() ) { - // if the encoding changes we need to reset the conversion results - charC.recycle(); - hasStrValue=false; - } - byteC.setEncoding(enc); + if( !byteC.isNull() ) { + // if the encoding changes we need to reset the conversion results + charC.recycle(); + hasStrValue=false; + } + byteC.setEncoding(enc); } /** @@ -153,16 +153,16 @@ public final class MessageBytes implements Cloneable, Serializable { } /** Remove the cached string value. Use it after a conversion on the - * byte[] or after the encoding is changed + * byte[] or after the encoding is changed * XXX Is this needed ? */ public void resetStringValue() { - if( type != T_STR ) { - // If this was created as a byte[] or char[], we remove - // the old string value - hasStrValue=false; - strValue=null; - } + if( type != T_STR ) { + // If this was created as a byte[] or char[], we remove + // the old string value + hasStrValue=false; + strValue=null; + } } /** @@ -208,7 +208,7 @@ public final class MessageBytes implements Cloneable, Serializable { * T_STR, T_BYTES, T_CHARS or T_NULL */ public int getType() { - return type; + return type; } /** @@ -216,7 +216,7 @@ public final class MessageBytes implements Cloneable, Serializable { * Valid only if T_BYTES or after a conversion was made. */ public ByteChunk getByteChunk() { - return byteC; + return byteC; } /** @@ -224,7 +224,7 @@ public final class MessageBytes implements Cloneable, Serializable { * Valid only if T_CHARS or after a conversion was made. */ public CharChunk getCharChunk() { - return charC; + return charC; } /** @@ -232,7 +232,7 @@ public final class MessageBytes implements Cloneable, Serializable { * Valid only if T_STR or after a conversion was made. */ public String getString() { - return strValue; + return strValue; } /** Do a char->byte conversion. @@ -252,15 +252,15 @@ public final class MessageBytes implements Cloneable, Serializable { * XXX Not optimized - it converts to String first. */ public void toChars() { - if( ! charC.isNull() ) { + if( ! charC.isNull() ) { type=T_CHARS; - return; - } - // inefficient - toString(); + return; + } + // inefficient + toString(); type=T_CHARS; - char cc[]=strValue.toCharArray(); - charC.setChars(cc, 0, cc.length); + char cc[]=strValue.toCharArray(); + charC.setChars(cc, 0, cc.length); } @@ -270,16 +270,16 @@ public final class MessageBytes implements Cloneable, Serializable { * in chars. */ public int getLength() { - if(type==T_BYTES) - return byteC.getLength(); - if(type==T_CHARS) { - return charC.getLength(); - } - if(type==T_STR) - return strValue.length(); - toString(); - if( strValue==null ) return 0; - return strValue.length(); + if(type==T_BYTES) + return byteC.getLength(); + if(type==T_CHARS) { + return charC.getLength(); + } + if(type==T_STR) + return strValue.length(); + toString(); + if( strValue==null ) return 0; + return strValue.length(); } // -------------------- equals -------------------- @@ -290,17 +290,17 @@ public final class MessageBytes implements Cloneable, Serializable { * @return true if the comparison succeeded, false otherwise */ public boolean equals(String s) { - switch (type) { - case T_STR: - if( strValue==null && s!=null) return false; - return strValue.equals( s ); - case T_CHARS: - return charC.equals( s ); - case T_BYTES: - return byteC.equals( s ); - default: - return false; - } + switch (type) { + case T_STR: + if( strValue==null && s!=null) return false; + return strValue.equals( s ); + case T_CHARS: + return charC.equals( s ); + case T_BYTES: + return byteC.equals( s ); + default: + return false; + } } /** @@ -309,49 +309,49 @@ public final class MessageBytes implements Cloneable, Serializable { * @return true if the comparison succeeded, false otherwise */ public boolean equalsIgnoreCase(String s) { - switch (type) { - case T_STR: - if( strValue==null && s!=null) return false; - return strValue.equalsIgnoreCase( s ); - case T_CHARS: - return charC.equalsIgnoreCase( s ); - case T_BYTES: - return byteC.equalsIgnoreCase( s ); - default: - return false; - } + switch (type) { + case T_STR: + if( strValue==null && s!=null) return false; + return strValue.equalsIgnoreCase( s ); + case T_CHARS: + return charC.equalsIgnoreCase( s ); + case T_BYTES: + return byteC.equalsIgnoreCase( s ); + default: + return false; + } } public boolean equals(MessageBytes mb) { - switch (type) { - case T_STR: - return mb.equals( strValue ); - } - - if( mb.type != T_CHARS && - mb.type!= T_BYTES ) { - // it's a string or int/date string value - return equals( mb.toString() ); - } - - // mb is either CHARS or BYTES. - // this is either CHARS or BYTES - // Deal with the 4 cases ( in fact 3, one is symmetric) - - if( mb.type == T_CHARS && type==T_CHARS ) { - return charC.equals( mb.charC ); - } - if( mb.type==T_BYTES && type== T_BYTES ) { - return byteC.equals( mb.byteC ); - } - if( mb.type== T_CHARS && type== T_BYTES ) { - return byteC.equals( mb.charC ); - } - if( mb.type== T_BYTES && type== T_CHARS ) { - return mb.byteC.equals( charC ); - } - // can't happen - return true; + switch (type) { + case T_STR: + return mb.equals( strValue ); + } + + if( mb.type != T_CHARS && + mb.type!= T_BYTES ) { + // it's a string or int/date string value + return equals( mb.toString() ); + } + + // mb is either CHARS or BYTES. + // this is either CHARS or BYTES + // Deal with the 4 cases ( in fact 3, one is symmetric) + + if( mb.type == T_CHARS && type==T_CHARS ) { + return charC.equals( mb.charC ); + } + if( mb.type==T_BYTES && type== T_BYTES ) { + return byteC.equals( mb.byteC ); + } + if( mb.type== T_CHARS && type== T_BYTES ) { + return byteC.equals( mb.charC ); + } + if( mb.type== T_BYTES && type== T_CHARS ) { + return mb.byteC.equals( charC ); + } + // can't happen + return true; } @@ -360,16 +360,16 @@ public final class MessageBytes implements Cloneable, Serializable { * @param s the string */ public boolean startsWith(String s) { - switch (type) { - case T_STR: - return strValue.startsWith( s ); - case T_CHARS: - return charC.startsWith( s ); - case T_BYTES: - return byteC.startsWith( s ); - default: - return false; - } + switch (type) { + case T_STR: + return strValue.startsWith( s ); + case T_CHARS: + return charC.startsWith( s ); + case T_BYTES: + return byteC.startsWith( s ); + default: + return false; + } } /** @@ -378,25 +378,25 @@ public final class MessageBytes implements Cloneable, Serializable { * @param pos The start position */ public boolean startsWithIgnoreCase(String s, int pos) { - switch (type) { - case T_STR: - if( strValue==null ) return false; - if( strValue.length() < pos + s.length() ) return false; - - for( int i=0; i getDefaults() { return defaultRules; - } + } // --------------------------------------------------------- Public Methods @@ -114,7 +114,7 @@ public class WithDefaultsRulesWrapper implements Rules { */ public List match(String namespaceURI, String pattern) { List matches = wrappedRules.match(namespaceURI, pattern); - if (matches == null || matches.isEmpty()) { + if (matches == null || matches.isEmpty()) { // a little bit of defensive programming return new ArrayList(defaultRules); } @@ -156,5 +156,5 @@ public class WithDefaultsRulesWrapper implements Rules { public void add(String pattern, Rule rule) { wrappedRules.add(pattern, rule); allRules.add(rule); - } + } } diff --git a/java/org/apache/tomcat/util/http/CookieSupport.java b/java/org/apache/tomcat/util/http/CookieSupport.java index 1aed47362..53906073d 100644 --- a/java/org/apache/tomcat/util/http/CookieSupport.java +++ b/java/org/apache/tomcat/util/http/CookieSupport.java @@ -24,7 +24,6 @@ package org.apache.tomcat.util.http; */ public final class CookieSupport { - // --------------------------------------------------------------- Constants /** * If set to true, we parse cookies strictly according to the servlet, diff --git a/java/org/apache/tomcat/util/modeler/BaseModelMBean.java b/java/org/apache/tomcat/util/modeler/BaseModelMBean.java index 3441d6210..8cf3677f0 100644 --- a/java/org/apache/tomcat/util/modeler/BaseModelMBean.java +++ b/java/org/apache/tomcat/util/modeler/BaseModelMBean.java @@ -1139,40 +1139,40 @@ public class BaseModelMBean implements DynamicMBean, MBeanRegistration, ModelMBe } static class MethodKey { - private String name; - private String[] signature; - - MethodKey(String name, String[] signature) { - this.name = name; - if(signature == null) { - signature = new String[0]; - } - this.signature = signature; - } - - @Override - public boolean equals(Object other) { - if(!(other instanceof MethodKey)) { - return false; - } - MethodKey omk = (MethodKey)other; - if(!name.equals(omk.name)) { - return false; - } - if(signature.length != omk.signature.length) { - return false; - } - for(int i=0; i < signature.length; i++) { - if(!signature[i].equals(omk.signature[i])) { - return false; - } - } - return true; - } - - @Override - public int hashCode() { - return name.hashCode(); - } + private String name; + private String[] signature; + + MethodKey(String name, String[] signature) { + this.name = name; + if(signature == null) { + signature = new String[0]; + } + this.signature = signature; + } + + @Override + public boolean equals(Object other) { + if(!(other instanceof MethodKey)) { + return false; + } + MethodKey omk = (MethodKey)other; + if(!name.equals(omk.name)) { + return false; + } + if(signature.length != omk.signature.length) { + return false; + } + for(int i=0; i < signature.length; i++) { + if(!signature[i].equals(omk.signature[i])) { + return false; + } + } + return true; + } + + @Override + public int hashCode() { + return name.hashCode(); + } } } diff --git a/java/org/apache/tomcat/util/net/DefaultServerSocketFactory.java b/java/org/apache/tomcat/util/net/DefaultServerSocketFactory.java index aeb77a2ef..0b9230004 100644 --- a/java/org/apache/tomcat/util/net/DefaultServerSocketFactory.java +++ b/java/org/apache/tomcat/util/net/DefaultServerSocketFactory.java @@ -61,15 +61,14 @@ class DefaultServerSocketFactory extends ServerSocketFactory { @Override public Socket acceptSocket(ServerSocket socket) - throws IOException { - return socket.accept(); + throws IOException { + return socket.accept(); } @Override public void handshake(Socket sock) - throws IOException { + throws IOException { // NOOP } - - } +} diff --git a/java/org/apache/tomcat/util/net/JIoEndpoint.java b/java/org/apache/tomcat/util/net/JIoEndpoint.java index b20a2d8f3..f393c5d76 100644 --- a/java/org/apache/tomcat/util/net/JIoEndpoint.java +++ b/java/org/apache/tomcat/util/net/JIoEndpoint.java @@ -242,44 +242,44 @@ public class JIoEndpoint extends AbstractEndpoint { public void run() { boolean launch = false; - try { - - if (!socket.processing.compareAndSet(false, true)) { - log.error("Unable to process socket. Invalid state."); - return; - } - - SocketState state = SocketState.OPEN; - // Process the request from this socket - if ( (!socket.isInitialized()) && (!setSocketOptions(socket.getSocket())) ) { - state = SocketState.CLOSED; - } - socket.setInitialized(true); - - if ( (state != SocketState.CLOSED) ) { - state = (status==null)?handler.process(socket):handler.process(socket,status); - } - if (state == SocketState.CLOSED) { - // Close socket - if (log.isTraceEnabled()) { - log.trace("Closing socket:"+socket); - } - try { - socket.getSocket().close(); - } catch (IOException e) { - // Ignore - } - } else if (state == SocketState.OPEN){ - socket.setKeptAlive(true); - socket.access(); - //keepalive connection - //TODO - servlet3 check async status, we may just be in a hold pattern - launch = true; - } else if (state == SocketState.LONG) { - socket.access(); - waitingRequests.add(socket); - } - } finally { + try { + + if (!socket.processing.compareAndSet(false, true)) { + log.error("Unable to process socket. Invalid state."); + return; + } + + SocketState state = SocketState.OPEN; + // Process the request from this socket + if ( (!socket.isInitialized()) && (!setSocketOptions(socket.getSocket())) ) { + state = SocketState.CLOSED; + } + socket.setInitialized(true); + + if ( (state != SocketState.CLOSED) ) { + state = (status==null)?handler.process(socket):handler.process(socket,status); + } + if (state == SocketState.CLOSED) { + // Close socket + if (log.isTraceEnabled()) { + log.trace("Closing socket:"+socket); + } + try { + socket.getSocket().close(); + } catch (IOException e) { + // Ignore + } + } else if (state == SocketState.OPEN){ + socket.setKeptAlive(true); + socket.access(); + //keepalive connection + //TODO - servlet3 check async status, we may just be in a hold pattern + launch = true; + } else if (state == SocketState.LONG) { + socket.access(); + waitingRequests.add(socket); + } + } finally { socket.processing.set(false); if (launch) getExecutor().execute(new SocketProcessor(socket)); socket = null; diff --git a/java/org/apache/tomcat/util/net/NioBlockingSelector.java b/java/org/apache/tomcat/util/net/NioBlockingSelector.java index 8a157ffc2..5bd10ac38 100644 --- a/java/org/apache/tomcat/util/net/NioBlockingSelector.java +++ b/java/org/apache/tomcat/util/net/NioBlockingSelector.java @@ -266,13 +266,13 @@ public class NioBlockingSelector { if (SelectionKey.OP_READ==(ops&SelectionKey.OP_READ))countDown(key.getReadLatch()); } else { if (sk.isValid()) { - sk.interestOps(sk.interestOps() & (~ops)); - if (SelectionKey.OP_WRITE==(ops&SelectionKey.OP_WRITE)) countDown(key.getWriteLatch()); - if (SelectionKey.OP_READ==(ops&SelectionKey.OP_READ))countDown(key.getReadLatch()); - if (sk.interestOps()==0) { - sk.cancel(); - sk.attach(null); - } + sk.interestOps(sk.interestOps() & (~ops)); + if (SelectionKey.OP_WRITE==(ops&SelectionKey.OP_WRITE)) countDown(key.getWriteLatch()); + if (SelectionKey.OP_READ==(ops&SelectionKey.OP_READ))countDown(key.getReadLatch()); + if (sk.interestOps()==0) { + sk.cancel(); + sk.attach(null); + } }else { sk.cancel(); sk.attach(null); diff --git a/java/org/apache/tomcat/util/net/SSLImplementation.java b/java/org/apache/tomcat/util/net/SSLImplementation.java index 0627ef77b..fed307885 100644 --- a/java/org/apache/tomcat/util/net/SSLImplementation.java +++ b/java/org/apache/tomcat/util/net/SSLImplementation.java @@ -23,65 +23,66 @@ import javax.net.ssl.SSLSession; /* SSLImplementation: - Abstract factory and base class for all SSL implementations. + Abstract factory and base class for all SSL implementations. - @author EKR -*/ + @author EKR + */ abstract public class SSLImplementation { - private static final org.apache.juli.logging.Log logger = - org.apache.juli.logging.LogFactory.getLog(SSLImplementation.class); + private static final org.apache.juli.logging.Log logger = org.apache.juli.logging.LogFactory + .getLog(SSLImplementation.class); // The default implementations in our search path - private static final String JSSEImplementationClass= - "org.apache.tomcat.util.net.jsse.JSSEImplementation"; - - private static final String[] implementations= - { - JSSEImplementationClass - }; - - public static SSLImplementation getInstance() throws ClassNotFoundException - { - for(int i=0;i clazz=Class.forName(className); - return (SSLImplementation)clazz.newInstance(); - } catch (Exception e){ - if(logger.isDebugEnabled()) - logger.debug("Error loading SSL Implementation " - +className, e); - throw new ClassNotFoundException("Error loading SSL Implementation " - +className+ " :" +e.toString()); - } + throws ClassNotFoundException { + if (className == null) + return getInstance(); + + try { + // Workaround for the J2SE 1.4.x classloading problem (under + // Solaris). + // Class.forName(..) fails without creating class using new. + // This is an ugly workaround. + if (JSSEImplementationClass.equals(className)) { + return new org.apache.tomcat.util.net.jsse.JSSEImplementation(); + } + Class clazz = Class.forName(className); + return (SSLImplementation) clazz.newInstance(); + } catch (Exception e) { + if (logger.isDebugEnabled()) + logger + .debug("Error loading SSL Implementation " + className, + e); + throw new ClassNotFoundException( + "Error loading SSL Implementation " + className + " :" + + e.toString()); + } } abstract public String getImplementationName(); + abstract public ServerSocketFactory getServerSocketFactory(); + abstract public SSLSupport getSSLSupport(Socket sock); + abstract public SSLSupport getSSLSupport(SSLSession session); -} +} diff --git a/java/org/apache/tomcat/util/net/ServerSocketFactory.java b/java/org/apache/tomcat/util/net/ServerSocketFactory.java index c8f20ae86..d87223cd3 100644 --- a/java/org/apache/tomcat/util/net/ServerSocketFactory.java +++ b/java/org/apache/tomcat/util/net/ServerSocketFactory.java @@ -24,151 +24,152 @@ import java.net.Socket; import java.util.Hashtable; /** - * This class creates server sockets. It may be subclassed by other - * factories, which create particular types of server sockets. This - * provides a general framework for the addition of public socket-level - * functionality. It it is the server side analogue of a socket factory, - * and similarly provides a way to capture a variety of policies related - * to the sockets being constructed. - * - *

Like socket factories, Server Socket factory instances have two - * categories of methods. First are methods used to create sockets. - * Second are methods which set properties used in the production of - * sockets, such as networking options. There is also an environment - * specific default server socket factory; frameworks will often use - * their own customized factory. - * - *


It may be desirable to move this interface into the + * This class creates server sockets. It may be subclassed by other factories, + * which create particular types of server sockets. This provides a general + * framework for the addition of public socket-level functionality. It it is the + * server side analogue of a socket factory, and similarly provides a way to + * capture a variety of policies related to the sockets being constructed. + *

+ * Like socket factories, Server Socket factory instances have two categories of + * methods. First are methods used to create sockets. Second are methods which + * set properties used in the production of sockets, such as networking options. + * There is also an environment specific default server socket factory; + * frameworks will often use their own customized factory. + *

+ *


+ * It may be desirable to move this interface into the * java.net package, so that is not an extension but the preferred * interface. Should this be serializable, making it a JavaBean which can * be saved along with its networking configuration? - * - * + *
+ * * @author db@eng.sun.com * @author Harish Prabandham */ public abstract class ServerSocketFactory implements Cloneable { // - // NOTE: JDK 1.1 bug in class GC, this can get collected + // NOTE: JDK 1.1 bug in class GC, this can get collected // even though it's always accessible via getDefault(). // private static ServerSocketFactory theFactory; - protected Hashtable attributes = - new Hashtable(); + protected Hashtable attributes = new Hashtable(); /** * Constructor is used only by subclasses. */ - - protected ServerSocketFactory () { + protected ServerSocketFactory() { /* NOTHING */ } - /** General mechanism to pass attributes from the - * ServerConnector to the socket factory. - * - * Note that the "preferred" mechanism is to - * use bean setters and explicit methods, but - * this allows easy configuration via server.xml - * or simple Properties + /** + * General mechanism to pass attributes from the ServerConnector to the + * socket factory. Note that the "preferred" mechanism is to use bean + * setters and explicit methods, but this allows easy configuration via + * server.xml or simple Properties */ - public void setAttribute( String name, Object value ) { - if( name!=null && value !=null) - attributes.put( name, value ); + public void setAttribute(String name, Object value) { + if (name != null && value != null) + attributes.put(name, value); } - + /** * Returns a copy of the environment's default socket factory. */ - public static synchronized ServerSocketFactory getDefault () { + public static synchronized ServerSocketFactory getDefault() { // - // optimize typical case: no synch needed + // optimize typical case: no synch needed // if (theFactory == null) { // // Different implementations of this method could - // work rather differently. For example, driving + // work rather differently. For example, driving // this from a system property, or using a different // implementation than JavaSoft's. // - theFactory = new DefaultServerSocketFactory (); + theFactory = new DefaultServerSocketFactory(); } try { - return (ServerSocketFactory) theFactory.clone (); + return (ServerSocketFactory) theFactory.clone(); } catch (CloneNotSupportedException e) { - throw new RuntimeException (e.getMessage ()); + throw new RuntimeException(e.getMessage()); } } /** - * Returns a server socket which uses all network interfaces on - * the host, and is bound to a the specified port. The socket is - * configured with the socket options (such as accept timeout) + * Returns a server socket which uses all network interfaces on the host, + * and is bound to a the specified port. The socket is configured with the + * socket options (such as accept timeout) given to this factory. + * + * @param port + * the port to listen to + * @exception IOException + * for networking errors + * @exception InstantiationException + * for construction errors + */ + public abstract ServerSocket createSocket(int port) throws IOException, + InstantiationException; + + /** + * Returns a server socket which uses all network interfaces on the host, is + * bound to a the specified port, and uses the specified connection backlog. + * The socket is configured with the socket options (such as accept timeout) * given to this factory. - * - * @param port the port to listen to - * @exception IOException for networking errors - * @exception InstantiationException for construction errors + * + * @param port + * the port to listen to + * @param backlog + * how many connections are queued + * @exception IOException + * for networking errors + * @exception InstantiationException + * for construction errors */ - public abstract ServerSocket createSocket (int port) - throws IOException, InstantiationException; + public abstract ServerSocket createSocket(int port, int backlog) + throws IOException, InstantiationException; /** - * Returns a server socket which uses all network interfaces on - * the host, is bound to a the specified port, and uses the - * specified connection backlog. The socket is configured with - * the socket options (such as accept timeout) given to this factory. - * - * @param port the port to listen to - * @param backlog how many connections are queued - * @exception IOException for networking errors - * @exception InstantiationException for construction errors + * Returns a server socket which uses only the specified network interface + * on the local host, is bound to a the specified port, and uses the + * specified connection backlog. The socket is configured with the socket + * options (such as accept timeout) given to this factory. + * + * @param port + * the port to listen to + * @param backlog + * how many connections are queued + * @param ifAddress + * the network interface address to use + * @exception IOException + * for networking errors + * @exception InstantiationException + * for construction errors */ + public abstract ServerSocket createSocket(int port, int backlog, + InetAddress ifAddress) throws IOException, InstantiationException; - public abstract ServerSocket createSocket (int port, int backlog) - throws IOException, InstantiationException; + public void initSocket(Socket s) { + } /** - * Returns a server socket which uses only the specified network - * interface on the local host, is bound to a the specified port, - * and uses the specified connection backlog. The socket is configured - * with the socket options (such as accept timeout) given to this factory. - * - * @param port the port to listen to - * @param backlog how many connections are queued - * @param ifAddress the network interface address to use - * @exception IOException for networking errors - * @exception InstantiationException for construction errors + * Wrapper function for accept(). This allows us to trap and translate + * exceptions if necessary + * + * @exception IOException + * ; */ + public abstract Socket acceptSocket(ServerSocket socket) throws IOException; - public abstract ServerSocket createSocket (int port, - int backlog, InetAddress ifAddress) - throws IOException, InstantiationException; - - public void initSocket( Socket s ) { - } - - /** - Wrapper function for accept(). This allows us to trap and - translate exceptions if necessary - - @exception IOException; - */ - public abstract Socket acceptSocket(ServerSocket socket) - throws IOException; - - /** - Extra function to initiate the handshake. Sometimes necessary - for SSL - - @exception IOException; - */ - public abstract void handshake(Socket sock) - throws IOException; + /** + * Extra function to initiate the handshake. Sometimes necessary for SSL + * + * @exception IOException + * ; + */ + public abstract void handshake(Socket sock) throws IOException; } - diff --git a/java/org/apache/tomcat/util/net/jsse/JSSESocketFactory.java b/java/org/apache/tomcat/util/net/jsse/JSSESocketFactory.java index df0be92f5..34941558c 100644 --- a/java/org/apache/tomcat/util/net/jsse/JSSESocketFactory.java +++ b/java/org/apache/tomcat/util/net/jsse/JSSESocketFactory.java @@ -168,9 +168,9 @@ public class JSSESocketFactory @Override public void handshake(Socket sock) throws IOException { // We do getSession instead of startHandshake() so we can call this multiple times - SSLSession session = ((SSLSocket)sock).getSession(); + SSLSession session = ((SSLSocket)sock).getSession(); if (session.getCipherSuite().equals("SSL_NULL_WITH_NULL_NULL")) - throw new IOException("SSL handshake failed. Ciper suite in SSL Session is SSL_NULL_WITH_NULL_NULL"); + throw new IOException("SSL handshake failed. Ciper suite in SSL Session is SSL_NULL_WITH_NULL_NULL"); if (!allowUnsafeLegacyRenegotiation) { // Prevent futher handshakes by removing all cipher suites