You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
P1.memo() sometimes returns null when accessed concurrently #105
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
Fix race condition in P1.memo()
knutwalker commentedon Feb 11, 2015
Hi, I took a stab at this in #106.
zot commentedon Feb 14, 2015
moved my comment to #106 :)