Skip to content

NullPointerException in HeaderUtils.getPreferredCookie #4773

@chilloutman

Description

@chilloutman

Introduced in: #4390 (which addressed #3433)

Cookie paths can be null. This is not handled in HeaderUtils.java:326, which causes a NullPointerException to be thrown.

return first.getPath().length() > second.getPath().length() ? first : second;

The problem occurs when the client receives something like the following, where it did not in versions prior to #4390 being implemented.

Set-Cookie: A=B,A=C
public static void main (String[] args) {
	var a = new NewCookie("NAME", "VALUE");
	var b = new NewCookie("NAME", "VALUE");
	try {
		HeaderUtils.getPreferredCookie(a, b);
	} catch (NullPointerException e) {
		e.printStackTrace();
	}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions