Skip to content

Fix off-by-one regression in AbstractMethodMockingControl [SPR-11385] #16012

Closed
@spring-projects-issues

Description

@spring-projects-issues

Sam Brannen opened SPR-11385 and commented

Status Quo

AnnotationDrivenStaticEntityMockingControlTests has been omitted from the build for quite some time (perhaps forever) since it was previously named AnnotationDrivenStaticEntityMockingControlTest which did not comply with Spring Framework's naming convention for test classes. Consequently, the tests within this class have not been included in the test suite.

Due to changes to the build configuration in #16011, it is now apparent that some of the tests in AnnotationDrivenStaticEntityMockingControlTests are broken.


Analysis

Initial analysis of the failing tests has made it apparent that there is an off-by-one bug in the implementation of AbstractMethodMockingControl.Expectations.nextCall(). Specifically, the verified count is one-based; whereas, the calls list is zero-based. Therefore, returning calls.get(verified) leads to inappropriate behavior (i.e., either accessing the wrong call or out-of-bounds exceptions).

Further analysis reveals that this off-by-one bug is in fact a regression that was accidentally introduced in the fix for #15513.


Deliverables

  1. Fix the off-by-one bug in AbstractMethodMockingControl.Expectations.nextCall().
  2. Ensure that all broken tests (currently annotated with @Ignore) in AnnotationDrivenStaticEntityMockingControlTests pass once again.

Affects: 3.2.5

Issue Links:

Referenced from: commits 3a89bc4, 03e243a, 69a89b1

Backported to: 3.2.8

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)in: testIssues in the test modulestatus: backportedAn issue that has been backported to maintenance branchestype: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions