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

StackOverflowException with HashMap #35

Closed
novaterata opened this Issue Feb 28, 2018 · 5 comments

Comments

2 participants
@novaterata

novaterata commented Feb 28, 2018

I think this might be related to mockito/mockito#818 as maybe it was ported from the culprit over there.
I'm using 1.7.8 and actually in my case I'm not mocking a HashMap, but returning one from an every block

 val blob : CloudBlockBlob = mockk() // from azure-storage-java  
 val metadata : HashMap<String?,String?> = hashMapOf()
 every { blob.metadata } returns metadata

The StackOverflowException occurs when blob calls metadata. I don't know why HashMap is getting mocked though.
Honestly I don't know what is happening but that mockito bug looked too similar to ignore

Exception in thread "main" java.lang.StackOverflowError
at java.lang.Class.getDeclaredMethod(Class.java:2127)
at java.util.HashMap.get(HashMap.java:556)
at sun.reflect.Reflection.filterMethods(Reflection.java:291)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
@oleksiyp

This comment has been minimized.

Collaborator

oleksiyp commented Feb 28, 2018

Thanks for reporting it. Indeed class transformation is very similar to Mockito.

@oleksiyp oleksiyp added the bug label Feb 28, 2018

oleksiyp added a commit that referenced this issue Mar 4, 2018

@oleksiyp

This comment has been minimized.

Collaborator

oleksiyp commented Mar 4, 2018

The fix is here, it is a little bit ugly, but should be OK. To make it really nice, ByteBuddy should be changed.

@novaterata

This comment has been minimized.

novaterata commented Mar 5, 2018

Thanks, I'm using a workaround now, I'll test after the next release when I have some down time

@oleksiyp

This comment has been minimized.

Collaborator

oleksiyp commented Mar 8, 2018

Version 1.7.10 released, please check if it fixes your case and close the ticket.

@novaterata

This comment has been minimized.

novaterata commented Mar 9, 2018

That fixed it thanks!

@novaterata novaterata closed this Mar 9, 2018

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