Commit 364d873e authored by Mygod's avatar Mygod

Update to AutoCloseable in Java 1.7

parent a722257a
......@@ -4,14 +4,11 @@ package com.github.shadowsocks.utils
* @author Mygod
*/
object CloseUtils {
type Closeable = {
def close()
}
type Disconnectable = {
def disconnect()
}
def autoClose[A <: Closeable, B](x: => A)(block: A => B): B = {
def autoClose[A <: AutoCloseable, B](x: => A)(block: A => B): B = {
var a: Option[A] = None
try {
a = Some(x)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment