Author: kkolinko Date: Thu Nov 10 06:27:27 2011 New Revision: 1200184 URL: http://svn.apache.org/viewvc?rev=1200184&view=rev Log: Merged revision 1187753 from tomcat/trunk: Clean-up. No functional change. Part 10, the last one. Updating mergeinfo.
Modified: tomcat/tc7.0.x/trunk/ (props changed) tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/http/FastHttpDateFormat.java tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/http/HttpMessages.java tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/http/MimeHeaders.java tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/http/Parameters.java Propchange: tomcat/tc7.0.x/trunk/ ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Thu Nov 10 06:27:27 2011 @@ -1 +1 @@ -/tomcat/trunk:1156115,1156171,1156276,1156304,1156519,1156530,1156602,1157015,1157018,1157151,1157198,1157204,1157810,1157832,1157834,1157847,1157908,1157939,1158155,1158160,1158176,1158195,1158198-1158199,1158227,1158331,1158334-1158335,1158426,1160347,1160592,1160611,1160619,1160626,1160639,1160652,1160720-1160721,1160772,1160774,1160776,1161303,1161310,1161322,1161339,1161486,1161540,1161549,1161584,1162082,1162149,1162169,1162721,1162769,1162836,1162932,1163630,1164419,1164438,1164469,1164480,1164567,1165234,1165247-1165248,1165253,1165273,1165282,1165309,1165331,1165338,1165347,1165360-1165361,1165367-1165368,1165602,1165608,1165677,1165693,1165721,1165723,1165728,1165730,1165738,1165746,1165765,1165777,1165918,1165921,1166077,1166150-1166151,1166290,1166366,1166620,1166686,1166693,1166752,1166757,1167368,1167394,1169447,1170647,1171692,1172233-1172234,1172236,1172269,1172278,1172282,1172556,1172610,1172664,1172689,1172711,1173020-1173021,1173082,1173088,1173090,1173096 ,1173241,1173256,1173288,1173333,1173342,1173461,1173614,1173630,1173659,1173722,1174061,1174239,1174322,1174325,1174329-1174330,1174337-1174339,1174343,1174353,1174799,1174882,1174884,1174983,1175155,1175158,1175167,1175182,1175190,1175201,1175272,1175275,1175283,1175582,1175589-1175590,1175594,1175602,1175613,1175633,1175690,1175713,1175798,1175889,1175896,1175907,1176584,1176590,1176799,1177050,1177060,1177125,1177152,1177160,1177245,1177850,1177862,1177978,1178209,1178228,1178233,1178449,1178542,1178681,1178684,1178721,1179268,1179274,1180261,1180865,1180891,1180894,1180907,1181028,1181123,1181125,1181136,1181291,1181743,1182796,1183078,1183105,1183142,1183328,1183339-1183340,1183492-1183494,1183605,1184917,1184919,1185018,1185020,1185200,1185588,1185626,1185756,1185758,1186011,1186042-1186045,1186104,1186123,1186137,1186153,1186254,1186257,1186377-1186379,1186479-1186480,1186712,1186743,1186750,1186763,1186890-1186892,1186894,1186949,1187018,1187027-1187028,1187381,1187 755,1187775,1187801,1187806,1187809,1187827,1188301,1188303-1188305,1188399,1188822,1188930-1188931,1189116,1189129,1189183,1189240,1189256,1189386,1189413-1189414,1189477,1189685,1189805,1189857,1189864,1189882,1190034,1190185,1190279,1190339,1190371,1190388-1190389,1190474,1190481,1194915,1195222-1195223,1195531,1195899,1195905,1195943,1195949,1195953,1195955,1195965,1195968,1196175,1196212,1196223,1196304-1196305,1196735,1196825,1196827,1197158,1197261,1197263,1197299-1197300,1197305,1197339-1197340,1197343,1197382,1197386-1197387,1197480,1197578,1198497,1198528,1198552,1198602,1198604,1198607,1198622,1198640,1199418,1199432,1199436,1199513,1199529,1199980,1199996,1200106 +/tomcat/trunk:1156115,1156171,1156276,1156304,1156519,1156530,1156602,1157015,1157018,1157151,1157198,1157204,1157810,1157832,1157834,1157847,1157908,1157939,1158155,1158160,1158176,1158195,1158198-1158199,1158227,1158331,1158334-1158335,1158426,1160347,1160592,1160611,1160619,1160626,1160639,1160652,1160720-1160721,1160772,1160774,1160776,1161303,1161310,1161322,1161339,1161486,1161540,1161549,1161584,1162082,1162149,1162169,1162721,1162769,1162836,1162932,1163630,1164419,1164438,1164469,1164480,1164567,1165234,1165247-1165248,1165253,1165273,1165282,1165309,1165331,1165338,1165347,1165360-1165361,1165367-1165368,1165602,1165608,1165677,1165693,1165721,1165723,1165728,1165730,1165738,1165746,1165765,1165777,1165918,1165921,1166077,1166150-1166151,1166290,1166366,1166620,1166686,1166693,1166752,1166757,1167368,1167394,1169447,1170647,1171692,1172233-1172234,1172236,1172269,1172278,1172282,1172556,1172610,1172664,1172689,1172711,1173020-1173021,1173082,1173088,1173090,1173096 ,1173241,1173256,1173288,1173333,1173342,1173461,1173614,1173630,1173659,1173722,1174061,1174239,1174322,1174325,1174329-1174330,1174337-1174339,1174343,1174353,1174799,1174882,1174884,1174983,1175155,1175158,1175167,1175182,1175190,1175201,1175272,1175275,1175283,1175582,1175589-1175590,1175594,1175602,1175613,1175633,1175690,1175713,1175798,1175889,1175896,1175907,1176584,1176590,1176799,1177050,1177060,1177125,1177152,1177160,1177245,1177850,1177862,1177978,1178209,1178228,1178233,1178449,1178542,1178681,1178684,1178721,1179268,1179274,1180261,1180865,1180891,1180894,1180907,1181028,1181123,1181125,1181136,1181291,1181743,1182796,1183078,1183105,1183142,1183328,1183339-1183340,1183492-1183494,1183605,1184917,1184919,1185018,1185020,1185200,1185588,1185626,1185756,1185758,1186011,1186042-1186045,1186104,1186123,1186137,1186153,1186254,1186257,1186377-1186379,1186479-1186480,1186712,1186743,1186750,1186763,1186890-1186892,1186894,1186949,1187018,1187027-1187028,1187381,1187 753,1187755,1187775,1187801,1187806,1187809,1187827,1188301,1188303-1188305,1188399,1188822,1188930-1188931,1189116,1189129,1189183,1189240,1189256,1189386,1189413-1189414,1189477,1189685,1189805,1189857,1189864,1189882,1190034,1190185,1190279,1190339,1190371,1190388-1190389,1190474,1190481,1194915,1195222-1195223,1195531,1195899,1195905,1195943,1195949,1195953,1195955,1195965,1195968,1196175,1196212,1196223,1196304-1196305,1196735,1196825,1196827,1197158,1197261,1197263,1197299-1197300,1197305,1197339-1197340,1197343,1197382,1197386-1197387,1197480,1197578,1198497,1198528,1198552,1198602,1198604,1198607,1198622,1198640,1199418,1199432,1199436,1199513,1199529,1199980,1199996,1200106 Modified: tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/http/FastHttpDateFormat.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/http/FastHttpDateFormat.java?rev=1200184&r1=1200183&r2=1200184&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/http/FastHttpDateFormat.java (original) +++ tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/http/FastHttpDateFormat.java Thu Nov 10 06:27:27 2011 @@ -14,7 +14,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.apache.tomcat.util.http; import java.text.DateFormat; @@ -27,7 +26,7 @@ import java.util.concurrent.ConcurrentHa /** * Utility class to generate HTTP dates. - * + * * @author Remy Maucherat */ public final class FastHttpDateFormat { @@ -36,14 +35,14 @@ public final class FastHttpDateFormat { // -------------------------------------------------------------- Variables - private static final int CACHE_SIZE = + private static final int CACHE_SIZE = Integer.parseInt(System.getProperty("org.apache.tomcat.util.http.FastHttpDateFormat.CACHE_SIZE", "1000")); - + /** * HTTP date format. */ - private static final SimpleDateFormat format = + private static final SimpleDateFormat format = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.US); @@ -89,14 +88,14 @@ public final class FastHttpDateFormat { /** * Formatter cache. */ - private static final ConcurrentHashMap<Long, String> formatCache = + private static final ConcurrentHashMap<Long, String> formatCache = new ConcurrentHashMap<Long, String>(CACHE_SIZE); /** * Parser cache. */ - private static final ConcurrentHashMap<String, Long> parseCache = + private static final ConcurrentHashMap<String, Long> parseCache = new ConcurrentHashMap<String, Long>(CACHE_SIZE); @@ -130,8 +129,9 @@ public final class FastHttpDateFormat { Long longValue = new Long(value); String cachedDate = formatCache.get(longValue); - if (cachedDate != null) + if (cachedDate != null) { return cachedDate; + } String newDate = null; Date dateValue = new Date(value); @@ -154,12 +154,13 @@ public final class FastHttpDateFormat { /** * Try to parse the given date as a HTTP date. */ - public static final long parseDate(String value, + public static final long parseDate(String value, DateFormat[] threadLocalformats) { Long cachedDate = parseCache.get(value); - if (cachedDate != null) + if (cachedDate != null) { return cachedDate.longValue(); + } Long date = null; if (threadLocalformats != null) { Modified: tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/http/HttpMessages.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/http/HttpMessages.java?rev=1200184&r1=1200183&r2=1200184&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/http/HttpMessages.java (original) +++ tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/http/HttpMessages.java Thu Nov 10 06:27:27 2011 @@ -14,14 +14,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.apache.tomcat.util.http; import org.apache.tomcat.util.res.StringManager; /** * Handle (internationalized) HTTP messages. - * + * * @author James Duncan Davidson [dun...@eng.sun.com] * @author James Todd [go...@eng.sun.com] * @author Jason Hunter [j...@eng.sun.com] @@ -32,12 +31,12 @@ public class HttpMessages { // XXX move message resources in this package protected static final StringManager sm = StringManager.getManager("org.apache.tomcat.util.http.res"); - + static String st_200=null; static String st_302=null; static String st_400=null; static String st_404=null; - + /** Get the status string associated with a status code. * No I18N - return the messages defined in the HTTP spec. * ( the user isn't supposed to see them, this is the last @@ -48,21 +47,29 @@ public class HttpMessages { */ public static String getMessage( int status ) { // method from Response. - + // Does HTTP requires/allow international messages or // are pre-defined? The user doesn't see them most of the time switch( status ) { case 200: - if( st_200==null ) st_200=sm.getString( "sc.200"); + if( st_200==null ) { + st_200=sm.getString( "sc.200"); + } return st_200; case 302: - if( st_302==null ) st_302=sm.getString( "sc.302"); + if( st_302==null ) { + st_302=sm.getString( "sc.302"); + } return st_302; case 400: - if( st_400==null ) st_400=sm.getString( "sc.400"); + if( st_400==null ) { + st_400=sm.getString( "sc.400"); + } return st_400; case 404: - if( st_404==null ) st_404=sm.getString( "sc.404"); + if( st_404==null ) { + st_404=sm.getString( "sc.404"); + } return st_404; } return sm.getString("sc."+ status); @@ -77,8 +84,9 @@ public class HttpMessages { */ public static String filter(String message) { - if (message == null) + if (message == null) { return (null); + } char content[] = new char[message.length()]; message.getChars(0, message.length(), content, 0); @@ -107,7 +115,7 @@ public class HttpMessages { /** * Is the provided message safe to use in an HTTP header. Safe messages must * meet the requirements of RFC2616 - i.e. must consist only of TEXT. - * + * * @param msg The message to test * @return <code>true</code> if the message is safe to use in an HTTP * header else <code>false</code> Modified: tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/http/MimeHeaders.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/http/MimeHeaders.java?rev=1200184&r1=1200183&r2=1200184&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/http/MimeHeaders.java (original) +++ tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/http/MimeHeaders.java Thu Nov 10 06:27:27 2011 @@ -14,7 +14,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.apache.tomcat.util.http; import java.io.PrintWriter; @@ -53,16 +52,16 @@ import org.apache.tomcat.util.buf.Messag directly access all headers, and most headers are single-valued. ( the alternative - a hash or similar data structure - will add an overhead that is not needed in most cases ) - + Apache seems to be using a similar method for storing and manipulating headers. - + Future enhancements: - hash the headers the first time a header is requested ( i.e. if the servlet needs direct access to headers). - scan "common" values ( length, cookies, etc ) during the parse ( addHeader hook ) - + */ @@ -83,8 +82,8 @@ import org.apache.tomcat.util.buf.Messag * XXX remove unused methods * XXX External enumerations, with 0 GC. * XXX use HeaderName ID - * - * + * + * * @author d...@eng.sun.com * @author James Todd [go...@eng.sun.com] * @author Costin Manolache @@ -95,7 +94,7 @@ public class MimeHeaders { * XXX make it configurable ( fine-tuning of web-apps ) */ public static final int DEFAULT_HEADER_SIZE=8; - + /** * The header fields. */ @@ -154,7 +153,7 @@ public class MimeHeaders { } // -------------------- Idx access to headers ---------- - + /** * Returns the current number of header fields. */ @@ -182,7 +181,7 @@ public class MimeHeaders { */ public int findHeader( String name, int starting ) { // We can use a hash - but it's not clear how much - // benefit you can get - there is an overhead + // benefit you can get - there is an overhead // and the number of headers is small (4-5 ?) // Another problem is that we'll pay the overhead // of constructing the hashtable @@ -195,7 +194,7 @@ public class MimeHeaders { } return -1; } - + // -------------------- -------------------- /** @@ -212,7 +211,7 @@ public class MimeHeaders { } // -------------------- Adding headers -------------------- - + /** * Adds a partially constructed field to the header. This @@ -263,7 +262,7 @@ public class MimeHeaders { return mhf.getValue(); } - /** Allow "set" operations - + /** Allow "set" operations - return a MessageBytes container for the header value ( existing header or new if this . @@ -302,7 +301,7 @@ public class MimeHeaders { /** * Finds and returns a unique header field with the given name. If no such * field exists, null is returned. If the specified header field is not - * unique then an {@link IllegalArgumentException} is thrown. + * unique then an {@link IllegalArgumentException} is thrown. */ public MessageBytes getUniqueValue(String name) { MessageBytes result = null; @@ -348,7 +347,7 @@ public class MimeHeaders { */ private void removeHeader(int idx) { MimeHeaderField mh = headers[idx]; - + mh.recycle(); headers[idx] = headers[count - 1]; headers[count - 1] = mh; @@ -397,7 +396,7 @@ class NamesEnumerator implements Enumera // next element pos++; } - + @Override public boolean hasMoreElements() { return next!=null; @@ -440,7 +439,7 @@ class ValuesEnumerator implements Enumer } pos++; } - + @Override public boolean hasMoreElements() { return next!=null; @@ -459,8 +458,8 @@ class MimeHeaderField { // speed up name enumerations and search ( both cpu and // GC) MimeHeaderField next; - MimeHeaderField prev; - + MimeHeaderField prev; + protected final MessageBytes nameB = MessageBytes.newInstance(); protected final MessageBytes valueB = MessageBytes.newInstance(); Modified: tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/http/Parameters.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/http/Parameters.java?rev=1200184&r1=1200183&r2=1200184&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/http/Parameters.java (original) +++ tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/http/Parameters.java Thu Nov 10 06:27:27 2011 @@ -14,7 +14,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.apache.tomcat.util.http; import java.io.IOException; @@ -34,7 +33,7 @@ import org.apache.tomcat.util.buf.UDecod import org.apache.tomcat.util.res.StringManager; /** - * + * * @author Costin Manolache */ public final class Parameters { @@ -49,7 +48,7 @@ public final class Parameters { new HashMap<String,ArrayList<String>>(); private boolean didQueryParameters=false; - + MessageBytes queryMB; UDecoder urlDec; @@ -57,7 +56,7 @@ public final class Parameters { String encoding=null; String queryStringEncoding=null; - + private int limit = -1; private int parameterCount = 0; @@ -98,11 +97,11 @@ public final class Parameters { encoding=null; decodedQuery.recycle(); } - + // -------------------- Data access -------------------- // Access to the current name/values, no side effect ( processing ). // You must explicitly call handleQueryParameters and the post methods. - + @Deprecated public void addParameterValues(String key, String[] newValues) { if (key == null) { @@ -129,7 +128,7 @@ public final class Parameters { } return values.toArray(new String[values.size()]); } - + public Enumeration<String> getParameterNames() { handleQueryParameters(); return Collections.enumeration(paramHashValues.keySet()); @@ -151,13 +150,16 @@ public final class Parameters { /** Process the query string into parameters */ public void handleQueryParameters() { - if( didQueryParameters ) return; + if( didQueryParameters ) { + return; + } didQueryParameters=true; - if( queryMB==null || queryMB.isNull() ) + if( queryMB==null || queryMB.isNull() ) { return; - + } + if(log.isDebugEnabled()) { log.debug("Decoding query " + decodedQuery + " " + queryStringEncoding); @@ -176,7 +178,9 @@ public final class Parameters { public void addParameter( String key, String value ) throws IllegalStateException { - if( key==null ) return; + if( key==null ) { + return; + } parameterCount ++; if (limit > -1 && parameterCount > limit) { @@ -203,28 +207,28 @@ public final class Parameters { // if needed ByteChunk tmpName=new ByteChunk(); ByteChunk tmpValue=new ByteChunk(); - private ByteChunk origName=new ByteChunk(); - private ByteChunk origValue=new ByteChunk(); + private final ByteChunk origName=new ByteChunk(); + private final ByteChunk origValue=new ByteChunk(); CharChunk tmpNameC=new CharChunk(1024); public static final String DEFAULT_ENCODING = "ISO-8859-1"; private static final Charset DEFAULT_CHARSET = Charset.forName(DEFAULT_ENCODING); - - + + public void processParameters( byte bytes[], int start, int len ) { processParameters(bytes, start, len, getCharset(encoding)); } private void processParameters(byte bytes[], int start, int len, Charset charset) { - + if(log.isDebugEnabled()) { log.debug(sm.getString("parameters.bytes", new String(bytes, start, len, DEFAULT_CHARSET))); } int decodeFailCount = 0; - + int pos = start; int end = start + len; @@ -277,6 +281,7 @@ public final class Parameters { break; } } while (!parameterComplete && pos < end); + } if (pos == end) { if (nameEnd == -1) { @@ -285,14 +290,14 @@ public final class Parameters { valueEnd = pos; } } - + if (log.isDebugEnabled() && valueStart == -1) { log.debug(sm.getString("parameters.noequal", Integer.valueOf(nameStart), Integer.valueOf(nameEnd), new String(bytes, nameStart, nameEnd-nameStart, DEFAULT_CHARSET))); } - + if (nameEnd <= nameStart ) { if (log.isInfoEnabled()) { String extract; @@ -313,7 +318,7 @@ public final class Parameters { continue; // invalid chunk - it's better to ignore } - + tmpName.setBytes(bytes, nameStart, nameEnd - nameStart); tmpValue.setBytes(bytes, valueStart, valueEnd - valueStart); @@ -329,7 +334,7 @@ public final class Parameters { log.error(sm.getString("paramerers.copyFail"), ioe); } } - + try { String name; String value; @@ -385,13 +390,15 @@ public final class Parameters { private void urlDecode(ByteChunk bc) throws IOException { if( urlDec==null ) { - urlDec=new UDecoder(); + urlDec=new UDecoder(); } urlDec.convert(bc); } public void processParameters( MessageBytes data, String encoding ) { - if( data==null || data.isNull() || data.getLength() <= 0 ) return; + if( data==null || data.isNull() || data.getLength() <= 0 ) { + return; + } if( data.getType() != MessageBytes.T_BYTES ) { data.toBytes(); --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org