Skip to content

Commit d65bd77

Browse files
authored
Merge pull request #1275 from mpilquist/bugfix/chunk-toarray-underflow
Fixed a bug in Chunk#toArray when the backing type is ByteBufferChunk
2 parents b941468 + def64a2 commit d65bd77

File tree

5 files changed

+12
-11
lines changed

5 files changed

+12
-11
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ script:
2727
- sbt ++$TRAVIS_SCALA_VERSION -Dfile.encoding=UTF8 -Dfs2.test.verbose testJVM
2828
- sbt ++$TRAVIS_SCALA_VERSION -Dfile.encoding=UTF8 -Dfs2.test.verbose testJS
2929
- sbt ++$TRAVIS_SCALA_VERSION -Dfile.encoding=UTF8 doc mimaReportBinaryIssues
30-
- (test $TRAVIS_SCALA_VERSION == "2.11.12" && sbt ++$TRAVIS_SCALA_VERSION -Dfile.encoding=UTF8 -J-Xms2g -J-Xmx2g docs/tut) || test $TRAVIS_SCALA_VERSION == "2.12.6"
30+
- (test $TRAVIS_SCALA_VERSION == "2.11.12" && sbt ++$TRAVIS_SCALA_VERSION -Dfile.encoding=UTF8 -J-Xms2g -J-Xmx2g docs/tut) || test $TRAVIS_SCALA_VERSION == "2.12.7"
3131

3232
after_success:
3333
- test $PUBLISH == "true" && test $TRAVIS_PULL_REQUEST == "false" && test $TRAVIS_BRANCH == "series/1.0" && sbt +publish

core/shared/src/main/scala/fs2/Chunk.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -784,7 +784,7 @@ object Chunk {
784784
val bs = new Array[C](size)
785785
val b = duplicate(buf)
786786
b.position(offset)
787-
get(buf, bs, 0, size)
787+
get(b, bs, 0, size)
788788
bs.asInstanceOf[Array[O2]]
789789
}
790790

core/shared/src/main/scala/fs2/concurrent/Queue.scala

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ trait Dequeue1[F[_], A] {
4343
def dequeue1: F[A]
4444

4545
/**
46-
* Tries to dequeue a single element. Unlike `dequeue1`, this method does not semantically
47-
* block until a chunk is available - instead, `None` is returned immediately.
48-
*/
46+
* Tries to dequeue a single element. Unlike `dequeue1`, this method does not semantically
47+
* block until a chunk is available - instead, `None` is returned immediately.
48+
*/
4949
def tryDequeue1: F[Option[A]]
5050
}
5151

@@ -56,10 +56,10 @@ trait DequeueChunk1[F[_], G[_], A] {
5656
def dequeueChunk1(maxSize: Int): F[G[Chunk[A]]]
5757

5858
/**
59-
* Tries to dequeue a single chunk of no more than `max size` elements.
60-
* Unlike `dequeueChunk1`, this method does not semantically block until a chunk is available -
61-
* instead, `None` is returned immediately.
62-
*/
59+
* Tries to dequeue a single chunk of no more than `max size` elements.
60+
* Unlike `dequeueChunk1`, this method does not semantically block until a chunk is available -
61+
* instead, `None` is returned immediately.
62+
*/
6363
def tryDequeueChunk1(maxSize: Int): F[Option[G[Chunk[A]]]]
6464
}
6565

core/shared/src/test/scala/fs2/ChunkProps.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@ object ChunkProps
3333
def propToArray[A: ClassTag: Arbitrary, C <: Chunk[A]: Arbitrary] =
3434
forAll { c: C =>
3535
c.toArray.toVector shouldBe c.toVector
36+
// Do it twice to make sure the first time didn't mutate state
37+
c.toArray.toVector shouldBe c.toVector
3638
}
37-
39+
3840
def propCopyToArray[A: ClassTag: Arbitrary, C <: Chunk[A]: Arbitrary] =
3941
forAll { c: C =>
4042
val arr = new Array[A](c.size * 2)

io/src/main/scala/fs2/io/file/file.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import scala.concurrent.duration._
77
import java.nio.file.{Path, StandardOpenOption, WatchEvent}
88

99
import cats.effect.{Concurrent, ContextShift, Resource, Sync}
10-
import cats.implicits._
1110

1211
/** Provides support for working with files. */
1312
package object file {

0 commit comments

Comments
 (0)