Skip to content

Commit cd80674

Browse files
adampaulscchantep
authored andcommitted
Use AutoCloseable instead of Closeable (jsuereth#80)
1 parent bfb2631 commit cd80674

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

src/jekyll/resource.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,4 @@ Type classes in scala are encoded using implicit parameters. Due to the mechan
4444

4545
These two implicits allow users of the library to make use of any resource class that defines a close or dispose method. The downside is that by using structural types, the close and dispose method will be invoked via reflection.
4646

47-
The scala-arm library also provides default implicits for common resources used from the Scala library or the Java SDK. In particular, anything that extends `java.io.Closeable` will *not* use reflection when closing the resource. This type class is given slightly higher priority so it will be preferred to the reflective version when resolving implicits.
47+
The scala-arm library also provides default implicits for common resources used from the Scala library or the Java SDK. In particular, anything that extends `java.lang.AutoCloseable` will *not* use reflection when closing the resource. This type class is given slightly higher priority so it will be preferred to the reflective version when resolving implicits.

src/main/scala/resource/Resource.scala

+3-3
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,14 @@ sealed trait LowPriorityResourceImplicits {
9898
}
9999

100100
sealed trait MediumPriorityResourceImplicits extends LowPriorityResourceImplicits {
101-
import _root_.java.io.Closeable
101+
import _root_.java.lang.AutoCloseable
102102

103-
implicit def closeableResource[A <: Closeable] = new Resource[A] {
103+
implicit def closeableResource[A <: AutoCloseable] = new Resource[A] {
104104
override def close(r: A) = r.close()
105105
// TODO - Should we actually catch less? What if there is a user exception not under IOException during
106106
// processing of a resource. We should still close it.
107107
//override val possibleExceptions = List(classOf[IOException])
108-
override def toString = "Resource[java.io.Closeable]"
108+
override def toString = "Resource[java.lang.AutoCloseable]"
109109
}
110110

111111
//Add All JDBC related handlers.

src/main/scala/resource/package.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ package object resource {
77
type ErrorHolder[A] = Either[List[Throwable],A]
88
/**
99
* Creates a ManagedResource for any type with a Resource type class implementation. This includes all
10-
* java.io.Closeable subclasses, and any types that have a close or dispose method. You can also provide your own
10+
* java.lang.AutoCloseable subclasses, and any types that have a close or dispose method. You can also provide your own
1111
* resource type class implementations in your own scope.
1212
*/
1313
def managed[A : Resource : OptManifest](opener: => A) : ManagedResource[A] = new DefaultManagedResource(opener)

0 commit comments

Comments
 (0)