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 ...@@ -4,14 +4,11 @@ package com.github.shadowsocks.utils
* @author Mygod * @author Mygod
*/ */
object CloseUtils { object CloseUtils {
type Closeable = {
def close()
}
type Disconnectable = { type Disconnectable = {
def disconnect() 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 var a: Option[A] = None
try { try {
a = Some(x) 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