Skip to content
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

PagedSeq's slice throws a NPE if it starts on a page that hasn't been computed yet #6615

scabug opened this issue Nov 5, 2012 · 4 comments


Copy link

@scabug scabug commented Nov 5, 2012

Trying to take a slice of a PagedSeq that starts on a page that hasn't been computed yet throws a NullPointerException. For example, the following works as expected:

scala> import scala.collection.immutable.PagedSeq
import scala.collection.immutable.PagedSeq

scala> PagedSeq.fromStrings(List.fill(5000)("a")).slice(4095, 4096)
res0: scala.collection.immutable.PagedSeq[Char] = PagedSeq(a)

But if we start one character later in the sequence (at the beginning of the second page), we get the following:

scala> PagedSeq.fromStrings(List.fill(5000)("a")).slice(4096, 4097)
        at scala.collection.immutable.PagedSeq.slice(PagedSeq.scala:189)
        at .<init>(<console>:9)
        at .<clinit>(<console>)

The error does not occur if you force the second page to be computed (by calling toString or length, for example) before calling slice:

scala> val s = PagedSeq.fromStrings(List.fill(5000)("a"))
s: scala.collection.immutable.PagedSeq[Char] = PagedSeq(a, a, a,  ...
scala> s.slice(4096, 4097)
res2: scala.collection.immutable.PagedSeq[Char] = PagedSeq(a)
Copy link

@scabug scabug commented Nov 5, 2012

Imported From:
Reporter: Travis Brown (travisbrown)
Affected Versions: 2.9.2, 2.10.0-RC1

Copy link

@scabug scabug commented Nov 6, 2012

@jsuereth said:
Note: This isn't a blocker for 2.10.0, but we'll try to fix it in 2.10.1

Copy link

@scabug scabug commented May 23, 2013

@JamesIry said:
Not a regression in 2.10.2 and not a blocker so not a candidate for RC2

Copy link

@scabug scabug commented Jan 13, 2014

@scabug scabug closed this Jan 13, 2014
@scabug scabug added this to the 2.11.0-M8 milestone Apr 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants