Skip to content

Commit

Permalink
Merge pull request #846 from /issues/845-rest-client-timeout
Browse files Browse the repository at this point in the history
Fix #845: Missing timeout options for REST client
  • Loading branch information
banterCZ authored Jun 11, 2024
2 parents dd2d239 + 62f1c05 commit 70ebf43
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@

package io.getlime.push.client;

import com.fasterxml.jackson.databind.Module;
import com.wultra.core.rest.client.base.DefaultRestClient;
import com.wultra.core.rest.client.base.RestClient;
import com.wultra.core.rest.client.base.RestClientConfiguration;
import com.wultra.core.rest.client.base.RestClientException;
import io.getlime.core.rest.model.base.entity.Error;
import io.getlime.core.rest.model.base.request.ObjectRequest;
Expand Down Expand Up @@ -64,7 +66,22 @@ public PushServerClient(String serviceBaseUrl) throws PushServerClientException
try {
this.restClient = DefaultRestClient.builder().baseUrl(serviceBaseUrl).build();
} catch (RestClientException ex) {
throw new PushServerClientException("Rest client initialization failed, error: " + ex.getMessage());
throw new PushServerClientException("Rest client initialization failed, error: " + ex.getMessage(), ex);
}
}

/**
* Construct the push server client with the given configuration.
*
* @param config REST client configuration.
* @param modules Optional jackson modules.
* @throws PushServerClientException Thrown in case REST client initialization fails.
*/
public PushServerClient(final RestClientConfiguration config, final Module... modules) throws PushServerClientException {
try {
this.restClient = new DefaultRestClient(config, modules);
} catch (RestClientException ex) {
throw new PushServerClientException("Rest client initialization failed, error: " + ex.getMessage(), ex);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class PushServerClientException extends Exception {
/**
* Error object.
*/
private Error error;
private final Error error;

/**
* Constructor with message.
Expand Down Expand Up @@ -71,6 +71,16 @@ public PushServerClientException(String message, Throwable cause, Error error) {
this.error = error;
}

/**
* Constructor with message, cause and error object.
* @param message Message.
* @param cause Cause.
*/
public PushServerClientException(String message, Throwable cause) {
super(message, cause);
this.error = new PushServerClientError(message);
}

/**
* Constructor with cause and error object.
* @param cause Cause.
Expand All @@ -95,14 +105,6 @@ public PushServerClientException(String message, Throwable cause, boolean enable
this.error = error;
}

/**
* Set error object.
* @param error Error object.
*/
public void setError(Error error) {
this.error = error;
}

/**
* Get error object.
* @return Error object.
Expand Down

0 comments on commit 70ebf43

Please sign in to comment.