Claus Ibsen created CAMEL-27968:
-----------------------------------

             Summary: camel-dhis2: shared client never used, missing baseApiUrl 
gives a NullPointerException, non-String query values fail
                 Key: CAMEL-27968
                 URL: https://issues.apache.org/jira/browse/CAMEL-27968
             Project: Camel
          Issue Type: Bug
          Components: camel-dhis2
            Reporter: Claus Ibsen
             Fix For: 4.25.0


Found while improving the option descriptions of camel-dhis2 for CAMEL-23832 
(pull request https://github.com/apache/camel/pull/31200).
These are separate problems of the component; the descriptions change only 
documents the current behavior.

h4. 1. The shared client is never used
{{Dhis2Component}} has a field configuration that hides 
AbstractApiComponent.configuration; setConfiguration() calls super, so the 
field stays null, and getClient() compares 
endpointConfiguration.equals(this.configuration), which is always false. Every 
endpoint builds its own Dhis2Client and OkHttp connection pool.
Proposed change: drop the hiding field and the dead branch, or cache the 
clients by their settings.

h4. 2. Missing baseApiUrl gives a NullPointerException
{{Dhis2Component.getClient}}: with neither client nor baseApiUrl set, the 
Dhis2ClientBuilder constructor calls baseApiUrl.trim() and the endpoint fails 
with a NullPointerException.
Proposed change: check baseApiUrl and throw an IllegalArgumentException that 
names it.

h4. 3. Non-String query values fail
{{Dhis2Get}}, Dhis2Post, Dhis2Put and Dhis2Delete cast the queryParams values 
(and List elements) to String, so Map.of("pageSize", 10) fails with 
ClassCastException.
Proposed change: use String.valueOf(value).

h4. 4. Smaller issues
Dhis2ResourceTables.analytics() throws RuntimeCamelException on 
InterruptedException without restoring the interrupt flag, its wait loop has no 
upper bound, and (Boolean) notification.get("completed") throws a 
NullPointerException when a notification lacks the field. A path with a {..} 
segment fails with ArrayIndexOutOfBoundsException because no path params are 
passed. The apiName enum lists POST, RESOURCE_TABLES, ... while the URI uses 
post, resourceTables, ...


_Claude Code on behalf of davsclaus_



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to