~ubuntu-branches/ubuntu/utopic/jetty/utopic-proposed

« back to all changes in this revision

Viewing changes to patches/java5.patch

  • Committer: Bazaar Package Importer
  • Author(s): Torsten Werner
  • Date: 2009-08-09 08:48:10 UTC
  • Revision ID: james.westby@ubuntu.com-20090809084810-k522b97ind2robyd
ImportĀ upstreamĀ versionĀ 6.1.19

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
Index: modules/jetty/pom.xml
 
2
===================================================================
 
3
--- modules/jetty/pom.xml       (revision 4733)
 
4
+++ modules/jetty/pom.xml       (working copy)
 
5
@@ -36,6 +36,13 @@
 
6
         </executions>
 
7
       </plugin>
 
8
       <plugin>
 
9
+        <artifactId>maven-compiler-plugin</artifactId>
 
10
+        <configuration>
 
11
+          <source>1.5</source>
 
12
+          <target>1.5</target>
 
13
+        </configuration>
 
14
+      </plugin>
 
15
+      <plugin>
 
16
         <artifactId>maven-antrun-plugin</artifactId>
 
17
         <executions>
 
18
           <execution>
 
19
Index: modules/jetty/src/main/java/org/mortbay/io/AbstractBuffer.java
 
20
===================================================================
 
21
--- modules/jetty/src/main/java/org/mortbay/io/AbstractBuffer.java      (revision 4733)
 
22
+++ modules/jetty/src/main/java/org/mortbay/io/AbstractBuffer.java      (working copy)
 
23
@@ -558,7 +558,7 @@
 
24
 
 
25
     public String toDetailString()
 
26
     {
 
27
-        StringBuffer buf = new StringBuffer();
 
28
+        StringBuilder buf = new StringBuilder();
 
29
         buf.append("[");
 
30
         buf.append(super.hashCode());
 
31
         buf.append(",");
 
32
Index: modules/jetty/src/main/java/org/mortbay/io/BufferUtil.java
 
33
===================================================================
 
34
--- modules/jetty/src/main/java/org/mortbay/io/BufferUtil.java  (revision 4733)
 
35
+++ modules/jetty/src/main/java/org/mortbay/io/BufferUtil.java  (working copy)
 
36
@@ -315,7 +315,7 @@
 
37
             if (bytes!=null)
 
38
                 return new String(bytes,buffer.getIndex(),buffer.length(),StringUtil.__ISO_8859_1);
 
39
             
 
40
-            StringBuffer b = new StringBuffer(buffer.length());
 
41
+            StringBuilder b = new StringBuilder(buffer.length());
 
42
             for (int i=buffer.getIndex(),c=0;c<buffer.length();i++,c++)
 
43
                 b.append((char)(0x7f&buffer.peek(i)));
 
44
             return b.toString();
 
45
Index: modules/jetty/src/main/java/org/mortbay/jetty/handler/ContextHandler.java
 
46
===================================================================
 
47
--- modules/jetty/src/main/java/org/mortbay/jetty/handler/ContextHandler.java   (revision 4733)
 
48
+++ modules/jetty/src/main/java/org/mortbay/jetty/handler/ContextHandler.java   (working copy)
 
49
@@ -349,7 +349,7 @@
 
50
             return null;
 
51
         URLClassLoader loader = (URLClassLoader)_classLoader;
 
52
         URL[] urls =loader.getURLs();
 
53
-        StringBuffer classpath=new StringBuffer();
 
54
+        StringBuilder classpath=new StringBuilder();
 
55
         for (int i=0;i<urls.length;i++)
 
56
         {
 
57
             try
 
58
Index: modules/jetty/src/main/java/org/mortbay/jetty/HttpGenerator.java
 
59
===================================================================
 
60
--- modules/jetty/src/main/java/org/mortbay/jetty/HttpGenerator.java    (revision 4733)
 
61
+++ modules/jetty/src/main/java/org/mortbay/jetty/HttpGenerator.java    (working copy)
 
62
@@ -387,7 +387,7 @@
 
63
         HttpFields.Field transfer_encoding = null;
 
64
         boolean keep_alive = false;
 
65
         boolean close=false;
 
66
-        StringBuffer connection = null;
 
67
+        StringBuilder connection = null;
 
68
 
 
69
         if (fields != null)
 
70
         {
 
71
@@ -460,7 +460,7 @@
 
72
                                             
 
73
                                             default:
 
74
                                                 if (connection==null)
 
75
-                                                    connection=new StringBuffer();
 
76
+                                                    connection=new StringBuilder();
 
77
                                                 else
 
78
                                                     connection.append(',');
 
79
                                                 connection.append(values[i]);
 
80
@@ -469,7 +469,7 @@
 
81
                                     else
 
82
                                     {
 
83
                                         if (connection==null)
 
84
-                                            connection=new StringBuffer();
 
85
+                                            connection=new StringBuilder();
 
86
                                         else
 
87
                                             connection.append(',');
 
88
                                         connection.append(values[i]);
 
89
@@ -500,7 +500,7 @@
 
90
                             default:
 
91
                             {
 
92
                                 if (connection==null)
 
93
-                                    connection=new StringBuffer();
 
94
+                                    connection=new StringBuilder();
 
95
                                 else
 
96
                                     connection.append(',');
 
97
                                 connection.append(field.getValue());
 
98
Index: modules/jetty/src/main/java/org/mortbay/jetty/InclusiveByteRange.java
 
99
===================================================================
 
100
--- modules/jetty/src/main/java/org/mortbay/jetty/InclusiveByteRange.java       (revision 4733)
 
101
+++ modules/jetty/src/main/java/org/mortbay/jetty/InclusiveByteRange.java       (working copy)
 
102
@@ -175,7 +175,7 @@
 
103
     /* ------------------------------------------------------------ */
 
104
     public String toHeaderRangeString(long size)
 
105
     {
 
106
-        StringBuffer sb = new StringBuffer(40);
 
107
+        StringBuilder sb = new StringBuilder(40);
 
108
         sb.append("bytes ");
 
109
         sb.append(getFirst(size));
 
110
         sb.append('-');
 
111
@@ -188,7 +188,7 @@
 
112
     /* ------------------------------------------------------------ */
 
113
     public static String to416HeaderRangeString(long size)
 
114
     {
 
115
-        StringBuffer sb = new StringBuffer(40);
 
116
+        StringBuilder sb = new StringBuilder(40);
 
117
         sb.append("bytes */");
 
118
         sb.append(size);
 
119
         return sb.toString();
 
120
@@ -198,7 +198,7 @@
 
121
     /* ------------------------------------------------------------ */
 
122
     public String toString()
 
123
     {
 
124
-        StringBuffer sb = new StringBuffer(60);
 
125
+        StringBuilder sb = new StringBuilder(60);
 
126
         sb.append(Long.toString(first));
 
127
         sb.append(":");
 
128
         sb.append(Long.toString(last));
 
129
Index: modules/jetty/src/main/java/org/mortbay/jetty/Request.java
 
130
===================================================================
 
131
--- modules/jetty/src/main/java/org/mortbay/jetty/Request.java  (revision 4733)
 
132
+++ modules/jetty/src/main/java/org/mortbay/jetty/Request.java  (working copy)
 
133
@@ -1763,25 +1763,22 @@
 
134
      * 
 
135
      * @return "scheme://host:port"
 
136
      */
 
137
-    public StringBuffer getRootURL()
 
138
+    public StringBuilder getRootURL()
 
139
     {
 
140
-        StringBuffer url = new StringBuffer(48);
 
141
-        synchronized (url)
 
142
-        {
 
143
-            String scheme = getScheme();
 
144
-            int port = getServerPort();
 
145
+        StringBuilder url = new StringBuilder(48);
 
146
+        String scheme = getScheme();
 
147
+        int port = getServerPort();
 
148
 
 
149
-            url.append(scheme);
 
150
-            url.append("://");
 
151
-            url.append(getServerName());
 
152
-            
 
153
-            if (port > 0 && ((scheme.equalsIgnoreCase("http") && port != 80) || (scheme.equalsIgnoreCase("https") && port != 443)))
 
154
-            {
 
155
-                url.append(':');
 
156
-                url.append(port);
 
157
-            }
 
158
-            return url;
 
159
+        url.append(scheme);
 
160
+        url.append("://");
 
161
+        url.append(getServerName());
 
162
+
 
163
+        if (port > 0 && ((scheme.equalsIgnoreCase("http") && port != 80) || (scheme.equalsIgnoreCase("https") && port != 443)))
 
164
+        {
 
165
+            url.append(':');
 
166
+            url.append(port);
 
167
         }
 
168
+        return url;
 
169
     }
 
170
 
 
171
     /* ------------------------------------------------------------ */
 
172
Index: modules/jetty/src/main/java/org/mortbay/jetty/Response.java
 
173
===================================================================
 
174
--- modules/jetty/src/main/java/org/mortbay/jetty/Response.java (revision 4733)
 
175
+++ modules/jetty/src/main/java/org/mortbay/jetty/Response.java (working copy)
 
176
@@ -387,7 +387,7 @@
 
177
 
 
178
         if (!URIUtil.hasScheme(location))
 
179
         {
 
180
-            StringBuffer buf = _connection.getRequest().getRootURL();
 
181
+            StringBuilder buf = _connection.getRequest().getRootURL();
 
182
             if (location.startsWith("/"))
 
183
                 buf.append(URIUtil.canonicalPath(location));
 
184
             else
 
185
Index: modules/jetty/src/main/java/org/mortbay/jetty/security/HTAccessHandler.java
 
186
===================================================================
 
187
--- modules/jetty/src/main/java/org/mortbay/jetty/security/HTAccessHandler.java (revision 4733)
 
188
+++ modules/jetty/src/main/java/org/mortbay/jetty/security/HTAccessHandler.java (working copy)
 
189
@@ -668,7 +668,7 @@
 
190
         /* ------------------------------------------------------------ */
 
191
         public String toString()
 
192
         {
 
193
-            StringBuffer buf=new StringBuffer();
 
194
+            StringBuilder buf=new StringBuilder();
 
195
 
 
196
             buf.append("AuthUserFile=");
 
197
             buf.append(_userFile);
 
198
Index: modules/jetty/src/main/java/org/mortbay/jetty/security/Password.java
 
199
===================================================================
 
200
--- modules/jetty/src/main/java/org/mortbay/jetty/security/Password.java        (revision 4733)
 
201
+++ modules/jetty/src/main/java/org/mortbay/jetty/security/Password.java        (working copy)
 
202
@@ -122,31 +122,29 @@
 
203
     /* ------------------------------------------------------------ */
 
204
     public static String obfuscate(String s)
 
205
     {
 
206
-        StringBuffer buf = new StringBuffer();
 
207
+        StringBuilder buf = new StringBuilder();
 
208
         byte[] b = s.getBytes();
 
209
-        
 
210
-        synchronized(buf)
 
211
+
 
212
+        buf.append(__OBFUSCATE);
 
213
+        for (int i=0;i<b.length;i++)
 
214
         {
 
215
-            buf.append(__OBFUSCATE);
 
216
-            for (int i=0;i<b.length;i++)
 
217
-            {
 
218
-                byte b1 = b[i];
 
219
-                byte b2 = b[s.length()-(i+1)];
 
220
-                int i1= 127+b1+b2;
 
221
-                int i2= 127+b1-b2;
 
222
-                int i0=i1*256+i2;
 
223
-                String x=Integer.toString(i0,36);
 
224
+            byte b1 = b[i];
 
225
+            byte b2 = b[s.length()-(i+1)];
 
226
+            int i1= 127+b1+b2;
 
227
+            int i2= 127+b1-b2;
 
228
+            int i0=i1*256+i2;
 
229
+            String x=Integer.toString(i0,36);
 
230
 
 
231
-                switch(x.length())
 
232
-                {
 
233
-                  case 1:buf.append('0');
 
234
-                  case 2:buf.append('0');
 
235
-                  case 3:buf.append('0');
 
236
-                  default:buf.append(x);
 
237
-                }
 
238
+            switch(x.length())
 
239
+            {
 
240
+                case 1:buf.append('0');
 
241
+                case 2:buf.append('0');
 
242
+                case 3:buf.append('0');
 
243
+                default:buf.append(x);
 
244
             }
 
245
-            return buf.toString();
 
246
         }
 
247
+        return buf.toString();
 
248
+
 
249
     }
 
250
     
 
251
     /* ------------------------------------------------------------ */
 
252
Index: modules/jetty/src/main/java/org/mortbay/jetty/servlet/DefaultServlet.java
 
253
===================================================================
 
254
--- modules/jetty/src/main/java/org/mortbay/jetty/servlet/DefaultServlet.java   (revision 4733)
 
255
+++ modules/jetty/src/main/java/org/mortbay/jetty/servlet/DefaultServlet.java   (working copy)
 
256
@@ -423,19 +423,22 @@
 
257
                 if (!endsWithSlash || (pathInContext.length()==1 && request.getAttribute("org.mortbay.jetty.nullPathInfo")!=null))
 
258
                 {
 
259
                     StringBuffer buf=request.getRequestURL();
 
260
-                    int param=buf.lastIndexOf(";");
 
261
-                    if (param<0)
 
262
-                        buf.append('/');
 
263
-                    else
 
264
-                        buf.insert(param,'/');
 
265
-                    String q=request.getQueryString();
 
266
-                    if (q!=null&&q.length()!=0)
 
267
+                    synchronized(buf)
 
268
                     {
 
269
-                        buf.append('?');
 
270
-                        buf.append(q);
 
271
+                        int param=buf.lastIndexOf(";");
 
272
+                        if (param<0)
 
273
+                            buf.append('/');
 
274
+                        else
 
275
+                            buf.insert(param,'/');
 
276
+                        String q=request.getQueryString();
 
277
+                        if (q!=null&&q.length()!=0)
 
278
+                        {
 
279
+                            buf.append('?');
 
280
+                            buf.append(q);
 
281
+                        }
 
282
+                        response.setContentLength(0);
 
283
+                        response.sendRedirect(response.encodeRedirectURL(buf.toString()));
 
284
                     }
 
285
-                    response.setContentLength(0);
 
286
-                    response.sendRedirect(response.encodeRedirectURL(buf.toString()));
 
287
                 }
 
288
                 // else look for a welcome file
 
289
                 else if (null!=(welcome=getWelcomeFile(resource)))
 
290
Index: modules/jetty/src/main/java/org/mortbay/jetty/servlet/HashSessionIdManager.java
 
291
===================================================================
 
292
--- modules/jetty/src/main/java/org/mortbay/jetty/servlet/HashSessionIdManager.java     (revision 4733)
 
293
+++ modules/jetty/src/main/java/org/mortbay/jetty/servlet/HashSessionIdManager.java     (working copy)
 
294
@@ -25,7 +25,7 @@
 
295
 import org.mortbay.jetty.SessionIdManager;
 
296
 import org.mortbay.jetty.servlet.AbstractSessionManager.Session;
 
297
 import org.mortbay.log.Log;
 
298
-import org.mortbay.util.MultiMap;
 
299
+import org.mortbay.util.ConcurrentMultiMap;
 
300
 
 
301
 /* ------------------------------------------------------------ */
 
302
 /**
 
303
@@ -37,7 +37,7 @@
 
304
     protected final static String SESSION_ID_RANDOM_ALGORITHM = "SHA1PRNG";
 
305
     protected final static String SESSION_ID_RANDOM_ALGORITHM_ALT = "IBMSecureRandom";
 
306
 
 
307
-    MultiMap _sessions;
 
308
+    ConcurrentMultiMap _sessions;
 
309
     protected Random _random;
 
310
     private boolean _weakRandom;
 
311
     private String _workerName;
 
312
@@ -137,7 +137,7 @@
 
313
             }
 
314
         }
 
315
         _random.setSeed(_random.nextLong()^System.currentTimeMillis()^hashCode()^Runtime.getRuntime().freeMemory());
 
316
-        _sessions=new MultiMap();
 
317
+        _sessions=new ConcurrentMultiMap();
 
318
     }
 
319
 
 
320
     /* ------------------------------------------------------------ */
 
321
@@ -163,10 +163,7 @@
 
322
      */
 
323
     public void addSession(HttpSession session)
 
324
     {
 
325
-        synchronized (this)
 
326
-        {
 
327
-            _sessions.add(getClusterId(session.getId()),session);
 
328
-        }
 
329
+        _sessions.add(getClusterId(session.getId()),session);
 
330
     }
 
331
 
 
332
     /* ------------------------------------------------------------ */
 
333
@@ -175,10 +172,7 @@
 
334
      */
 
335
     public void removeSession(HttpSession session)
 
336
     {
 
337
-        synchronized (this)
 
338
-        {
 
339
-            _sessions.removeValue(getClusterId(session.getId()),session);
 
340
-        }
 
341
+        _sessions.removeValue(getClusterId(session.getId()),session);
 
342
     }
 
343
 
 
344
     /* ------------------------------------------------------------ */
 
345
@@ -187,19 +181,16 @@
 
346
      */
 
347
     public void invalidateAll(String id)
 
348
     {
 
349
-        synchronized (this)
 
350
-        {
 
351
-            // Do not use interators as this method tends to be called recursively 
 
352
-            // by the invalidate calls.
 
353
-            while (_sessions.containsKey(id))
 
354
-            {
 
355
-                Session session=(Session)_sessions.getValue(id,0);
 
356
-                if (session.isValid())
 
357
-                    session.invalidate();
 
358
-                else
 
359
-                    _sessions.removeValue(id,session);
 
360
-            }
 
361
-        }
 
362
+       // Do not use interators as this method tends to be called recursively 
 
363
+       // by the invalidate calls.
 
364
+       while (_sessions.containsKey(id))
 
365
+       {
 
366
+           Session session=(Session)_sessions.getValue(id,0);
 
367
+           if (session.isValid())
 
368
+               session.invalidate();
 
369
+           else
 
370
+               _sessions.removeValue(id,session);
 
371
+       }
 
372
     }
 
373
 
 
374
     /* ------------------------------------------------------------ */
 
375
@@ -263,4 +254,4 @@
 
376
         _weakRandom=false;
 
377
     }
 
378
 
 
379
-}
 
380
\ No newline at end of file
 
381
+}
 
382
Index: modules/jetty/src/main/java/org/mortbay/jetty/servlet/HashSessionManager.java
 
383
===================================================================
 
384
--- modules/jetty/src/main/java/org/mortbay/jetty/servlet/HashSessionManager.java       (revision 4733)
 
385
+++ modules/jetty/src/main/java/org/mortbay/jetty/servlet/HashSessionManager.java       (working copy)
 
386
@@ -30,6 +30,8 @@
 
387
 import java.util.Timer;
 
388
 import java.util.TimerTask;
 
389
 
 
390
+import java.util.concurrent.ConcurrentHashMap;
 
391
+
 
392
 import javax.servlet.http.HttpServletRequest;
 
393
 
 
394
 import org.mortbay.log.Log;
 
395
@@ -43,6 +45,7 @@
 
396
  */
 
397
 public class HashSessionManager extends AbstractSessionManager
 
398
 {
 
399
+    private static int __id;
 
400
     private Timer _timer;
 
401
     private TimerTask _task;
 
402
     private int _scavengePeriodMs=30000;
 
403
@@ -65,10 +68,10 @@
 
404
      */
 
405
     public void doStart() throws Exception
 
406
     {
 
407
-        _sessions=new HashMap();
 
408
+        _sessions=new ConcurrentHashMap(); // TODO: use syncronizedMap for JDK 1.4
 
409
         super.doStart();
 
410
 
 
411
-        _timer=new Timer(true);
 
412
+        _timer=new Timer("HashSessionScavenger-"+__id++, true);
 
413
         
 
414
         setScavengePeriod(getScavengePeriod());
 
415
 
 
416
Index: modules/jetty/src/main/java/org/mortbay/jetty/servlet/ServletHandler.java
 
417
===================================================================
 
418
--- modules/jetty/src/main/java/org/mortbay/jetty/servlet/ServletHandler.java   (revision 4733)
 
419
+++ modules/jetty/src/main/java/org/mortbay/jetty/servlet/ServletHandler.java   (working copy)
 
420
@@ -21,6 +21,7 @@
 
421
 import java.util.HashMap;
 
422
 import java.util.List;
 
423
 import java.util.Map;
 
424
+import java.util.concurrent.ConcurrentHashMap;
 
425
 
 
426
 import javax.servlet.Filter;
 
427
 import javax.servlet.FilterChain;
 
428
@@ -97,7 +98,7 @@
 
429
     private transient Map _servletNameMap=new HashMap();
 
430
     private transient PathMap _servletPathMap;
 
431
     
 
432
-    protected transient HashMap _chainCache[];
 
433
+    protected transient ConcurrentHashMap _chainCache[];
 
434
 
 
435
 
 
436
     /* ------------------------------------------------------------ */
 
437
@@ -142,7 +143,7 @@
 
438
         updateMappings();
 
439
         
 
440
         if(_filterChainsCached)
 
441
-            _chainCache=     new HashMap[]{null,new HashMap(),new HashMap(),null,new HashMap(),null,null,null,new HashMap()};
 
442
+            _chainCache=     new ConcurrentHashMap[]{null,new ConcurrentHashMap(),new ConcurrentHashMap(),null,new ConcurrentHashMap(),null,null,null,new ConcurrentHashMap()};
 
443
 
 
444
         super.doStart();
 
445
         
 
446
@@ -505,11 +506,9 @@
 
447
         
 
448
         if (_filterChainsCached && _chainCache!=null)
 
449
         {
 
450
-            synchronized(this)
 
451
-            {
 
452
-                if(_chainCache[requestType].containsKey(key))
 
453
-                    return (FilterChain)_chainCache[requestType].get(key);
 
454
-            }
 
455
+            FilterChain chain = (FilterChain)_chainCache[requestType].get(key);
 
456
+            if (chain!=null)
 
457
+                return chain;
 
458
         }
 
459
         
 
460
         // Build list of filters
 
461
@@ -558,12 +557,9 @@
 
462
         {
 
463
             if (LazyList.size(filters) > 0)
 
464
                 chain= new CachedChain(filters, servletHolder);
 
465
-            synchronized(this)
 
466
-            {
 
467
-                if (_maxFilterChainsCacheSize>0 && _chainCache[requestType].size()>_maxFilterChainsCacheSize)
 
468
-                    _chainCache[requestType].clear();
 
469
-                _chainCache[requestType].put(key,chain);
 
470
-            }
 
471
+            if (_maxFilterChainsCacheSize>0 && _chainCache[requestType].size()>_maxFilterChainsCacheSize)
 
472
+                _chainCache[requestType].clear();
 
473
+            _chainCache[requestType].put(key,chain);
 
474
         }
 
475
         else if (LazyList.size(filters) > 0)
 
476
             chain = new Chain(filters, servletHolder);
 
477
@@ -1205,7 +1201,7 @@
 
478
         /* ------------------------------------------------------------ */
 
479
         public String toString()
 
480
         {
 
481
-            StringBuffer b = new StringBuffer();
 
482
+            StringBuilder b = new StringBuilder();
 
483
             for (int i=0; i<LazyList.size(_chain);i++)
 
484
             {
 
485
                 b.append(LazyList.get(_chain, i).toString());
 
486
Index: modules/jetty/src/main/java/org/mortbay/resource/Resource.java
 
487
===================================================================
 
488
--- modules/jetty/src/main/java/org/mortbay/resource/Resource.java      (revision 4733)
 
489
+++ modules/jetty/src/main/java/org/mortbay/resource/Resource.java      (working copy)
 
490
@@ -432,7 +432,7 @@
 
491
         String decodedBase = URIUtil.decodePath(base);
 
492
         String title = "Directory: "+decodedBase;
 
493
 
 
494
-        StringBuffer buf=new StringBuffer(4096);
 
495
+        StringBuilder buf=new StringBuilder(4096);
 
496
         buf.append("<HTML><HEAD><TITLE>");
 
497
         buf.append(title);
 
498
         buf.append("</TITLE></HEAD><BODY>\n<H1>");
 
499
Index: modules/jetty/src/main/java/org/mortbay/xml/XmlConfiguration.java
 
500
===================================================================
 
501
--- modules/jetty/src/main/java/org/mortbay/xml/XmlConfiguration.java   (revision 4733)
 
502
+++ modules/jetty/src/main/java/org/mortbay/xml/XmlConfiguration.java   (working copy)
 
503
@@ -838,16 +838,13 @@
 
504
             else
 
505
             {
 
506
                 // Get the multiple items as a single string
 
507
-                StringBuffer buf = new StringBuffer();
 
508
-                synchronized (buf)
 
509
+                StringBuilder buf = new StringBuilder();
 
510
+                for (int i = first; i <= last; i++)
 
511
                 {
 
512
-                    for (int i = first; i <= last; i++)
 
513
-                    {
 
514
-                        Object item = node.get(i);
 
515
-                        buf.append(itemValue(obj, item));
 
516
-                    }
 
517
-                    value = buf.toString();
 
518
+                    Object item = node.get(i);
 
519
+                    buf.append(itemValue(obj, item));
 
520
                 }
 
521
+                value = buf.toString();
 
522
             }
 
523
         }
 
524
 
 
525
Index: modules/jetty/src/main/java/org/mortbay/xml/XmlParser.java
 
526
===================================================================
 
527
--- modules/jetty/src/main/java/org/mortbay/xml/XmlParser.java  (revision 4733)
 
528
+++ modules/jetty/src/main/java/org/mortbay/xml/XmlParser.java  (working copy)
 
529
@@ -669,12 +669,9 @@
 
530
          */
 
531
         public synchronized String toString(boolean tag)
 
532
         {
 
533
-            StringBuffer buf = new StringBuffer();
 
534
-            synchronized (buf)
 
535
-            {
 
536
-                toString(buf, tag);
 
537
-                return buf.toString();
 
538
-            }
 
539
+            StringBuilder buf = new StringBuilder();
 
540
+            toString(buf, tag);
 
541
+            return buf.toString();
 
542
         }
 
543
 
 
544
         /* ------------------------------------------------------------ */
 
545
@@ -692,7 +689,7 @@
 
546
         }
 
547
 
 
548
         /* ------------------------------------------------------------ */
 
549
-        private synchronized void toString(StringBuffer buf, boolean tag)
 
550
+        private synchronized void toString(StringBuilder buf, boolean tag)
 
551
         {
 
552
             if (tag)
 
553
             {
 
554
Index: modules/jetty/src/test/java/org/mortbay/jetty/HttpServerTestBase.java
 
555
===================================================================
 
556
--- modules/jetty/src/test/java/org/mortbay/jetty/HttpServerTestBase.java       (revision 4733)
 
557
+++ modules/jetty/src/test/java/org/mortbay/jetty/HttpServerTestBase.java       (working copy)
 
558
@@ -251,7 +251,7 @@
 
559
             {
 
560
 
 
561
                 int[] points=new int[pointCount];
 
562
-                StringBuffer message=new StringBuffer();
 
563
+                StringBuilder message=new StringBuilder();
 
564
 
 
565
                 message.append("iteration #"+(i+1));
 
566
 
 
567
@@ -296,7 +296,7 @@
 
568
             for (int i=0; i<bytes.length; i+=3)
 
569
             {
 
570
                 int[] points=new int[] { i };
 
571
-                StringBuffer message=new StringBuffer();
 
572
+                StringBuilder message=new StringBuilder();
 
573
 
 
574
                 message.append("iteration #"+(i+1));
 
575
 
 
576
@@ -348,7 +348,7 @@
 
577
             {
 
578
                 Socket client=new Socket(HOST,port);
 
579
                 OutputStream os=client.getOutputStream();
 
580
-                StringBuffer message=new StringBuffer();
 
581
+                StringBuilder message=new StringBuilder();
 
582
 
 
583
                 message.append("iteration #"+(i+1));
 
584
                 writeFragments(bytes,badPoints[i],message,os);
 
585
@@ -701,7 +701,7 @@
 
586
         {
 
587
             br=new BufferedReader(new InputStreamReader(client.getInputStream()));
 
588
 
 
589
-            StringBuffer sb=new StringBuffer();
 
590
+            StringBuilder sb=new StringBuilder();
 
591
             String line;
 
592
 
 
593
             while ((line=br.readLine())!=null)
 
594
@@ -748,7 +748,7 @@
 
595
         return server;
 
596
     }
 
597
 
 
598
-    private void writeFragments(byte[] bytes, int[] points, StringBuffer message, OutputStream os) throws IOException, InterruptedException
 
599
+    private void writeFragments(byte[] bytes, int[] points, StringBuilder message, OutputStream os) throws IOException, InterruptedException
 
600
     {
 
601
         int last=0;
 
602
 
 
603
Index: modules/util/pom.xml
 
604
===================================================================
 
605
--- modules/util/pom.xml        (revision 4733)
 
606
+++ modules/util/pom.xml        (working copy)
 
607
@@ -25,6 +25,13 @@
 
608
     </testResources>
 
609
     <plugins>
 
610
       <plugin>
 
611
+        <artifactId>maven-compiler-plugin</artifactId>
 
612
+        <configuration>
 
613
+          <source>1.5</source>
 
614
+          <target>1.5</target>
 
615
+        </configuration>
 
616
+      </plugin>
 
617
+      <plugin>
 
618
         <artifactId>maven-antrun-plugin</artifactId>
 
619
         <executions>
 
620
           <execution>
 
621
Index: modules/util/src/main/java/org/mortbay/servlet/CGI.java
 
622
===================================================================
 
623
--- modules/util/src/main/java/org/mortbay/servlet/CGI.java     (revision 4733)
 
624
+++ modules/util/src/main/java/org/mortbay/servlet/CGI.java     (working copy)
 
625
@@ -373,7 +373,7 @@
 
626
      * @throws IOException
 
627
      */
 
628
     private String getTextLineFromStream( InputStream is ) throws IOException {
 
629
-        StringBuffer buffer = new StringBuffer();
 
630
+        StringBuilder buffer = new StringBuilder();
 
631
         int b;
 
632
 
 
633
                while( (b = is.read()) != -1 && b != (int) '\n' ) {
 
634
Index: modules/util/src/main/java/org/mortbay/servlet/GzipFilter.java
 
635
===================================================================
 
636
--- modules/util/src/main/java/org/mortbay/servlet/GzipFilter.java      (revision 4733)
 
637
+++ modules/util/src/main/java/org/mortbay/servlet/GzipFilter.java      (working copy)
 
638
@@ -330,7 +330,7 @@
 
639
                 }
 
640
                 catch (IOException e)
 
641
                 {
 
642
-                    throw new IllegalStateException();
 
643
+                    throw new IllegalStateException(e);
 
644
                 }
 
645
             }
 
646
         }
 
647
Index: modules/util/src/main/java/org/mortbay/servlet/UserAgentFilter.java
 
648
===================================================================
 
649
--- modules/util/src/main/java/org/mortbay/servlet/UserAgentFilter.java (revision 4733)
 
650
+++ modules/util/src/main/java/org/mortbay/servlet/UserAgentFilter.java (working copy)
 
651
@@ -20,6 +20,7 @@
 
652
 import java.util.HashMap;
 
653
 import java.util.List;
 
654
 import java.util.Map;
 
655
+import java.util.concurrent.ConcurrentHashMap;
 
656
 import java.util.regex.Matcher;
 
657
 import java.util.regex.Pattern;
 
658
 
 
659
@@ -55,7 +56,7 @@
 
660
 public class UserAgentFilter implements Filter
 
661
 {
 
662
     private Pattern _pattern;
 
663
-    private Map _agentCache = new HashMap();
 
664
+    private Map _agentCache = new ConcurrentHashMap();
 
665
     private int _agentCacheSize=1024;
 
666
     private String _attribute;
 
667
 
 
668
@@ -118,11 +119,8 @@
 
669
         if (ua==null)
 
670
             return null;
 
671
         
 
672
-        String tag;
 
673
-        synchronized(_agentCache)
 
674
-        {
 
675
-            tag = (String)_agentCache.get(ua);
 
676
-        }
 
677
+        String tag = (String)_agentCache.get(ua);
 
678
+        
 
679
 
 
680
         if (tag==null)
 
681
         {
 
682
@@ -144,12 +142,9 @@
 
683
             else
 
684
                 tag=ua;
 
685
 
 
686
-            synchronized(_agentCache)
 
687
-            {
 
688
-                if (_agentCache.size()>=_agentCacheSize)
 
689
+            if (_agentCache.size()>=_agentCacheSize)
 
690
                     _agentCache.clear();
 
691
                 _agentCache.put(ua,tag);
 
692
-            }
 
693
 
 
694
         }
 
695
         return tag;
 
696
Index: modules/util/src/main/java/org/mortbay/thread/Timeout.java
 
697
===================================================================
 
698
--- modules/util/src/main/java/org/mortbay/thread/Timeout.java  (revision 4733)
 
699
+++ modules/util/src/main/java/org/mortbay/thread/Timeout.java  (working copy)
 
700
@@ -237,7 +237,7 @@
 
701
     /* ------------------------------------------------------------ */
 
702
     public String toString()
 
703
     {
 
704
-        StringBuffer buf = new StringBuffer();
 
705
+        StringBuilder buf = new StringBuilder();
 
706
         buf.append(super.toString());
 
707
         
 
708
         Task task = _head._next;
 
709
Index: modules/util/src/main/java/org/mortbay/util/ajax/JSON.java
 
710
===================================================================
 
711
--- modules/util/src/main/java/org/mortbay/util/ajax/JSON.java  (revision 4733)
 
712
+++ modules/util/src/main/java/org/mortbay/util/ajax/JSON.java  (working copy)
 
713
@@ -1031,7 +1031,7 @@
 
714
     {
 
715
         boolean minus=false;
 
716
         long number=0;
 
717
-        StringBuffer buffer=null;
 
718
+        StringBuilder buffer=null;
 
719
 
 
720
         longLoop: while (source.hasNext())
 
721
         {
 
722
@@ -1063,7 +1063,7 @@
 
723
                 case '.':
 
724
                 case 'e':
 
725
                 case 'E':
 
726
-                    buffer=new StringBuffer(16);
 
727
+                    buffer=new StringBuilder(16);
 
728
                     if(minus) 
 
729
                         buffer.append('-');
 
730
                     buffer.append(number);
 
731
@@ -1079,8 +1079,6 @@
 
732
         if (buffer==null)
 
733
             return TypeUtil.newLong(minus?-1*number:number);
 
734
 
 
735
-        synchronized (buffer)
 
736
-        {
 
737
             doubleLoop: while (source.hasNext())
 
738
             {
 
739
                 char c=source.peek();
 
740
@@ -1110,7 +1108,6 @@
 
741
                 }
 
742
             }
 
743
             return new Double(buffer.toString());
 
744
-        }
 
745
     }
 
746
 
 
747
     protected void seekTo(char seek, Source source)
 
748
Index: modules/util/src/main/java/org/mortbay/util/ConcurrentMultiMap.java
 
749
===================================================================
 
750
--- modules/util/src/main/java/org/mortbay/util/ConcurrentMultiMap.java (revision 0)
 
751
+++ modules/util/src/main/java/org/mortbay/util/ConcurrentMultiMap.java (revision 0)
 
752
@@ -0,0 +1,303 @@
 
753
+// ========================================================================
 
754
+// Copyright 2004-2005 Mort Bay Consulting Pty. Ltd.
 
755
+// ------------------------------------------------------------------------
 
756
+// Licensed under the Apache License, Version 2.0 (the "License");
 
757
+// you may not use this file except in compliance with the License.
 
758
+// You may obtain a copy of the License at 
 
759
+// http://www.apache.org/licenses/LICENSE-2.0
 
760
+// Unless required by applicable law or agreed to in writing, software
 
761
+// distributed under the License is distributed on an "AS IS" BASIS,
 
762
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
763
+// See the License for the specific language governing permissions and
 
764
+// limitations under the License.
 
765
+// ========================================================================
 
766
+
 
767
+package org.mortbay.util;
 
768
+
 
769
+import java.util.Arrays;
 
770
+import java.util.concurrent.ConcurrentHashMap;
 
771
+import java.util.HashMap;
 
772
+import java.util.Iterator;
 
773
+import java.util.List;
 
774
+import java.util.Map;
 
775
+
 
776
+/* ------------------------------------------------------------ */
 
777
+/** A multi valued Map.
 
778
+ * This Map specializes HashMap and provides methods
 
779
+ * that operate on multi valued items. 
 
780
+ * <P>
 
781
+ * Implemented as a map of LazyList values
 
782
+ *
 
783
+ * @see LazyList
 
784
+ * @author Greg Wilkins (gregw)
 
785
+ */
 
786
+public class ConcurrentMultiMap extends ConcurrentHashMap
 
787
+    implements Cloneable
 
788
+{
 
789
+    /* ------------------------------------------------------------ */
 
790
+    /** Constructor. 
 
791
+     */
 
792
+    public ConcurrentMultiMap()
 
793
+    {}
 
794
+    
 
795
+    /* ------------------------------------------------------------ */
 
796
+    /** Constructor. 
 
797
+     * @param size Capacity of the map
 
798
+     */
 
799
+    public ConcurrentMultiMap(int size)
 
800
+    {
 
801
+        super(size);
 
802
+    }
 
803
+    
 
804
+    /* ------------------------------------------------------------ */
 
805
+    /** Constructor. 
 
806
+     * @param map 
 
807
+     */
 
808
+    public ConcurrentMultiMap(Map map)
 
809
+    {
 
810
+        super((map.size()*3)/2);
 
811
+        putAll(map);
 
812
+    }
 
813
+    
 
814
+    /* ------------------------------------------------------------ */
 
815
+    /** Get multiple values.
 
816
+     * Single valued entries are converted to singleton lists.
 
817
+     * @param name The entry key. 
 
818
+     * @return Unmodifieable List of values.
 
819
+     */
 
820
+    public List getValues(Object name)
 
821
+    {
 
822
+        return LazyList.getList(super.get(name),true);
 
823
+    }
 
824
+    
 
825
+    /* ------------------------------------------------------------ */
 
826
+    /** Get a value from a multiple value.
 
827
+     * If the value is not a multivalue, then index 0 retrieves the
 
828
+     * value or null.
 
829
+     * @param name The entry key.
 
830
+     * @param i Index of element to get.
 
831
+     * @return Unmodifieable List of values.
 
832
+     */
 
833
+    public Object getValue(Object name,int i)
 
834
+    {
 
835
+        Object l=super.get(name);
 
836
+        if (i==0 && LazyList.size(l)==0)
 
837
+            return null;
 
838
+        return LazyList.get(l,i);
 
839
+    }
 
840
+    
 
841
+    
 
842
+    /* ------------------------------------------------------------ */
 
843
+    /** Get value as String.
 
844
+     * Single valued items are converted to a String with the toString()
 
845
+     * Object method. Multi valued entries are converted to a comma separated
 
846
+     * List.  No quoting of commas within values is performed.
 
847
+     * @param name The entry key. 
 
848
+     * @return String value.
 
849
+     */
 
850
+    public String getString(Object name)
 
851
+    {
 
852
+        Object l=super.get(name);
 
853
+        switch(LazyList.size(l))
 
854
+        {
 
855
+          case 0:
 
856
+              return null;
 
857
+          case 1:
 
858
+              Object o=LazyList.get(l,0);
 
859
+              return o==null?null:o.toString();
 
860
+          default:
 
861
+              StringBuffer values=new StringBuffer(128);
 
862
+              synchronized(values)
 
863
+              {
 
864
+                  for (int i=0; i<LazyList.size(l); i++)              
 
865
+                  {
 
866
+                      Object e=LazyList.get(l,i);
 
867
+                      if (e!=null)
 
868
+                      {
 
869
+                          if (values.length()>0)
 
870
+                              values.append(',');
 
871
+                          values.append(e.toString());
 
872
+                      }
 
873
+                  }   
 
874
+                  return values.toString();
 
875
+              }
 
876
+        }
 
877
+    }
 
878
+    
 
879
+    /* ------------------------------------------------------------ */
 
880
+    public Object get(Object name) 
 
881
+    {
 
882
+        Object l=super.get(name);
 
883
+        switch(LazyList.size(l))
 
884
+        {
 
885
+          case 0:
 
886
+              return null;
 
887
+          case 1:
 
888
+              Object o=LazyList.get(l,0);
 
889
+              return o;
 
890
+          default:
 
891
+              return LazyList.getList(l,true);
 
892
+        }
 
893
+    }
 
894
+    
 
895
+    /* ------------------------------------------------------------ */
 
896
+    /** Put and entry into the map.
 
897
+     * @param name The entry key. 
 
898
+     * @param value The entry value.
 
899
+     * @return The previous value or null.
 
900
+     */
 
901
+    public Object put(Object name, Object value) 
 
902
+    {
 
903
+        return super.put(name,LazyList.add(null,value));
 
904
+    }
 
905
+
 
906
+    /* ------------------------------------------------------------ */
 
907
+    /** Put multi valued entry.
 
908
+     * @param name The entry key. 
 
909
+     * @param values The List of multiple values.
 
910
+     * @return The previous value or null.
 
911
+     */
 
912
+    public Object putValues(Object name, List values) 
 
913
+    {
 
914
+        return super.put(name,values);
 
915
+    }
 
916
+    
 
917
+    /* ------------------------------------------------------------ */
 
918
+    /** Put multi valued entry.
 
919
+     * @param name The entry key. 
 
920
+     * @param values The String array of multiple values.
 
921
+     * @return The previous value or null.
 
922
+     */
 
923
+    public Object putValues(Object name, String[] values) 
 
924
+    {
 
925
+        Object list=null;
 
926
+        for (int i=0;i<values.length;i++)
 
927
+            list=LazyList.add(list,values[i]);
 
928
+        return put(name,list);
 
929
+    }
 
930
+    
 
931
+    
 
932
+    /* ------------------------------------------------------------ */
 
933
+    /** Add value to multi valued entry.
 
934
+     * If the entry is single valued, it is converted to the first
 
935
+     * value of a multi valued entry.
 
936
+     * @param name The entry key. 
 
937
+     * @param value The entry value.
 
938
+     */
 
939
+    public void add(Object name, Object value) 
 
940
+    {
 
941
+        Object lo = super.get(name);
 
942
+        Object ln = LazyList.add(lo,value);
 
943
+        if (lo!=ln)
 
944
+            super.put(name,ln);
 
945
+    }
 
946
+
 
947
+    /* ------------------------------------------------------------ */
 
948
+    /** Add values to multi valued entry.
 
949
+     * If the entry is single valued, it is converted to the first
 
950
+     * value of a multi valued entry.
 
951
+     * @param name The entry key. 
 
952
+     * @param values The List of multiple values.
 
953
+     */
 
954
+    public void addValues(Object name, List values) 
 
955
+    {
 
956
+        Object lo = super.get(name);
 
957
+        Object ln = LazyList.addCollection(lo,values);
 
958
+        if (lo!=ln)
 
959
+            super.put(name,ln);
 
960
+    }
 
961
+    
 
962
+    /* ------------------------------------------------------------ */
 
963
+    /** Add values to multi valued entry.
 
964
+     * If the entry is single valued, it is converted to the first
 
965
+     * value of a multi valued entry.
 
966
+     * @param name The entry key. 
 
967
+     * @param values The String array of multiple values.
 
968
+     */
 
969
+    public void addValues(Object name, String[] values) 
 
970
+    {
 
971
+        Object lo = super.get(name);
 
972
+        Object ln = LazyList.addCollection(lo,Arrays.asList(values));
 
973
+        if (lo!=ln)
 
974
+            super.put(name,ln);
 
975
+    }
 
976
+    
 
977
+    /* ------------------------------------------------------------ */
 
978
+    /** Remove value.
 
979
+     * @param name The entry key. 
 
980
+     * @param value The entry value. 
 
981
+     * @return true if it was removed.
 
982
+     */
 
983
+    public boolean removeValue(Object name,Object value)
 
984
+    {
 
985
+        Object lo = super.get(name);
 
986
+        Object ln=lo;
 
987
+        int s=LazyList.size(lo);
 
988
+        if (s>0)
 
989
+        {
 
990
+            ln=LazyList.remove(lo,value);
 
991
+            if (ln==null)
 
992
+                super.remove(name);
 
993
+            else
 
994
+                super.put(name, ln);
 
995
+        }
 
996
+        return LazyList.size(ln)!=s;
 
997
+    }
 
998
+    
 
999
+    /* ------------------------------------------------------------ */
 
1000
+    /** Put all contents of map.
 
1001
+     * @param m Map
 
1002
+     */
 
1003
+    public void putAll(Map m)
 
1004
+    {
 
1005
+        Iterator i = m.entrySet().iterator();
 
1006
+        boolean multi=m instanceof MultiMap;
 
1007
+        while(i.hasNext())
 
1008
+        {
 
1009
+            Map.Entry entry =
 
1010
+                (Map.Entry)i.next();
 
1011
+            if (multi)
 
1012
+                super.put(entry.getKey(),LazyList.clone(entry.getValue()));
 
1013
+            else
 
1014
+                put(entry.getKey(),entry.getValue());
 
1015
+        }
 
1016
+    }
 
1017
+
 
1018
+    /* ------------------------------------------------------------ */
 
1019
+    /** 
 
1020
+     * @return Map of String arrays
 
1021
+     */
 
1022
+    public Map toStringArrayMap()
 
1023
+    {
 
1024
+        HashMap map = new HashMap(size()*3/2);
 
1025
+        
 
1026
+        Iterator i = super.entrySet().iterator();
 
1027
+        while(i.hasNext())
 
1028
+        {
 
1029
+            Map.Entry entry = (Map.Entry)i.next();
 
1030
+            Object l = entry.getValue();
 
1031
+            String[] a = LazyList.toStringArray(l);
 
1032
+            // for (int j=a.length;j-->0;)
 
1033
+            //    if (a[j]==null)
 
1034
+            //         a[j]="";
 
1035
+            map.put(entry.getKey(),a);
 
1036
+        }
 
1037
+        return map;
 
1038
+    }
 
1039
+    
 
1040
+    /* ------------------------------------------------------------ */
 
1041
+    public Object clone()
 
1042
+        throws CloneNotSupportedException
 
1043
+    {
 
1044
+        ConcurrentMultiMap mm = (ConcurrentMultiMap) super.clone();
 
1045
+        
 
1046
+        Iterator iter = mm.entrySet().iterator();
 
1047
+        while (iter.hasNext())
 
1048
+        {
 
1049
+            Map.Entry entry = (Map.Entry)iter.next();
 
1050
+            entry.setValue(LazyList.clone(entry.getValue()));
 
1051
+        }
 
1052
+        
 
1053
+        return mm;
 
1054
+    }
 
1055
+}
 
1056
Index: modules/util/src/main/java/org/mortbay/util/DateCache.java
 
1057
===================================================================
 
1058
--- modules/util/src/main/java/org/mortbay/util/DateCache.java  (revision 4733)
 
1059
+++ modules/util/src/main/java/org/mortbay/util/DateCache.java  (working copy)
 
1060
@@ -155,7 +155,7 @@
 
1061
             String ss2 = _formatString.substring( zIndex+3 );
 
1062
             int tzOffset = tz.getRawOffset();
 
1063
             
 
1064
-            StringBuffer sb = new StringBuffer(_formatString.length()+10);
 
1065
+            StringBuilder sb = new StringBuilder(_formatString.length()+10);
 
1066
             sb.append(ss1);
 
1067
             sb.append("'");
 
1068
             if( tzOffset >= 0 )
 
1069
@@ -254,17 +254,15 @@
 
1070
 
 
1071
         // Always format if we get here
 
1072
         _lastSeconds = seconds;
 
1073
-        StringBuffer sb=new StringBuffer(_secFormatString.length());
 
1074
-        synchronized(sb)
 
1075
-        {
 
1076
-            sb.append(_secFormatString0);
 
1077
-            int s=(int)(seconds%60);
 
1078
-            if (s<10)
 
1079
-                sb.append('0');
 
1080
-            sb.append(s);
 
1081
-            sb.append(_secFormatString1);
 
1082
-            _lastResult=sb.toString();
 
1083
-        }
 
1084
+        StringBuilder sb=new StringBuilder(_secFormatString.length());
 
1085
+        sb.append(_secFormatString0);
 
1086
+        int s=(int)(seconds%60);
 
1087
+        if (s<10)
 
1088
+            sb.append('0');
 
1089
+        sb.append(s);
 
1090
+        sb.append(_secFormatString1);
 
1091
+        _lastResult=sb.toString();
 
1092
+
 
1093
                 
 
1094
         return _lastResult;
 
1095
     }
 
1096
@@ -272,9 +270,9 @@
 
1097
     /* ------------------------------------------------------------ */
 
1098
     /** Format to string buffer. 
 
1099
      * @param inDate Date the format
 
1100
-     * @param buffer StringBuffer
 
1101
+     * @param buffer StringBuilder
 
1102
      */
 
1103
-    public void format(long inDate, StringBuffer buffer)
 
1104
+    public void format(long inDate, StringBuilder buffer)
 
1105
     {
 
1106
         buffer.append(format(inDate));
 
1107
     }
 
1108
Index: modules/util/src/main/java/org/mortbay/util/MultiMap.java
 
1109
===================================================================
 
1110
--- modules/util/src/main/java/org/mortbay/util/MultiMap.java   (revision 4733)
 
1111
+++ modules/util/src/main/java/org/mortbay/util/MultiMap.java   (working copy)
 
1112
@@ -105,21 +105,20 @@
 
1113
               Object o=LazyList.get(l,0);
 
1114
               return o==null?null:o.toString();
 
1115
           default:
 
1116
-              StringBuffer values=new StringBuffer(128);
 
1117
-              synchronized(values)
 
1118
+          {
 
1119
+              StringBuilder values=new StringBuilder(128);
 
1120
+              for (int i=0; i<LazyList.size(l); i++)              
 
1121
               {
 
1122
-                  for (int i=0; i<LazyList.size(l); i++)              
 
1123
+                  Object e=LazyList.get(l,i);
 
1124
+                  if (e!=null)
 
1125
                   {
 
1126
-                      Object e=LazyList.get(l,i);
 
1127
-                      if (e!=null)
 
1128
-                      {
 
1129
-                          if (values.length()>0)
 
1130
-                              values.append(',');
 
1131
-                          values.append(e.toString());
 
1132
-                      }
 
1133
-                  }   
 
1134
-                  return values.toString();
 
1135
-              }
 
1136
+                      if (values.length()>0)
 
1137
+                          values.append(',');
 
1138
+                      values.append(e.toString());
 
1139
+                  }
 
1140
+              }   
 
1141
+              return values.toString();
 
1142
+          }
 
1143
         }
 
1144
     }
 
1145
     
 
1146
Index: modules/util/src/main/java/org/mortbay/util/RolloverFileOutputStream.java
 
1147
===================================================================
 
1148
--- modules/util/src/main/java/org/mortbay/util/RolloverFileOutputStream.java   (revision 4733)
 
1149
+++ modules/util/src/main/java/org/mortbay/util/RolloverFileOutputStream.java   (working copy)
 
1150
@@ -166,7 +166,7 @@
 
1151
         synchronized(RolloverFileOutputStream.class)
 
1152
         {
 
1153
             if (__rollover==null)
 
1154
-                __rollover=new Timer(true);
 
1155
+                __rollover=new Timer(RolloverFileOutputStream.class.getName(),true);
 
1156
             
 
1157
             _rollTask=new RollTask();
 
1158
 
 
1159
Index: modules/util/src/main/java/org/mortbay/util/Scanner.java
 
1160
===================================================================
 
1161
--- modules/util/src/main/java/org/mortbay/util/Scanner.java    (revision 4733)
 
1162
+++ modules/util/src/main/java/org/mortbay/util/Scanner.java    (working copy)
 
1163
@@ -43,6 +43,7 @@
 
1164
  */
 
1165
 public class Scanner
 
1166
 {
 
1167
+    private static int __scannerId=0;
 
1168
     private int _scanInterval;
 
1169
     private List _listeners = Collections.synchronizedList(new ArrayList());
 
1170
     private Map _prevScan = new HashMap();
 
1171
@@ -235,7 +236,7 @@
 
1172
 
 
1173
     public Timer newTimer ()
 
1174
     {
 
1175
-        return new Timer(true);
 
1176
+        return new Timer("Scanner-"+__scannerId++, true);
 
1177
     }
 
1178
     
 
1179
     public void schedule ()
 
1180
Index: modules/util/src/main/java/org/mortbay/util/StringMap.java
 
1181
===================================================================
 
1182
--- modules/util/src/main/java/org/mortbay/util/StringMap.java  (revision 4733)
 
1183
+++ modules/util/src/main/java/org/mortbay/util/StringMap.java  (working copy)
 
1184
@@ -613,15 +613,12 @@
 
1185
         public Object setValue(Object o){Object old=_value;_value=o;return old;}
 
1186
         public String toString()
 
1187
         {
 
1188
-            StringBuffer buf=new StringBuffer();
 
1189
-            synchronized(buf)
 
1190
-            {
 
1191
-                toString(buf);
 
1192
-            }
 
1193
+            StringBuilder buf=new StringBuilder();
 
1194
+            toString(buf);
 
1195
             return buf.toString();
 
1196
         }
 
1197
 
 
1198
-        private void toString(StringBuffer buf)
 
1199
+        private void toString(StringBuilder buf)
 
1200
         {
 
1201
             buf.append("{[");
 
1202
             if (_char==null)
 
1203
Index: modules/util/src/main/java/org/mortbay/util/StringUtil.java
 
1204
===================================================================
 
1205
--- modules/util/src/main/java/org/mortbay/util/StringUtil.java (revision 4733)
 
1206
+++ modules/util/src/main/java/org/mortbay/util/StringUtil.java (working copy)
 
1207
@@ -191,22 +191,20 @@
 
1208
         if (i == -1)
 
1209
             return s;
 
1210
     
 
1211
-        StringBuffer buf = new StringBuffer(s.length()+with.length());
 
1212
+        StringBuilder buf = new StringBuilder(s.length()+with.length());
 
1213
 
 
1214
-        synchronized(buf)
 
1215
+        do
 
1216
         {
 
1217
-            do
 
1218
-            {
 
1219
-                buf.append(s.substring(c,i));
 
1220
-                buf.append(with);
 
1221
-                c=i+sub.length();
 
1222
-            } while ((i=s.indexOf(sub,c))!=-1);
 
1223
-            
 
1224
-            if (c<s.length())
 
1225
-                buf.append(s.substring(c,s.length()));
 
1226
-            
 
1227
-            return buf.toString();
 
1228
-        }
 
1229
+            buf.append(s.substring(c,i));
 
1230
+            buf.append(with);
 
1231
+            c=i+sub.length();
 
1232
+        } while ((i=s.indexOf(sub,c))!=-1);
 
1233
+
 
1234
+        if (c<s.length())
 
1235
+            buf.append(s.substring(c,s.length()));
 
1236
+
 
1237
+        return buf.toString();
 
1238
+        
 
1239
     }
 
1240
 
 
1241
 
 
1242
@@ -220,13 +218,13 @@
 
1243
 
 
1244
 
 
1245
     /* ------------------------------------------------------------ */
 
1246
-    /** Append substring to StringBuffer 
 
1247
-     * @param buf StringBuffer to append to
 
1248
+    /** Append substring to StringBuilder 
 
1249
+     * @param buf StringBuilder to append to
 
1250
      * @param s String to append from
 
1251
      * @param offset The offset of the substring
 
1252
      * @param length The length of the substring
 
1253
      */
 
1254
-    public static void append(StringBuffer buf,
 
1255
+    public static void append(StringBuilder buf,
 
1256
                               String s,
 
1257
                               int offset,
 
1258
                               int length)
 
1259
@@ -249,7 +247,7 @@
 
1260
      * append hex digit
 
1261
      * 
 
1262
      */
 
1263
-    public static void append(StringBuffer buf,byte b,int base)
 
1264
+    public static void append(StringBuilder buf,byte b,int base)
 
1265
     {
 
1266
         int bi=0xff&b;
 
1267
         int c='0'+(bi/base)%base;
 
1268
@@ -262,7 +260,6 @@
 
1269
         buf.append((char)c);
 
1270
     }
 
1271
 
 
1272
-    
 
1273
     /* ------------------------------------------------------------ */
 
1274
     public static void append2digits(StringBuffer buf,int i)
 
1275
     {
 
1276
@@ -274,6 +271,16 @@
 
1277
     }
 
1278
     
 
1279
     /* ------------------------------------------------------------ */
 
1280
+    public static void append2digits(StringBuilder buf,int i)
 
1281
+    {
 
1282
+        if (i<100)
 
1283
+        {
 
1284
+            buf.append((char)(i/10+'0'));
 
1285
+            buf.append((char)(i%10+'0'));
 
1286
+        }
 
1287
+    }
 
1288
+    
 
1289
+    /* ------------------------------------------------------------ */
 
1290
     /** Return a non null string.
 
1291
      * @param s String
 
1292
      * @return The string passed in or empty string if it is null. 
 
1293
@@ -347,7 +354,7 @@
 
1294
     {
 
1295
         if (name==null)
 
1296
             return null;
 
1297
-        StringBuffer buf = new StringBuffer(name.length());
 
1298
+        StringBuilder buf = new StringBuilder(name.length());
 
1299
         for (int i=0;i<name.length();i++)
 
1300
         {
 
1301
             char c=name.charAt(i);
 
1302
Index: modules/util/src/main/java/org/mortbay/util/TypeUtil.java
 
1303
===================================================================
 
1304
--- modules/util/src/main/java/org/mortbay/util/TypeUtil.java   (revision 4733)
 
1305
+++ modules/util/src/main/java/org/mortbay/util/TypeUtil.java   (working copy)
 
1306
@@ -395,7 +395,7 @@
 
1307
     /* ------------------------------------------------------------ */
 
1308
     public static String toString(byte[] bytes, int base)
 
1309
     {
 
1310
-        StringBuffer buf = new StringBuffer();
 
1311
+        StringBuilder buf = new StringBuilder();
 
1312
         for (int i=0;i<bytes.length;i++)
 
1313
         {
 
1314
             int bi=0xff&bytes[i];
 
1315
@@ -427,7 +427,7 @@
 
1316
     /* ------------------------------------------------------------ */
 
1317
     public static String toHexString(byte[] b)
 
1318
     {   
 
1319
-        StringBuffer buf = new StringBuffer();
 
1320
+        StringBuilder buf = new StringBuilder();
 
1321
         for (int i=0;i<b.length;i++)
 
1322
         {
 
1323
             int bi=0xff&b[i];
 
1324
@@ -446,7 +446,7 @@
 
1325
     /* ------------------------------------------------------------ */
 
1326
     public static String toHexString(byte[] b,int offset,int length)
 
1327
     {   
 
1328
-        StringBuffer buf = new StringBuffer();
 
1329
+        StringBuilder buf = new StringBuilder();
 
1330
         for (int i=offset;i<offset+length;i++)
 
1331
         {
 
1332
             int bi=0xff&b[i];
 
1333
Index: modules/util/src/main/java/org/mortbay/util/URIUtil.java
 
1334
===================================================================
 
1335
--- modules/util/src/main/java/org/mortbay/util/URIUtil.java    (revision 4733)
 
1336
+++ modules/util/src/main/java/org/mortbay/util/URIUtil.java    (working copy)
 
1337
@@ -56,17 +56,17 @@
 
1338
         if (path==null || path.length()==0)
 
1339
             return path;
 
1340
         
 
1341
-        StringBuffer buf = encodePath(null,path);
 
1342
+        StringBuilder buf = encodePath(null,path);
 
1343
         return buf==null?path:buf.toString();
 
1344
     }
 
1345
         
 
1346
     /* ------------------------------------------------------------ */
 
1347
     /** Encode a URI path.
 
1348
      * @param path The path the encode
 
1349
-     * @param buf StringBuffer to encode path into (or null)
 
1350
-     * @return The StringBuffer or null if no substitutions required.
 
1351
+     * @param buf StringBuilder to encode path into (or null)
 
1352
+     * @return The StringBuilder or null if no substitutions required.
 
1353
      */
 
1354
-    public static StringBuffer encodePath(StringBuffer buf, String path)
 
1355
+    public static StringBuilder encodePath(StringBuilder buf, String path)
 
1356
     {
 
1357
         if (buf==null)
 
1358
         {
 
1359
@@ -81,7 +81,7 @@
 
1360
                   case ';':
 
1361
                   case '#':
 
1362
                   case ' ':
 
1363
-                      buf=new StringBuffer(path.length()<<1);
 
1364
+                      buf=new StringBuilder(path.length()<<1);
 
1365
                       break loop;
 
1366
                 }
 
1367
             }
 
1368
@@ -124,13 +124,13 @@
 
1369
     /* ------------------------------------------------------------ */
 
1370
     /** Encode a URI path.
 
1371
      * @param path The path the encode
 
1372
-     * @param buf StringBuffer to encode path into (or null)
 
1373
+     * @param buf StringBuilder to encode path into (or null)
 
1374
      * @param encode String of characters to encode. % is always encoded.
 
1375
-     * @return The StringBuffer or null if no substitutions required.
 
1376
+     * @return The StringBuilder or null if no substitutions required.
 
1377
      */
 
1378
-    public static StringBuffer encodeString(StringBuffer buf,
 
1379
-                                            String path,
 
1380
-                                            String encode)
 
1381
+    public static StringBuilder encodeString(StringBuilder buf,
 
1382
+                                             String path,
 
1383
+                                             String encode)
 
1384
     {
 
1385
         if (buf==null)
 
1386
         {
 
1387
@@ -140,7 +140,7 @@
 
1388
                 char c=path.charAt(i);
 
1389
                 if (c=='%' || encode.indexOf(c)>=0)
 
1390
                 {    
 
1391
-                    buf=new StringBuffer(path.length()<<1);
 
1392
+                    buf=new StringBuilder(path.length()<<1);
 
1393
                     break loop;
 
1394
                 }
 
1395
             }
 
1396
@@ -169,7 +169,7 @@
 
1397
     /* ------------------------------------------------------------ */
 
1398
     /* Decode a URI path.
 
1399
      * @param path The path the encode
 
1400
-     * @param buf StringBuffer to encode path into
 
1401
+     * @param buf StringBuilder to encode path into
 
1402
      */
 
1403
     public static String decodePath(String path)
 
1404
     {
 
1405
@@ -247,7 +247,7 @@
 
1406
     /* ------------------------------------------------------------ */
 
1407
     /* Decode a URI path.
 
1408
      * @param path The path the encode
 
1409
-     * @param buf StringBuffer to encode path into
 
1410
+     * @param buf StringBuilder to encode path into
 
1411
      */
 
1412
     public static String decodePath(byte[] buf, int offset, int length)
 
1413
     {
 
1414
@@ -312,7 +312,7 @@
 
1415
         if (split<0)
 
1416
             split=p1.length();
 
1417
 
 
1418
-        StringBuffer buf = new StringBuffer(p1.length()+p2.length()+2);
 
1419
+        StringBuilder buf = new StringBuilder(p1.length()+p2.length()+2);
 
1420
         buf.append(p1);
 
1421
         
 
1422
         if (buf.charAt(split-1)=='/')
 
1423
@@ -406,7 +406,7 @@
 
1424
         if (start>=end)
 
1425
             return path;
 
1426
         
 
1427
-        StringBuffer buf = new StringBuffer(path);
 
1428
+        StringBuilder buf = new StringBuilder(path);
 
1429
         int delStart=-1;
 
1430
         int delEnd=-1;
 
1431
         int skip=0;
 
1432
Index: modules/util/src/main/java/org/mortbay/util/UrlEncoded.java
 
1433
===================================================================
 
1434
--- modules/util/src/main/java/org/mortbay/util/UrlEncoded.java (revision 4733)
 
1435
+++ modules/util/src/main/java/org/mortbay/util/UrlEncoded.java (working copy)
 
1436
@@ -116,57 +116,56 @@
 
1437
     {
 
1438
         if (charset==null)
 
1439
             charset=StringUtil.__UTF8;
 
1440
-        
 
1441
-        StringBuffer result = new StringBuffer(128);
 
1442
-        synchronized(result)
 
1443
+
 
1444
+        StringBuilder result = new StringBuilder(128);
 
1445
+
 
1446
+        Iterator iter = map.entrySet().iterator();
 
1447
+        while(iter.hasNext())
 
1448
         {
 
1449
-            Iterator iter = map.entrySet().iterator();
 
1450
-            while(iter.hasNext())
 
1451
+            Map.Entry entry = (Map.Entry)iter.next();
 
1452
+
 
1453
+            String key = entry.getKey().toString();
 
1454
+            Object list = entry.getValue();
 
1455
+            int s=LazyList.size(list);
 
1456
+
 
1457
+            if (s==0)
 
1458
             {
 
1459
-                Map.Entry entry = (Map.Entry)iter.next();
 
1460
-                
 
1461
-                String key = entry.getKey().toString();
 
1462
-                Object list = entry.getValue();
 
1463
-                int s=LazyList.size(list);
 
1464
-                
 
1465
-                if (s==0)
 
1466
+                result.append(encodeString(key,charset));
 
1467
+                if(equalsForNullValue)
 
1468
+                    result.append('=');
 
1469
+            }
 
1470
+            else
 
1471
+            {
 
1472
+                for (int i=0;i<s;i++)
 
1473
                 {
 
1474
+                    if (i>0)
 
1475
+                        result.append('&');
 
1476
+                    Object val=LazyList.get(list,i);
 
1477
                     result.append(encodeString(key,charset));
 
1478
-                    if(equalsForNullValue)
 
1479
-                        result.append('=');
 
1480
-                }
 
1481
-                else
 
1482
-                {
 
1483
-                    for (int i=0;i<s;i++)
 
1484
-                    {
 
1485
-                        if (i>0)
 
1486
-                            result.append('&');
 
1487
-                        Object val=LazyList.get(list,i);
 
1488
-                        result.append(encodeString(key,charset));
 
1489
 
 
1490
-                        if (val!=null)
 
1491
+                    if (val!=null)
 
1492
+                    {
 
1493
+                        String str=val.toString();
 
1494
+                        if (str.length()>0)
 
1495
                         {
 
1496
-                            String str=val.toString();
 
1497
-                            if (str.length()>0)
 
1498
-                            {
 
1499
-                                result.append('=');
 
1500
-                                result.append(encodeString(str,charset));
 
1501
-                            }
 
1502
-                            else if (equalsForNullValue)
 
1503
-                                result.append('=');
 
1504
+                            result.append('=');
 
1505
+                            result.append(encodeString(str,charset));
 
1506
                         }
 
1507
                         else if (equalsForNullValue)
 
1508
                             result.append('=');
 
1509
                     }
 
1510
+                    else if (equalsForNullValue)
 
1511
+                        result.append('=');
 
1512
                 }
 
1513
-                if (iter.hasNext())
 
1514
-                    result.append('&');
 
1515
             }
 
1516
-            return result.toString();
 
1517
+            if (iter.hasNext())
 
1518
+                result.append('&');
 
1519
         }
 
1520
+        return result.toString();
 
1521
     }
 
1522
 
 
1523
 
 
1524
+
 
1525
     /* -------------------------------------------------------------- */
 
1526
     /** Decoded parameters to Map.
 
1527
      * @param content the string containing the encoded parameters
 
1528
Index: modules/util/src/main/java/org/mortbay/util/Utf8StringBuffer.java
 
1529
===================================================================
 
1530
--- modules/util/src/main/java/org/mortbay/util/Utf8StringBuffer.java   (revision 4733)
 
1531
+++ modules/util/src/main/java/org/mortbay/util/Utf8StringBuffer.java   (working copy)
 
1532
@@ -26,6 +26,7 @@
 
1533
  * The UTF-8 decoding is done by this class and no additional buffers or Readers are used.
 
1534
  * The UTF-8 code was inspired by http://javolution.org
 
1535
  * 
 
1536
+ * This class is not synchronized and should probably be called Utf8StringBuilder
 
1537
  */
 
1538
 public class Utf8StringBuffer 
 
1539
 {
 
1540
Index: modules/util/src/test/java/org/mortbay/util/StringMapTest.java
 
1541
===================================================================
 
1542
--- modules/util/src/test/java/org/mortbay/util/StringMapTest.java      (revision 4733)
 
1543
+++ modules/util/src/test/java/org/mortbay/util/StringMapTest.java      (working copy)
 
1544
@@ -133,7 +133,7 @@
 
1545
         m5.put("aBc", "x");
 
1546
         m5i.put("AbC", "x");
 
1547
 
 
1548
-        StringBuffer buffer=new StringBuffer();
 
1549
+        StringBuilder buffer=new StringBuilder();
 
1550
         buffer.append("aBc");
 
1551
         assertEquals("2",m5.get("abc"));
 
1552
         assertEquals("x",m5.get(buffer));
 
1553
Index: modules/util/src/test/java/org/mortbay/util/StringUtilTest.java
 
1554
===================================================================
 
1555
--- modules/util/src/test/java/org/mortbay/util/StringUtilTest.java     (revision 4733)
 
1556
+++ modules/util/src/test/java/org/mortbay/util/StringUtilTest.java     (working copy)
 
1557
@@ -137,7 +137,7 @@
 
1558
 
 
1559
     public void testAppend()
 
1560
     {
 
1561
-        StringBuffer buf = new StringBuffer();
 
1562
+        StringBuilder buf = new StringBuilder();
 
1563
         buf.append('a');
 
1564
         StringUtil.append(buf, "abc", 1, 1);
 
1565
         StringUtil.append(buf, (byte)12, 16);
 
1566
Index: modules/util/src/test/java/org/mortbay/util/URITest.java
 
1567
===================================================================
 
1568
--- modules/util/src/test/java/org/mortbay/util/URITest.java    (revision 4733)
 
1569
+++ modules/util/src/test/java/org/mortbay/util/URITest.java    (working copy)
 
1570
@@ -45,7 +45,7 @@
 
1571
     public void testEncodePath()
 
1572
     {
 
1573
         // test basic encode/decode
 
1574
-        StringBuffer buf = new StringBuffer();
 
1575
+        StringBuilder buf = new StringBuilder();
 
1576
         
 
1577
         
 
1578
         buf.setLength(0);