Scala ARM is a library for Automatic Resource Management
Questions tagged [scala-arm]
9 questions
2
votes
2 answers
managed (ARM) in scala for nested resources
So, I have this code in scala which I am converting to managed.
val file_out = new FileOutputStream(new java.io.File(filePath, resultFile + ".tar.gz"));
val buffer_out = new BufferedOutputStream(file_out);
val gzip_out = new…

Asad Iqbal
- 3,241
- 4
- 32
- 52
1
vote
1 answer
How can I compose resources in Scala while still closing them correctly with scala-arm?
I have a class that takes a local file, transforms it, and stores it in GCS:
import java.nio.channels.Channels
import java.nio.file.{ Files, Path }
import java.util.zip.{ GZIPOutputStream, ZipInputStream }
import com.google.cloud.storage.{…

Etienne Neveu
- 12,604
- 9
- 36
- 59
1
vote
1 answer
Scala-ARM for class members?
I'm very new to Scala, so please excuse my basic question.
I'm trying to get Scala-Arm to manage the release of a class member, but having trouble with scoping.
Although the following code compiles, it fails with
java.lang.NoSuchMethodError:…

puppet
- 660
- 1
- 5
- 8
0
votes
0 answers
scala-arm: Expression of type Iterator[Int] doesn't conform to expected type ManagedResource[B_]
This code using "com.jsuereth" %% "scala-arm" % "2.0":
import resource._
val lineLengths = for {
source <- managed(scala.io.Source.fromFile("file.txt"))
line <- source.getLines()
} yield line.length
Fails compiling with error:
Expression of…

David Portabella
- 12,390
- 27
- 101
- 182
0
votes
1 answer
How do I create a seq of string from a file that is opened with managed?
Tried this to create a seq from file:
def getFileAsList(bufferedReader: BufferedReader): Seq[String] ={
import resource._
for(source <- managed(bufferedReader)){
for(line<-source.lines())
yield line
…

bhank
- 11
- 4
0
votes
0 answers
Managed resource closing when inside another managed resource
I'm using scala-arm and I have a code similar to this one:
val pathList = List("wrongPath1", "path2", "path3")
val enumerator: Enumerator[Array[Byte]] = Enumerator.outputStream { os =>
managed(new ZipOutputStream(os)).map { zip =>
…

Daniel Avalos
- 21
- 4
0
votes
1 answer
Scala-arm import error: missing arguments for method resource
I've added scala-arm to my Play project but got compile error:
Can't understand what is wrong. Import line was taken from docs.

sergeda
- 2,061
- 3
- 20
- 43
0
votes
1 answer
ScalaARM error - value filter is not a member of ManagedResource
Following the example on the ScalaARM homepage I wrote this:
for ( ir: IndexReader <- managed(DirectoryReader.open(FSDirectory.open(file)))) { ... }
(Open a lucene IndexReader)
however I get this compilation error:
Error:(34, 45) Play 2 Compiler: …
user404345
0
votes
2 answers
scala-arm. Return type
I'm using scala-arm library to automatically release/close resources (for example InputStream).
But the problem is that code below returns ExtractableManagedResource[Int], not just Int as I want.
val result = for(responseStream <-…

WelcomeTo
- 19,843
- 53
- 170
- 286