Skip to content

MockCookie parsing fails if cookie does not include attributes [SPR-17321] #21854

@spring-projects-issues

Description

@spring-projects-issues

Michael Bell opened SPR-17321 and commented

In brief, the MockServletRequest and MockServletResponse cannot handle a cookie of name=value . They require name=value; (optionalattribute). Without the semi-colon, MockCookie.parse(), introduced in Spring 5.1 RC2 throws an ArrayIndexOutOfBoundsException.

@Test(expected = ArrayIndexOutOfBoundsException.class)
public void springTestParsingBug() {
    // Demonstrates Spring can't handle this
    MockCookie.parse("a=1");
}

@Test
public void springTestParsingBugWorkaround() {
    // Demonstrates Spring test needs an attribute
    MockCookie.parse("a=1; HttpOnly");
}

@Test
public void springTestParsingBugWorkaround2() {
    // Demonstrates Spring test needs an attribute
    MockCookie.parse("a=1;");
}

Regression was introduced in the work discussed in #21647.

 


Affects: 5.1 GA

Issue Links:

Metadata

Metadata

Assignees

Labels

in: testIssues in the test moduletype: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions