Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
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