Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JAVA] need to expose getters / setters for readTimeout and writeTimeout values on the generated java clients #6852

Closed
normana400 opened this issue Oct 30, 2017 · 2 comments

Comments

@normana400
Copy link
Contributor

normana400 commented Oct 30, 2017

Description

this issue addresses a deficiency to the earlier enhancement: #1730.
Issue #1730 added the ability to set the OkHttpClient connectionTimeout for the java clients used; however, it didn't add a way to set the OkHttpClient readTimeout and writeTimeout values. By default, OkHttpClient sets all 3 values to a default of 10 seconds. A limit of 10 seconds for reads and writes is a low enough value that many usage scenarios will require the ability to set a larger value for these.

Swagger-codegen version

version 2.2.3 . It is not a regression issue.

Swagger declaration file content or url
Command line used for generation

no specific command line needed for this

Steps to reproduce

generate the java client.
attempt to set the readTimeout and writeTimeout for the ApiClient's internal OkHttpClient.
expected: there are setters to do these that resemble the setConnectTimeout method
actual: there are no setters in the ApiClient that expose these 2 timeout settings

Related issues/PRs

#1730

Suggest a fix/enhancement

the generated ApiClient class needs the following getter / setter pairs:

/**
 * Get read timeout (in milliseconds).
 *
 * @return Timeout in milliseconds
 */
public int getReadTimeout() {
    return httpClient.getReadTimeout();
}

/**
 * Sets the read timeout (in milliseconds).
 * A value of 0 means no timeout, otherwise values must be between 1 and
 * 
 * @param readTimeout connection timeout in milliseconds
 * @return Api client
 */
public ApiClient setReadTimeout(int readTimeout) {
    httpClient.setReadTimeout(readTimeout, TimeUnit.MILLISECONDS);
    return this;
}

/**
 * Get write timeout (in milliseconds).
 *
 * @return Timeout in milliseconds
 */
public int getWriteTimeout() {
    return httpClient.getWriteTimeout();
}

/**
 * Sets the write timeout (in milliseconds).
 * A value of 0 means no timeout, otherwise values must be between 1 and
 *
 * @param writeTimeout connection timeout in milliseconds
 * @return Api client
 */
public ApiClient setWriteTimeout(int writeTimeout) {
    httpClient.setWriteTimeout(writeTimeout, TimeUnit.MILLISECONDS);
    return this;
}
@normana400
Copy link
Contributor Author

created a PR for this:
#6853

@wing328
Copy link
Contributor

wing328 commented Nov 1, 2017

@normana400 thanks for the PR. We'll review and let you know if we've any question.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants