smartystreets / smartystreets-java-sdk

The official client libraries for accessing SmartyStreets APIs from Java (and JRE-based languages)
https://smartystreets.com/docs/sdk/java
14 stars 18 forks source link

ClientBuilder doesn't pass along connection settings to OkHttpClient #46

Closed msaavedra-healthgorilla closed 8 months ago

msaavedra-healthgorilla commented 8 months ago

I tried doing this:

this.client = new ClientBuilder(new StaticCredentials(authId, authToken))
        .withLicenses(license.getLicenses())
        .withMaxTimeout(timeoutSeconds * 1000)
        .buildUsStreetApiClient();

and variations of this, but couldn't get it to work. Then I realized that your ClientBuilder.buildUsStreetApiClient() calls SmartySender(int maxTimeout) constructor.

The maxTimeout is ignored and this constructor should be something like this:

public SmartySender(int maxTimeout) {
    this.maxTimeOut = maxTimeout;
    this.client = new OkHttpClient.Builder()
                .writeTimeout(this.maxTimeOut, TimeUnit.MILLISECONDS)
                .readTimeout(this.maxTimeOut, TimeUnit.MILLISECONDS)
                .connectTimeout(this.maxTimeOut, TimeUnit.MILLISECONDS)
                .build();
}

Are you guys open to PRs from community?

RyanLCox1 commented 8 months ago

This is fixed now. SmartySender now takes into account the proper maxTimout with this code

SmartySender(int maxTimeOut) { this.maxTimeOut = maxTimeOut; this.client = new OkHttpClient.Builder() .writeTimeout(this.maxTimeOut, TimeUnit.MILLISECONDS) .readTimeout(this.maxTimeOut, TimeUnit.MILLISECONDS) .connectTimeout(this.maxTimeOut, TimeUnit.MILLISECONDS) .build(); }

I utilized your suggestions from your pull request! Thank you!