GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — StackOverflowError mocking our functional objects · Issue #890 · googleapis/google-cloud-java

StackOverflowError mocking our functional objects #890

New issue
Copy link
New issue
Copy link
Closed
Closed
StackOverflowError mocking our functional objects#890
Copy link
Assignees
mziccard
Labels
type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Description

@mziccard
mziccard
opened on Apr 11, 2016
Issue body actions

There seem to be a problem with EasyMock (as well as Mockito) when mocking classes that have a final equals() method that in its body calls other methods on the current object.
This results in a StackOverflowError as the following:

java.lang.StackOverflowError
    at java.util.ArrayList$Itr.<init>(ArrayList.java:820)
    at java.util.ArrayList$Itr.<init>(ArrayList.java:820)
    at java.util.ArrayList.iterator(ArrayList.java:814)
    at org.easymock.internal.UnorderedBehavior.addActual(UnorderedBehavior.java:50)
    at org.easymock.internal.MocksBehavior.addActual(MocksBehavior.java:87)
    at org.easymock.internal.ReplayState.invokeInner(ReplayState.java:58)
    at org.easymock.internal.ReplayState.invoke(ReplayState.java:46)
    at org.easymock.internal.MockInvocationHandler.invoke(MockInvocationHandler.java:40)
    at org.easymock.internal.ObjectMethodsFilter.invoke(ObjectMethodsFilter.java:94)
    at org.easymock.internal.ClassProxyFactory$MockMethodInterceptor.intercept(ClassProxyFactory.java:97)
    at com.google.gcloud.storage.Blob$$EnhancerByCGLIB$$aa59c155.toPb(<generated>)
    at com.google.gcloud.storage.Blob.equals(Blob.java:529)
    at org.easymock.internal.ExpectedInvocation.matches(ExpectedInvocation.java:85)
    at org.easymock.internal.UnorderedBehavior.addActual(UnorderedBehavior.java:57)
    at org.easymock.internal.MocksBehavior.addActual(MocksBehavior.java:87)
    at org.easymock.internal.ReplayState.invokeInner(ReplayState.java:58)
    at org.easymock.internal.ReplayState.invoke(ReplayState.java:46)
    at org.easymock.internal.MockInvocationHandler.invoke(MockInvocationHandler.java:40)
    at org.easymock.internal.ObjectMethodsFilter.invoke(ObjectMethodsFilter.java:94)
    at org.easymock.internal.ClassProxyFactory$MockMethodInterceptor.intercept(ClassProxyFactory.java:97)
    at com.google.gcloud.storage.Blob$$EnhancerByCGLIB$$aa59c155.toPb(<generated>)
    at com.google.gcloud.storage.Blob.equals(Blob.java:529)

To overcome this error all final equals methods should first check for "pointer" equality. For instance Blob.equals must become:

@Override
public final boolean equals(Object obj) {
  return this == obj || (obj instanceof Blob && Objects.equals(toPb(), ((Blob) obj).toPb())
      && Objects.equals(options, ((Blob) obj).options));
}

This should be fixed ASAP. Even tough we don't encourage users to mock our objects and provide test helpers to aid testing we don't want them to stumble upon this error.

This issue should remain open until fixed in compute as well.

Activity

  1. mziccard
    added
    type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.
    testing
    on Apr 11, 2016
  2. mziccard
    self-assigned this
    on Apr 11, 2016
  3. mziccard commented on Apr 15, 2016

    @mziccard
    mziccard
    on Apr 15, 2016
    ContributorAuthor
    More actions

    This was fixed in #892

  4. mziccard
    closed this as completedon Apr 15, 2016
  5. github-actions
    added a commit that references this issue on Jun 21, 2022

    build(deps): update dependency com.google.cloud:google-cloud-shared-c…

    7706a99
  6. github-actions
    added a commit that references this issue on Jul 6, 2022

    build(deps): update dependency com.google.cloud:google-cloud-shared-c…

    06c30bf
  7. github-actions
    added 2 commits that reference this issue on Jul 20, 2022

    build(deps): update dependency org.apache.maven.plugins:maven-deploy-…

    c482d95

    chore(main): release 3.3.3 (#890)

    a0bec1c
  8. github-actions
    added a commit that references this issue on Aug 18, 2022

    deps: update dependency com.google.cloud:google-cloud-pubsub to v1.12…

    6cf0475
  9. github-actions
    added 3 commits that reference this issue on Sep 15, 2022

    deps: update dependency com.google.cloud:google-cloud-shared-dependen…

    408f8cb

    chore(main): release 2.3.4 (#891)

    b12c15f

    chore(main): release 2.10.0 (#918)

    86370a6
  10. github-actions
    added 4 commits that reference this issue on Sep 30, 2022

    deps: update dependency protobuf to v4 (#890)

    13080bb

    chore(main): release 2.3.7 (#899)

    cc9c5b6

    chore(main): release 2.6.8 (#890)

    80028ea

    chore(main): release 1.9.5 (googleapis#898)

    0541adc
  11. github-actions
    added a commit that references this issue on Nov 9, 2022

    chore(deps): update dependency com.google.cloud:libraries-bom to v26.…

    b252729
  12. suztomo
    added 4 commits that reference this issue on Feb 1, 2023

    deps: update dependency com.google.api:gax-bom to v2.18.7 (#890)

    9412848

    chore(main): release 2.8.6 (#892)

    2ef6225

    deps: update google.core.version to v2.8.24 (#890)

    70791a5

    chore(main): release 3.0.6 (#888)

    38cd9f3
  13. chingor13
    added a commit that references this issue on Jan 6, 2026

    chore: pin versions of certifi and google-resumable-media (#1660) (#890)

    d4d6841
  14. chingor13
    added a commit that references this issue on Jan 22, 2026

    chore(deps): update dependency com.google.cloud:google-cloud-datastor…

    0b5fea5
  15. chingor13
    added a commit that references this issue on Feb 24, 2026

    chore(deps): update dependency org.apache.maven.plugins:maven-compile…

    608ddf7
  16. chingor13
    added a commit that references this issue on Mar 12, 2026

    chore(deps): update dependency org.apache.maven.plugins:maven-compile…

    46b342d
  17. suztomo
    added a commit that references this issue on Mar 23, 2026

    chore(main): release 2.7.3 (googleapis#890)

    07adc51
  18. suztomo
    added a commit that references this issue on Mar 30, 2026

    test(deps): update dependency org.mockito:mockito-core to v4.5.0 (#890)

    1c6b12c
  19. lqiu96
    added a commit that references this issue on Apr 1, 2026

    test(deps): update dependency org.mockito:mockito-core to v4.5.0 (#890)

    d3819b2
  20. benjaminp
    added a commit that references this issue on Jul 13, 2026

    chore: release 1.27.2-SNAPSHOT (googleapis#890)

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

Metadata

Metadata

Assignees

  • @mziccard
    mziccard

Labels

type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.