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

Incomplete stack trace returned from spy inside another spy #2489

Closed
5 tasks done
holubec-petr opened this issue Nov 26, 2021 · 2 comments
Closed
5 tasks done

Incomplete stack trace returned from spy inside another spy #2489

holubec-petr opened this issue Nov 26, 2021 · 2 comments

Comments

@holubec-petr
Copy link

Hi,

due to the fix of issue #2238, the returned stack trace is not complete when an exception is thrown from a spy inside another spy.
The problem appeared in released version 3.9.0 (specifically 3.8.14) and still exists in 4.1.0.

I wrote a unit test simulating this behavior:
https://github.com/holubec-petr/mockito/blob/stack_trace_clean_up/src/test/java/org/mockito/internal/creation/bytebuddy/InlineDelegateByteBuddyMockMakerTest.java#L272

Problem is that the method MockMethodAdvice.hideRecursiveCall() is too aggressive when removing stack trace frames.

Check that

  • The mockito message in the stacktrace have useful information, but it didn't help
  • The problematic code (if that's possible) is copied here;
    Note that some configuration are impossible to mock via Mockito
  • Provide versions (mockito / jdk / os / any other relevant information)
  • Provide a Short, Self Contained, Correct (Compilable), Example of the issue
    (same as any question on stackoverflow.com)
  • Read the contributing guide
@TimvdLippe
Copy link
Contributor

Do you mind sending us a PR with the regression test and a corresponding fix? That would be awesome 🎉

@holubec-petr
Copy link
Author

I'm thinking about some fix the last few days and I don't know if I'll be able to provide any generic-enough fix.

Maybe that's just my lack of knowledge of why is this stack trace cleaning implemented and what frames exactly we want to remove.

For example, this unit test:
https://github.com/mockito/mockito/blob/main/src/test/java/org/mockito/internal/creation/bytebuddy/InlineDelegateByteBuddyMockMakerTest.java#L270
Why exactly those 3 elements should remain in stack trace after cleaning?

andrey-kozel pushed a commit to andrey-kozel/mockito that referenced this issue Jan 21, 2022
…e nested spies. Behaviour of the filtering redundant method calls from stacktrace was changed. Now it removes only lines that have the same method name and line number
andrey-kozel pushed a commit to andrey-kozel/mockito that referenced this issue Jan 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants