Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullPointerException in HeaderUtils.getPreferredCookie #4773

Closed
chilloutman opened this issue Apr 19, 2021 · 0 comments
Closed

NullPointerException in HeaderUtils.getPreferredCookie #4773

chilloutman opened this issue Apr 19, 2021 · 0 comments
Milestone

Comments

@chilloutman
Copy link

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();
	}
}
tvallin added a commit to tvallin/jersey that referenced this issue May 12, 2021
jansupol pushed a commit that referenced this issue Jun 14, 2021
@jansupol jansupol added this to the 2.35 milestone Jun 17, 2021
This was referenced Sep 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants