Skip to content

P1.memo() sometimes returns null when accessed concurrently #105

Closed

Description

@mperry

Paweł Krupiński reported an issue in the group as per below (https://groups.google.com/forum/#!topic/functionaljava/nSPIBAvAWVY):

Hi.
We started noticing NullPointerExceptions in our code that accessed fj.data.Stream instances concurrently.

I was able to trace it down to P1.memo() creating a P1 that sometimes returns null from ._1() call when accessed concurrently.
Here's how to reproduce it (sometimes you need to run it multiple times) on Java 8 and functionaljava 4.2:

final P1<String> p1 = P.p("Bla").memo();
ExecutorService executorService = Executors.newCachedThreadPool();
for (int i = 0; i < 1000; i++) {
    executorService.submit(() -> {
        if (p1._1() == null) {
            System.out.println("Null");
        }
    });
}

executorService.shutdown();
executorService.awaitTermination(10, TimeUnit.DAYS);

Activity

  1. added a commit that references this issue on Feb 11, 2015
    a0d4ec5
  2. knutwalker commented on Feb 11, 2015

    @knutwalker
    Contributor

    Hi, I took a stab at this in #106.

  3. added this to the v4.3 milestone on Feb 11, 2015
  4. zot commented on Feb 14, 2015

    @zot

    moved my comment to #106 :)

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

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions