Mercurial Hosting > luan
comparison src/org/eclipse/jetty/util/IO.java @ 820:8e9db0bbf4f9
remove org.eclipse.jetty.util.log and upgrade slf4j
| author | Franklin Schmidt <fschmidt@gmail.com> | 
|---|---|
| date | Tue, 13 Sep 2016 23:13:06 -0600 | 
| parents | 3428c60d7cfc | 
| children | 2bb375e94f64 | 
   comparison
  equal
  deleted
  inserted
  replaced
| 819:17bd0b170ed6 | 820:8e9db0bbf4f9 | 
|---|---|
| 29 import java.io.PrintWriter; | 29 import java.io.PrintWriter; | 
| 30 import java.io.Reader; | 30 import java.io.Reader; | 
| 31 import java.io.StringWriter; | 31 import java.io.StringWriter; | 
| 32 import java.io.Writer; | 32 import java.io.Writer; | 
| 33 | 33 | 
| 34 import org.eclipse.jetty.util.log.Log; | 34 import org.slf4j.Logger; | 
| 35 import org.eclipse.jetty.util.log.Logger; | 35 import org.slf4j.LoggerFactory; | 
| 36 import org.eclipse.jetty.util.thread.QueuedThreadPool; | 36 import org.eclipse.jetty.util.thread.QueuedThreadPool; | 
| 37 | 37 | 
| 38 /* ======================================================================== */ | 38 /* ======================================================================== */ | 
| 39 /** IO Utilities. | 39 /** IO Utilities. | 
| 40 * Provides stream handling utilities in | 40 * Provides stream handling utilities in | 
| 41 * singleton Threadpool implementation accessed by static members. | 41 * singleton Threadpool implementation accessed by static members. | 
| 42 */ | 42 */ | 
| 43 public class IO | 43 public class IO | 
| 44 { | 44 { | 
| 45 private static final Logger LOG = Log.getLogger(IO.class); | 45 private static final Logger LOG = LoggerFactory.getLogger(IO.class); | 
| 46 | 46 | 
| 47 /* ------------------------------------------------------------------- */ | 47 /* ------------------------------------------------------------------- */ | 
| 48 public final static String | 48 public final static String | 
| 49 CRLF = "\015\012"; | 49 CRLF = "\015\012"; | 
| 50 | 50 | 
| 60 private static class Singleton { | 60 private static class Singleton { | 
| 61 static final QueuedThreadPool __pool=new QueuedThreadPool(); | 61 static final QueuedThreadPool __pool=new QueuedThreadPool(); | 
| 62 static | 62 static | 
| 63 { | 63 { | 
| 64 try{__pool.start();} | 64 try{__pool.start();} | 
| 65 catch(Exception e){LOG.warn(e); System.exit(1);} | 65 catch(Exception e){LOG.warn("",e); System.exit(1);} | 
| 66 } | 66 } | 
| 67 } | 67 } | 
| 68 | 68 | 
| 69 /* ------------------------------------------------------------------- */ | 69 /* ------------------------------------------------------------------- */ | 
| 70 static class Job implements Runnable | 70 static class Job implements Runnable | 
| 101 else | 101 else | 
| 102 copy(read,write,-1); | 102 copy(read,write,-1); | 
| 103 } | 103 } | 
| 104 catch(IOException e) | 104 catch(IOException e) | 
| 105 { | 105 { | 
| 106 LOG.ignore(e); | 106 LOG.trace("",e); | 
| 107 try{ | 107 try{ | 
| 108 if (out!=null) | 108 if (out!=null) | 
| 109 out.close(); | 109 out.close(); | 
| 110 if (write!=null) | 110 if (write!=null) | 
| 111 write.close(); | 111 write.close(); | 
| 112 } | 112 } | 
| 113 catch(IOException e2) | 113 catch(IOException e2) | 
| 114 { | 114 { | 
| 115 LOG.ignore(e2); | 115 LOG.trace("",e2); | 
| 116 } | 116 } | 
| 117 } | 117 } | 
| 118 } | 118 } | 
| 119 } | 119 } | 
| 120 | 120 | 
| 129 if (!Singleton.__pool.dispatch(job)) | 129 if (!Singleton.__pool.dispatch(job)) | 
| 130 job.run(); | 130 job.run(); | 
| 131 } | 131 } | 
| 132 catch(Exception e) | 132 catch(Exception e) | 
| 133 { | 133 { | 
| 134 LOG.warn(e); | 134 LOG.warn("",e); | 
| 135 } | 135 } | 
| 136 } | 136 } | 
| 137 | 137 | 
| 138 /* ------------------------------------------------------------------- */ | 138 /* ------------------------------------------------------------------- */ | 
| 139 /** Copy Stream in to Stream out until EOF or exception. | 139 /** Copy Stream in to Stream out until EOF or exception. | 
| 156 if (!Singleton.__pool.dispatch(job)) | 156 if (!Singleton.__pool.dispatch(job)) | 
| 157 job.run(); | 157 job.run(); | 
| 158 } | 158 } | 
| 159 catch(Exception e) | 159 catch(Exception e) | 
| 160 { | 160 { | 
| 161 LOG.warn(e); | 161 LOG.warn("",e); | 
| 162 } | 162 } | 
| 163 } | 163 } | 
| 164 | 164 | 
| 165 /* ------------------------------------------------------------------- */ | 165 /* ------------------------------------------------------------------- */ | 
| 166 /** Copy Reader to Writer out until EOF or exception. | 166 /** Copy Reader to Writer out until EOF or exception. | 
| 371 if (c != null) | 371 if (c != null) | 
| 372 c.close(); | 372 c.close(); | 
| 373 } | 373 } | 
| 374 catch (IOException e) | 374 catch (IOException e) | 
| 375 { | 375 { | 
| 376 LOG.ignore(e); | 376 LOG.trace("",e); | 
| 377 } | 377 } | 
| 378 } | 378 } | 
| 379 | 379 | 
| 380 /** | 380 /** | 
| 381 * closes an input stream, and logs exceptions | 381 * closes an input stream, and logs exceptions | 
| 389 if (is != null) | 389 if (is != null) | 
| 390 is.close(); | 390 is.close(); | 
| 391 } | 391 } | 
| 392 catch (IOException e) | 392 catch (IOException e) | 
| 393 { | 393 { | 
| 394 LOG.ignore(e); | 394 LOG.trace("",e); | 
| 395 } | 395 } | 
| 396 } | 396 } | 
| 397 | 397 | 
| 398 /** | 398 /** | 
| 399 * closes a reader, and logs exceptions | 399 * closes a reader, and logs exceptions | 
| 406 { | 406 { | 
| 407 if (reader != null) | 407 if (reader != null) | 
| 408 reader.close(); | 408 reader.close(); | 
| 409 } catch (IOException e) | 409 } catch (IOException e) | 
| 410 { | 410 { | 
| 411 LOG.ignore(e); | 411 LOG.trace("",e); | 
| 412 } | 412 } | 
| 413 } | 413 } | 
| 414 | 414 | 
| 415 /** | 415 /** | 
| 416 * closes a writer, and logs exceptions | 416 * closes a writer, and logs exceptions | 
| 423 { | 423 { | 
| 424 if (writer != null) | 424 if (writer != null) | 
| 425 writer.close(); | 425 writer.close(); | 
| 426 } catch (IOException e) | 426 } catch (IOException e) | 
| 427 { | 427 { | 
| 428 LOG.ignore(e); | 428 LOG.trace("",e); | 
| 429 } | 429 } | 
| 430 } | 430 } | 
| 431 | 431 | 
| 432 /* ------------------------------------------------------------ */ | 432 /* ------------------------------------------------------------ */ | 
| 433 public static byte[] readBytes(InputStream in) | 433 public static byte[] readBytes(InputStream in) | 
| 451 if (os != null) | 451 if (os != null) | 
| 452 os.close(); | 452 os.close(); | 
| 453 } | 453 } | 
| 454 catch (IOException e) | 454 catch (IOException e) | 
| 455 { | 455 { | 
| 456 LOG.ignore(e); | 456 LOG.trace("",e); | 
| 457 } | 457 } | 
| 458 } | 458 } | 
| 459 | 459 | 
| 460 /* ------------------------------------------------------------ */ | 460 /* ------------------------------------------------------------ */ | 
| 461 /** | 461 /** | 
