Skip to content

Do not report RV_RETURN_VALUE_IGNORED_NO_SIDE_EFFECT with Mockito.doAnswer() #3334

@peterxcli

Description

@peterxcli

Description

SnapshotDiffManager spy = spy(snapshotDiffManager);

doAnswer(invocation -> {
      String[] split = invocation.getArgument(0, String.class).split("/");
      String keyName = split[split.length - 1];
      return Integer.parseInt(keyName.substring(3)) % 2 == 0;
    }
).when(spy).isKeyInBucket(anyString(), anyMap(), anyString());

This code leads to:

M D RV: Return value of SnapshotDiffManager.isKeyInBucket(String, Map, String) ignored, but method has no side effect  At TestSnapshotDiffManager.java:[line 689]

In a Mockito.doAnswer(...) chained call it is OK to ignore the return value.

Related link

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions