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

Infinite loop in Function* fixed #513

Merged
merged 1 commit into from
Aug 25, 2015

Conversation

ruslansennov
Copy link
Member

@danieldietrich please check this test on current branch

private static Function1<Integer, Integer> recurrent1 = (i1) -> i1 <= 0 ? i1 : Function1Test.recurrent2.apply(i1 - 1) + 1;
private static Function1<Integer, Integer> recurrent2 = Function1Test.recurrent1.memoized();

@Test
public void shouldCalculatedRecursively() {
    assertThat(recurrent1.apply(11)).isEqualTo(11);
    assertThat(recurrent1.apply(22)).isEqualTo(22);
}

I believe you'll see infinite loop because of internal architecture of ConcurrentHashMap. We should use java.util.HashMap inside synchronized block...

@danieldietrich
Copy link
Contributor

You're right - I checked it on current branch and it results in an infinite loop. Good finding!

danieldietrich added a commit that referenced this pull request Aug 25, 2015
Infinite loop in Function* fixed
@danieldietrich danieldietrich merged commit 7b56ccd into vavr-io:master Aug 25, 2015
@ruslansennov ruslansennov deleted the infLoop2 branch August 25, 2015 18:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants