Added hooks methods for connection and read timeouts override
This commit is contained in:
parent
e41a8f9c20
commit
edfe561608
|
@ -24,6 +24,8 @@ public abstract class AbstractHTTPWithJWTTokenAuthEventSender implements EventSe
|
|||
protected String clientId;
|
||||
protected String clientSecret;
|
||||
protected URL tokenURL;
|
||||
protected int connectionTimeout;
|
||||
protected int readTimeout;
|
||||
|
||||
public AbstractHTTPWithJWTTokenAuthEventSender(URL baseEndpointURL, String clientId, String clientSecret,
|
||||
URL tokenURL) {
|
||||
|
@ -33,6 +35,16 @@ public abstract class AbstractHTTPWithJWTTokenAuthEventSender implements EventSe
|
|||
this.clientId = clientId;
|
||||
this.clientSecret = clientSecret;
|
||||
this.tokenURL = tokenURL;
|
||||
connectionTimeout = getConnectionTimeout();
|
||||
readTimeout = getReadTimeout();
|
||||
}
|
||||
|
||||
protected int getReadTimeout() {
|
||||
return HTTPVerb.DEFAULT_READ_TIMEOUT;
|
||||
}
|
||||
|
||||
protected int getConnectionTimeout() {
|
||||
return HTTPVerb.DEFAULT_CONNECTION_TIMEOUT;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -69,8 +81,8 @@ public abstract class AbstractHTTPWithJWTTokenAuthEventSender implements EventSe
|
|||
|
||||
public abstract class HTTPVerb {
|
||||
|
||||
protected static final int CONNECTION_TIMEOUT = 10000;
|
||||
protected static final int READ_TIMEOUT = 5000;
|
||||
protected static final int DEFAULT_CONNECTION_TIMEOUT = 10000;
|
||||
protected static final int DEFAULT_READ_TIMEOUT = 5000;
|
||||
|
||||
protected URL baseEndpoint;
|
||||
|
||||
|
@ -118,9 +130,9 @@ public abstract class AbstractHTTPWithJWTTokenAuthEventSender implements EventSe
|
|||
log.debug("Performing HTTP POST to: {}", baseEndpoint);
|
||||
HttpURLConnection connection = (HttpURLConnection) eventEndpoint.openConnection();
|
||||
connection.setRequestMethod("POST");
|
||||
connection.setConnectTimeout(CONNECTION_TIMEOUT);
|
||||
connection.setConnectTimeout(connectionTimeout);
|
||||
log.trace("HTTP connection timeout set to: {}", connection.getConnectTimeout());
|
||||
connection.setReadTimeout(READ_TIMEOUT);
|
||||
connection.setReadTimeout(readTimeout);
|
||||
log.trace("HTTP connection Read timeout set to: {}", connection.getReadTimeout());
|
||||
connection.setRequestProperty("Content-Type", "application/json");
|
||||
// Commented out as per the Conductor issue: https://github.com/Netflix/conductor/issues/376
|
||||
|
@ -233,9 +245,9 @@ public abstract class AbstractHTTPWithJWTTokenAuthEventSender implements EventSe
|
|||
log.debug("Performing HTTP GET to: {}", endpoint);
|
||||
HttpURLConnection connection = (HttpURLConnection) endpoint.openConnection();
|
||||
connection.setRequestMethod("GET");
|
||||
connection.setConnectTimeout(CONNECTION_TIMEOUT);
|
||||
connection.setConnectTimeout(connectionTimeout);
|
||||
log.trace("HTTP connection timeout set to: {}", connection.getConnectTimeout());
|
||||
connection.setReadTimeout(READ_TIMEOUT);
|
||||
connection.setReadTimeout(readTimeout);
|
||||
log.trace("HTTP connection Read timeout set to: {}", connection.getReadTimeout());
|
||||
if (token != null) {
|
||||
log.debug("Setting authorization header as: {}", token.getAccessTokenAsBearer());
|
||||
|
|
Loading…
Reference in New Issue