Skip to content

Should Stream.iteratorStream be deprecated? #304

Description

@clinuxrulz

The following static method in Stream is unsafe.

public static <A> Stream<A> iteratorStream(final Iterator<A> it)

Due to Stream's use of WeakRef, when you visit the elements of Stream you can get a different result on the 2nd pass. (Internal mutable iterator keeps its state while cache is cleared)

I think this method should be avoided at all times because its behavior is unpredictable.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions