Skip to content

Conversation

@Krisoblucki-okta
Copy link

@Krisoblucki-okta Krisoblucki-okta commented Dec 20, 2018

Currently there is no way to configure the connection timeouts to custom values as they are hard coded. This change allows connection timeouts to be configured.

@Krisoblucki-okta
Copy link
Author

Krisoblucki-okta commented Dec 20, 2018

@deepak2016 @rgrebski

Could you guys take a look at this and see if it makes sense.

@Krisoblucki-okta Krisoblucki-okta force-pushed the configurable-timeout-in-url-connect branch 2 times, most recently from 1aea835 to 9a1d3e9 Compare December 20, 2018 19:47
.gitignore Outdated
.idea

# Output
/out
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert changes to this file.

/**
* Default connection read timeout
*/
private static final int DEFAULT_READ_TIMEOUT_MS = 30_000;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove final, by keeping it final it can never be changed and the value will be always 30 _000.

/**
* Default connect timeout
*/
private static final int DEFAULT_CONNECT_TIMEOUT_MS = 30_000;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove final, by keeping it final it can never be changed and the value will be always 30 _000.

public int getConnectTimeout() {
return DEFAULT_CONNECT_TIMEOUT_MS;
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Provide setter for DEFAULT_CONNECT_TIMEOUT_MS.

@Override
public int getReadTimeout() {
return DEFAULT_READ_TIMEOUT_MS;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Provide setter for DEFAULT_READ_TIMEOUT_MS.

* @return the timeout in milliseconds
*/
int getReadTimeout();
} No newline at end of file
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Provide void setReadTimeout(); so that change of DEFAULT_READ_TIMEOUT_MS is possible.

/**
* The connection config
*/
private final IConnectionConfig connectionConfig;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove final from here, so that any class implementing IConnectionConfig can be used rather depending on fixed DefaultConnectionConfig.

* The connection config
*/
private final IConnectionConfig connectionConfig;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Provide getter and setter for connectionConfig in DefaultHttpProvider and IHttpProvider.

final IExecutors executors,
final ILogger logger,
final IConnectionConfig connectionConfig
) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding a new constructor is not required.

final URL requestUrl = request.getRequestUrl();
logger.logDebug("Starting to send request, URL " + requestUrl.toString());
final IConnection connection = connectionFactory.createFromRequest(request);
connection.setConnectTimeout(connectionConfig.getConnectTimeout());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use this

if(this.connectionConfig == null) {
         this.connectionConfig = new DefaultConnectionConfig();
}

So, that default values are only used when config is null.

This connection.setConnectTimeout(connectionConfig.getConnectTimeout()); is fine.

logger.logDebug("Starting to send request, URL " + requestUrl.toString());
final IConnection connection = connectionFactory.createFromRequest(request);
connection.setConnectTimeout(connectionConfig.getConnectTimeout());
connection.setReadTimeout(connectionConfig.getReadTimeout());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine.

@NakulSabharwal
Copy link
Contributor

Hi, DefaultConnectionConfig will contain the values of timeout which can be changed using set and get. This config will be passed using getter and setter in DefaultHttpProvider to change value of IConnectionConfig connectionConfig. Timeout and connectionConfig cannot be made final as they can be changed.
The intended usage will be -
graphClient.getHttpProvider().setConnectionConfig(any class implementing IConnectionConfig);

@deepak2016
Copy link
Contributor

We have fixed the issue using PR: #216
Closing this PR.

@deepak2016 deepak2016 closed this Feb 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants