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

Fixes #2331 #2369

Merged
merged 2 commits into from Jul 30, 2021
Merged

Fixes #2331 #2369

merged 2 commits into from Jul 30, 2021

Conversation

saurabh7248
Copy link
Contributor

@saurabh7248 saurabh7248 commented Jul 30, 2021

Has conditionally on basis of whether default answer is pass to actual methods made hash code and equals pass to actual methods.

Checklist

  • Read the contributing guide
  • PR should be motivated, i.e. what does it fix, why, and if relevant how
  • If possible / relevant include an example in the description, that could help all readers
    including project members to get a better picture of the change
  • Avoid other runtime dependencies
  • Meaningful commit history ; intention is important please rebase your commit history so that each
    commit is meaningful and help the people that will explore a change in 2 years
  • The pull request follows coding style
  • Mention Fixes #<issue number> in the description if relevant
  • At least one commit should mention Fixes #<issue number> if relevant

saurabh7248 added 2 commits July 30, 2021 10:38
Has conditionally on basis of whether default answer is pass to actual methods made hash code and equals pass to actual methods.
Has conditionally on basis of whether default answer is pass to actual methods made hash code and equals pass to actual methods.
Intellij seems to had only pushed import and not the test
@codecov-commenter
Copy link

codecov-commenter commented Jul 30, 2021

Codecov Report

Merging #2369 (6886b0f) into main (1ad8235) will decrease coverage by 0.13%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff              @@
##               main    #2369      +/-   ##
============================================
- Coverage     84.90%   84.77%   -0.14%     
+ Complexity     2794     2792       -2     
============================================
  Files           328      328              
  Lines          8480     8490      +10     
  Branches       1025     1026       +1     
============================================
- Hits           7200     7197       -3     
- Misses         1004     1015      +11     
- Partials        276      278       +2     
Impacted Files Coverage Δ
...on/bytebuddy/InlineDelegateByteBuddyMockMaker.java 65.82% <100.00%> (-2.72%) ⬇️
...kito/internal/creation/bytebuddy/MockFeatures.java 100.00% <100.00%> (ø)
...creation/bytebuddy/SubclassByteBuddyMockMaker.java 70.00% <100.00%> (+0.43%) ⬆️
.../creation/bytebuddy/SubclassBytecodeGenerator.java 81.64% <100.00%> (+0.85%) ⬆️
...mockito/internal/invocation/InvocationMatcher.java 98.00% <100.00%> (ø)
...rnal/util/reflection/ReflectionMemberAccessor.java 69.44% <0.00%> (-8.34%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1ad8235...6886b0f. Read the comment docs.

Copy link
Contributor

@TimvdLippe TimvdLippe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not ideal to have another branch, but I think it is the best way forward. Only 1 question, but the rest LGTM

@@ -77,7 +77,7 @@ public String toString() {

@Override
public boolean matches(Invocation candidate) {
return invocation.getMock().equals(candidate.getMock())
return invocation.getMock() == candidate.getMock()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure if I follow why this line was changed. Could you elaborate as to why?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider the test PartialMockingWithSpiesTest.shouldAllowStubbingOfMethodsThatDelegateToOtherMethods.
Now the call to getName is handled by MockMethodInterceptor.DispatcherDefaultingToRealMethod.interceptSuperCallable here the interceptor will not be null and it will go to interceptor.doIntercept. This finally leads to InvocationMatcher.matches

Now with changes in this pull request the call to equals is again delegated to MockMethodInterceptor.DispatcherDefaultingToRealMethod and it will come at same place. And this way it leads to stackoverflow. Earlier equals of spy was this==that. So i just replced equals with ==.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks for the explanation! That makes sense to me 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haha Thanks. Had missed to put links to the classes.

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.

None yet

3 participants