Skip to content

Commit

Permalink
Merge branch 'master' of github.com:rebnridgway/logstash-plugin into …
Browse files Browse the repository at this point in the history
…JENKINS-44712-pipeline-support
  • Loading branch information
Ted Bao committed Jun 8, 2017
2 parents 891fad6 + 9ce0c79 commit 795774f
Showing 1 changed file with 6 additions and 1 deletion.
Expand Up @@ -24,6 +24,8 @@

package jenkins.plugins.logstash.persistence;

import static com.google.common.collect.Ranges.closedOpen;

import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.exception.ExceptionUtils;
Expand All @@ -41,6 +43,8 @@
import java.net.URI;
import java.net.URISyntaxException;

import com.google.common.collect.Range;

/**
* Elastic Search Data Access Object.
*
Expand All @@ -51,6 +55,7 @@ public class ElasticSearchDao extends AbstractLogstashIndexerDao {
final HttpClientBuilder clientBuilder;
final URI uri;
final String auth;
final Range<Integer> successCodes = closedOpen(200,300);

//primary constructor used by indexer factory
public ElasticSearchDao(String host, int port, String key, String username, String password) {
Expand Down Expand Up @@ -109,7 +114,7 @@ public void push(String data) throws IOException {
httpClient = clientBuilder.build();
response = httpClient.execute(post);

if (response.getStatusLine().getStatusCode() != 201) {
if (!successCodes.contains(response.getStatusLine().getStatusCode())) {
throw new IOException(this.getErrorMessage(response));
}
} finally {
Expand Down

0 comments on commit 795774f

Please sign in to comment.