finos / symphony-bdk-java

The Symphony BDK (Bot Developer Kit) for Java helps you to create production-grade Chat Bots and Extension Applications on top of the Symphony REST APIs.
https://symphony-bdk-java.finos.org
Apache License 2.0
23 stars 69 forks source link

HttpClient NPE bug when add queryparam #462

Closed symphony-hong closed 3 years ago

symphony-hong commented 3 years ago

Bug Report

When we try to add a query param to a HttpClient instance, a NPE will be thrown because the queryParams in RequestConfig was initialised with null and same for headers, cookies and formParams. Ref

Steps to Reproduce:

Reproduce with the unittest:

final HttpClient httpClient = HttpClient.builder(this::mockedApiClientBuilder)
      .basePath("https://localhost:8080")
      .header("Connection", "Keep-Alive")
      .header("Keep-Alive", "timeout=5, max=1000")
      .cookie("foo", "bar")
      .build();

httpClient.queryParam("test", "test");

Expected Result:

The query param is added successfully. Same for headers, cookies, formParams

Actual Result:

java.lang.NullPointerException
    at com.symphony.bdk.http.api.HttpClient$RequestConfig.appendQueryParam(HttpClient.java:394)
    at com.symphony.bdk.http.api.HttpClient.queryParam(HttpClient.java:182)
    at com.symphony.bdk.http.api.HttpClientTest.usage(HttpClientTest.java:22)

Environment:

symphony-bdk-2.1.0

thibauult commented 3 years ago

@symphony-hong PR created https://github.com/finos/symphony-bdk-java/pull/463

thibauult commented 3 years ago

Release 2.1.1 should be available soon in Maven Central.

symphony-youri commented 3 years ago

Do we need to merge into master too?

thibauult commented 3 years ago

Already backported onto main : https://github.com/finos/symphony-bdk-java/commit/723a4a778af046ae8482066817963a9a79345550