8000 Fix MIMA Checks by adamgfraser · Pull Request #7148 · zio/zio · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix MIMA Checks #7148

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ lazy val streams = crossProject(JSPlatform, JVMPlatform, NativePlatform)
Seq("-P:silencer:globalFilters=[zio.stacktracer.TracingImplicits.disableAutoTrace]")
}
)
.jvmSettings(mimaSettings(failOnProblem = false))
.jvmSettings(mimaSettings(failOnProblem = true))
.nativeSettings(nativeSettings)

lazy val streamsTests = crossProject(JSPlatform, JVMPlatform, NativePlatform)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,20 @@ private[managed] trait ZManagedCompatPlatformSpecific {
)(implicit trace: Trace): ZStream[R, E, A] =
ZStream.asyncScoped[R, E, A](register(_).scoped, outputBuffer)

/**
* Creates a stream from a managed Java stream
*/
final def fromJavaStreamManaged[R, A](stream: => ZManaged[R, Throwable, java.util.stream.Stream[A]])(implicit
trace: Trace
): ZStream[R, Throwable, A] =
fromJavaStreamManaged(stream, ZStream.DefaultChunkSize)

/**
* Creates a stream from a managed Java stream
*/
final def fromJavaStreamManaged[R, A](
stream: => ZManaged[R, Throwable, java.util.stream.Stream[A]],
chunkSize: Int = ZStream.DefaultChunkSize
chunkSize: Int
)(implicit trace: Trace): ZStream[R, Throwable, A] =
ZStream.fromJavaStreamScoped[R, A](stream.scoped, chunkSize)

Expand Down
10 changes: 9 additions & 1 deletion managed/shared/src/main/scala/zio/managed/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -383,12 +383,20 @@ package object managed extends ZManagedCompatPlatformSpecific {
): ZStream[R, Throwable, A] =
ZStream.fromIteratorScoped[R, A](iterator.scoped, maxChunkSize)

/**
* Creates a stream from a managed iterator
*/
def fromJavaIteratorManaged[R, A](iterator: => ZManaged[R, Throwable, java.util.Iterator[A]])(implicit
trace: Trace
): ZStream[R, Throwable, A] =
fromJavaIteratorManaged(iterator, ZStream.DefaultChunkSize)

/**
* Creates a stream from a managed iterator
*/
def fromJavaIteratorManaged[R, A](
iterator: => ZManaged[R, Throwable, java.util.Iterator[A]],
chunkSize: Int = ZStream.DefaultChunkSize
chunkSize: Int
)(implicit
trace: Trace
): ZStream[R, Throwable, A] =
Expand Down
40 changes: 36 additions & 4 deletions streams/jvm/src/main/scala/zio/stream/platform.scala
Original file line number Diff line number Diff line change
Expand Up @@ -324,44 +324,76 @@ private[stream] trait ZStreamPlatformSpecificConstructors {
} yield result
}

/**
* Creates a stream from a Java stream
*/
final def fromJavaStream[A](stream: => java.util.stream.Stream[A])(implicit
trace: Trace
): ZStream[Any, Throwable, A] =
fromJavaStream(stream, ZStream.DefaultChunkSize)

/**
* Creates a stream from a Java stream
*/
final def fromJavaStream[A](
stream: => java.util.stream.Stream[A],
chunkSize: Int = ZStream.DefaultChunkSize
chunkSize: Int
)(implicit trace: Trace): ZStream[Any, Throwable, A] =
ZStream.fromJavaIteratorScoped(
ZIO.acquireRelease(ZIO.attempt(stream))(stream => ZIO.succeed(stream.close())).map(_.iterator()),
chunkSize
)

/**
* Creates a stream from a scoped Java stream
*/
final def fromJavaStreamScoped[R, A](stream: => ZIO[Scope with R, Throwable, java.util.stream.Stream[A]])(implicit
trace: Trace
): ZStream[R, Throwable, A] =
fromJavaStreamScoped[R, A](stream, ZStream.DefaultChunkSize)

/**
* Creates a stream from a scoped Java stream
*/
final def fromJavaStreamScoped[R, A](
stream: => ZIO[Scope with R, Throwable, java.util.stream.Stream[A]],
chunkSize: Int = ZStream.DefaultChunkSize
chunkSize: Int
)(implicit trace: Trace): ZStream[R, Throwable, A] =
ZStream.scoped[R](stream).flatMap(ZStream.fromJavaStream(_, chunkSize))

/**
* Creates a stream from a Java stream
*/
final def fromJavaStreamSucceed[R, A](stream: => java.util.stream.Stream[A])(implicit
trace: Trace
): ZStream[R, Nothing, A] =
fromJavaStreamSucceed(stream, ZStream.DefaultChunkSize)

/**
* Creates a stream from a Java stream
*/
final def fromJavaStreamSucceed[R, A](
stream: => java.util.stream.Stream[A],
chunkSize: Int = ZStream.DefaultChunkSize
chunkSize: Int
)(implicit
trace: Trace
): ZStream[R, Nothing, A] =
ZStream.fromJavaIteratorSucceed(stream.iterator(), chunkSize)

/**
* Creates a stream from a Java stream
*/
final def fromJavaStreamZIO[R, A](stream: => ZIO[R, Throwable, java.util.stream.Stream[A]])(implicit
trace: Trace
): ZStream[R, Throwable, A] =
fromJavaStreamZIO(stream, ZStream.DefaultChunkSize)

/**
* Creates a stream from a Java stream
*/
final def fromJavaStreamZIO[R, A](
stream: => ZIO[R, Throwable, java.util.stream.Stream[A]],
chunkSize: Int = ZStream.DefaultChunkSize
chunkSize: Int
)(implicit
trace: Trace
): ZStream[R, Throwable, A] =
Expand Down
46 changes: 41 additions & 5 deletions streams/shared/src/main/scala/zio/stream/ZStream.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4402,21 +4402,35 @@ object ZStream extends ZStreamPlatformSpecificConstructors {
}
}

/**
* Creates a stream from an iterator that may potentially throw exceptions
*/
def fromIteratorZIO[R, A](iterator: => ZIO[R, Throwable, Iterator[A]])(implicit
trace: Trace
): ZStream[R, Throwable, A] =
fromIteratorZIO(iterator, DefaultChunkSize)

/**
* Creates a stream from an iterator that may potentially throw exceptions
*/
def fromIteratorZIO[R, A](
iterator: => ZIO[R, Throwable, Iterator[A]],
chunkSize: Int = DefaultChunkSize
chunkSize: Int
)(implicit trace: Trace): ZStream[R, Throwable, A] =
fromZIO(iterator).flatMap(fromIterator(_, chunkSize))

/**
* Creates a stream from a Java iterator that may throw exceptions
*/
def fromJavaIterator[A](iterator: => java.util.Iterator[A])(implicit trace: Trace): ZStream[Any, Throwable, A] =
fromJavaIterator(iterator, DefaultChunkSize)

/**
* Creates a stream from a Java iterator that may throw exceptions
*/
def fromJavaIterator[A](
iterator: => java.util.Iterator[A],
chunkSize: Int = DefaultChunkSize
chunkSize: Int
)(implicit trace: Trace): ZStream[Any, Throwable, A] =
fromIterator(
{
Expand All @@ -4429,23 +4443,37 @@ object ZStream extends ZStreamPlatformSpecificConstructors {
chunkSize
)

/**
* Creates a stream from a scoped iterator
*/
def fromJavaIteratorScoped[R, A](iterator: => ZIO[Scope with R, Throwable, java.util.Iterator[A]])(implicit
trace: Trace
): ZStream[R, Throwable, A] =
fromJavaIteratorScoped[R, A](iterator, DefaultChunkSize)

/**
* Creates a stream from a scoped iterator
*/
def fromJavaIteratorScoped[R, A](
iterator: => ZIO[Scope with R, Throwable, java.util.Iterator[A]],
chunkSize: Int = DefaultChunkSize
chunkSize: Int
)(implicit
trace: Trace
): ZStream[R, Throwable, A] =
scoped[R](iterator).flatMap(fromJavaIterator(_, chunkSize))

/**
* Creates a stream from a Java iterator
*/
def fromJavaIteratorSucceed[A](iterator: => java.util.Iterator[A])(implicit trace: Trace): ZStream[Any, Nothing, A] =
fromJavaIteratorSucceed(iterator, DefaultChunkSize)

/**
* Creates a stream from a Java iterator
*/
def fromJavaIteratorSucceed[A](
iterator: => java.util.Iterator[A],
chunkSize: Int = DefaultChunkSize
chunkSize: Int
)(implicit trace: Trace): ZStream[Any, Nothing, A] =
fromIteratorSucceed(
{
Expand All @@ -4458,12 +4486,20 @@ object ZStream extends ZStreamPlatformSpecificConstructors {
chunkSize
)

/**
* Creates a stream from a Java iterator that may potentially throw exceptions
*/
def fromJavaIteratorZIO[R, A](iterator: => ZIO[R, Throwable, java.util.Iterator[A]])(implicit
trace: Trace
): ZStream[R, Throwable, A] =
fromJavaIteratorZIO(iterator, DefaultChunkSize)

/**
* Creates a stream from a Java iterator that may potentially throw exceptions
*/
def fromJavaIteratorZIO[R, A](
iterator: => ZIO[R, Throwable, java.util.Iterator[A]],
chunkSize: Int = DefaultChunkSize
chunkSize: Int
)(implicit trace: Trace): ZStream[R, Throwable, A] =
fromZIO(iterator).flatMap(fromJavaIterator(_, chunkSize))

Expand Down
0