Xero - beautiful accounting software

Xero Developer Help Center

Xero Developer Community

Community > Wrapper libraries >

Xero-Java 3.1.8 "HTTPS hostname wrong" exception after 5 second delay between API calls

Started by James Dean -   in Wrapper libraries

I have implemented the Xero-Java SDK 3.1.8, specifically the OAuth2.0 implementation, into an ongoing project. I was able to authorise and receive access and refresh tokens, and access the Xero Accounting API.

However, if I hit the Accounting API for example and receive a result, wait 5 seconds or more, then hit it again, I receive the exception:
java.io.IOException: HTTPS hostname wrong: should be <api.xero.com>

If I do it in less than 5 seconds, it works every time without exceptions.

I am initiating the Accounting API in the following manner:
ApiClient apiClient = new ApiClient(null, null, null, null, null);
AccountingApi accountingApi = AccountingApi.getInstance(apiClient);

An example Accounting API call looks like the following:
Contacts contacts = accountingApi.getContacts(theAccessToken, theTenantId, null, null, null, null, null, null);

As you can see I'm not overriding any defaults with the hostname settings so they shouldn't change from call to call. Is there something else I'm missing here?
For anyone who is experiencing a similar problem, the issue turned out to be a JDK bug, specifically the AdoptOpenJDK's jdk-11.0.2+9. Moving to a newer version on our deployment server solved the issue.
 

James Dean