Search in sources :

Example 1 with ConfigParseException

use of com.optimizely.ab.config.parser.ConfigParseException in project java-sdk by optimizely.

the class HttpProjectConfigManager method poll.

@Override
protected ProjectConfig poll() {
    HttpGet httpGet = createHttpRequest();
    CloseableHttpResponse response = null;
    logger.debug("Fetching datafile from: {}", httpGet.getURI());
    try {
        response = httpClient.execute(httpGet);
        String datafile = getDatafileFromResponse(response);
        if (datafile == null) {
            return null;
        }
        return parseProjectConfig(datafile);
    } catch (ConfigParseException | IOException e) {
        logger.error("Error fetching datafile", e);
    } finally {
        if (response != null) {
            try {
                response.close();
            } catch (IOException e) {
                logger.warn(e.getLocalizedMessage());
            }
        }
    }
    return null;
}
Also used : ConfigParseException(com.optimizely.ab.config.parser.ConfigParseException) HttpGet(org.apache.http.client.methods.HttpGet) CloseableHttpResponse(org.apache.http.client.methods.CloseableHttpResponse) IOException(java.io.IOException)

Aggregations

ConfigParseException (com.optimizely.ab.config.parser.ConfigParseException)1 IOException (java.io.IOException)1 CloseableHttpResponse (org.apache.http.client.methods.CloseableHttpResponse)1 HttpGet (org.apache.http.client.methods.HttpGet)1