Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
This repository was archived by the owner on Feb 26, 2023. It is now read-only.
This repository was archived by the owner on Feb 26, 2023. It is now read-only.

NPE when @SetsCookie is used but cookie was *not* set by the server #855

Copy link
Copy link
@kutsal

Description

@kutsal
Issue body actions

Tested this on version 3.0.

Given an interface like this:

@Rest(converters = { StringHttpMessageConverter.class, FormHttpMessageConverter.class })
public interface MyCoolRestInterface {
    @Post("/very/cool?foo={bar}")
    @SetsCookie({ "YUMMY" })
    @Accept(MediaType.APPLICATION_FORM_URLENCODED_VALUE)
    String veryCool(MultiValueMap<String, String> params, boolean bar);

    @Get("needs/cookie")
    @RequiresCookie("YUMMY")
    String needsCookie();
}

When the response comes back from the server and YUMMY _is not_ set, we get an NPE at the for loop in the generated code (see RIGHT HERE below):

@Override
public String veryCool(MultiValueMap<String, String> params, boolean bar) {
    ...
    String[] requestedCookies = new String[] {"YUMMY"};
    List<String> allCookies = response.getHeaders().get("Set-Cookie");
    *** RIGHT HERE *** > for (String rawCookie: allCookies) {
        ...
}

because _Set-Cookie_ header is not present, and allCookies is null. Well, at least in my case it is. This should be better guarded by a null check of the list returned by the get() call.

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.