Skip to content

Commit d9fba8c

Browse files
committed
WIP: Scala 2.13
1 parent ca1cefc commit d9fba8c

File tree

3 files changed

+19
-16
lines changed

3 files changed

+19
-16
lines changed

scala/build.sbt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name := "webknossos-wrap"
22

3-
scalaVersion := "2.12.7"
3+
scalaVersion := "2.13.11"
44

55
javaOptions in test ++= Seq("-Xmx512m")
66

@@ -56,7 +56,6 @@ pomExtra := (
5656

5757
libraryDependencies ++= Seq(
5858
"com.google.guava" % "guava" % "21.0",
59-
"com.jsuereth" %% "scala-arm" % "2.0",
6059
"net.jpountz.lz4" % "lz4" % "1.3.0",
6160
"net.liftweb" % "lift-common_2.10" % "2.6-M3",
6261
"net.liftweb" % "lift-util_2.10" % "3.0-M1",

scala/src/main/scala/com/scalableminds/webknossos/wrap/WKWFile.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ class WKWFile(val header: WKWHeader, fileMode: FileMode.Value, underlyingFile: R
207207
val sourceBlockLengths = if (header.isCompressed) {
208208
header.jumpTable.sliding(2).map(a => (a(1) - a(0)).toInt)
209209
} else {
210-
Array.fill(header.numBlocksPerCube)(header.numBytesPerBlock).toIterator
210+
Array.fill(header.numBlocksPerCube)(header.numBytesPerBlock).iterator
211211
}
212212

213213
val targetBlockLengths = sourceBlockLengths.foldLeft[Box[Seq[Int]]](Full(Seq.empty)) {
Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,29 @@
11
package com.scalableminds.webknossos.wrap.util
22

3-
import net.liftweb.common.{Box, Failure}
3+
import net.liftweb.common.Box
4+
import net.liftweb.common.{Failure => BoxFailure}
45
import net.liftweb.util.Helpers.tryo
5-
import resource._
6+
7+
import scala.util.Using.Releasable
8+
import scala.util.{Success, Using, Failure => TryFailure}
9+
610

711
object ResourceBox {
8-
def apply[R : Resource](resource: => R): Box[R] = {
12+
def apply[R : Releasable](resource: => R): Box[R] = {
913
tryo(resource) ~> "Exception during resource creation"
1014
}
1115

12-
def manage[R : Resource, T](resource: => R)(f: R => Box[T]): Box[T] = {
16+
def manage[R : Releasable, T](resource: => R)(f: R => Box[T]): Box[T] = {
1317
for {
1418
r <- ResourceBox(resource)
15-
result <- managed(r).map(f).either.either match {
16-
case Left(ex) =>
17-
Failure(s"Exception during resource management: ${ex.toString}")
18-
case Right(result) =>
19-
result
20-
}
21-
} yield {
22-
result
23-
}
19+
result <- Using.Manager { use =>
20+
f(use(r))
21+
} match {
22+
case TryFailure(ex) =>
23+
BoxFailure(s"Exception during resource management: ${ex.toString}")
24+
case Success(result) =>
25+
result
26+
}
27+
} yield result
2428
}
2529
}

0 commit comments

Comments
 (0)