Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@sideeffffect
Copy link
Member

fixes #1730

@iravid
Copy link
Member

iravid commented Sep 22, 2019

@sideeffffect what do you think of mixing the platform-specific trait directly into ZStream and using implicit evidence instead of implicit classes?

@iravid
Copy link
Member

iravid commented Sep 22, 2019

Oh actually someone pointed out in another PR that ScalaJS has InputStream. So we can move this code directly into ZStream.

@fsvehla
Copy link
Contributor

fsvehla commented Sep 23, 2019

Should we read more than a single byte on every read call?

@fsvehla
Copy link
Contributor

fsvehla commented Sep 23, 2019

close on the InputStream looks to me like a noop

@sideeffffect
Copy link
Member Author

there is toInputStream for all ZStream, StreamEffect, ZStreamChunk and StreamEffectChunk, as proper (non-extension) methods

Copy link
Member

@iravid iravid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One small fix and this is ready to go!

…ream

# Conflicts:
#	streams-tests/jvm/src/test/scala/zio/stream/StreamChunkSpec.scala
@iravid
Copy link
Member

iravid commented Sep 24, 2019

Ok, needs a quick rebase and we're good

@sideeffffect
Copy link
Member Author

@iravid so are we sure that the overhead of Chunk is low enough that we don't need also toInputStream from Stream[_, Array[Byte]]?

@sideeffffect sideeffffect changed the title Add a method for converting ZStream[Byte] to a ZManaged[java.io.InputStream] [WIP] Add a method for converting ZStream[Byte] to a ZManaged[java.io.InputStream] Sep 24, 2019
@iravid
Copy link
Member

iravid commented Sep 24, 2019

@sideeffffect Chunk definitely has some overhead, but I believe that's offset by the utility of combinators available on ZStreamChunk. We're also designing the rest of the library to always return chunks, rather than arrays, when applicable - e.g. ZStream.fromInputStream.

@sideeffffect
Copy link
Member Author

my builds are now failing with

[warn] Thread[scala-execution-context-global-672,5,zio-timer] loading zio/RTSSpec.class after test or run has completed. This is a likely resource leak.
java.lang.OutOfMemoryError: GC overhead limit exceeded

and

[warn] Thread[ForkJoinPool-1-worker-1,5,zio-default-blocking] loading zio.RTSSpec$$anonfun$testTimeoutOfLongComputation$1$$anonfun$apply$10$$anonfun$apply$mcZ$sp$2$$anonfun$apply$321$$anonfun$apply$11 after test or run has completed. This is a likely resource leak.
java.lang.OutOfMemoryError: GC overhead limit exceeded
	at scala.collection.mutable.ListBuffer.$plus$eq(ListBuffer.scala:174)
	at scala.collection.mutable.ListBuffer.$plus$eq(ListBuffer.scala:45)
...

I don't know how my changes could introduce such a problem... :-/ does it happen also in master?

@sideeffffect sideeffffect requested a review from iravid September 24, 2019 11:39
@sideeffffect sideeffffect changed the title [WIP] Add a method for converting ZStream[Byte] to a ZManaged[java.io.InputStream] Add a method for converting ZStream[Byte] to a ZManaged[java.io.InputStream] Sep 24, 2019
} yield (chunk, i)

def chunkGen[R <: Random, A: ClassTag](a: Gen[R, A], max: Int): Gen[R with Sized, Chunk[A]] =
private def chunkGen[R <: Random, A: ClassTag](a: Gen[R, A], max: Int): Gen[R with Sized, Chunk[A]] =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we keep this public? No reason for it to be private.

@sideeffffect
Copy link
Member Author

@iravid ready to merge

@sideeffffect sideeffffect requested a review from iravid September 24, 2019 15:54
Copy link
Member

@iravid iravid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome work @sideeffffect. Thanks for contributing this!

@iravid iravid merged commit 567476e into zio:master Sep 24, 2019
Twizty pushed a commit to Twizty/zio that referenced this pull request Nov 13, 2019
@sideeffffect sideeffffect deleted the 1730-java-InputStream branch September 25, 2020 21:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a method for converting ZStream[Byte] to a ZManaged[java.io.InputStream]

4 participants