Skip to content

Commit

Permalink
issue-489: Update SearchScroll for large scroll_ids
Browse files Browse the repository at this point in the history
Refs Graylog2/graylog2-server#4190

(cherry picked from commit 2a34a76)
  • Loading branch information
weed101@gmail.com authored and Jochen Schalanda committed Oct 16, 2017
1 parent 8222d10 commit b90cd0d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ public class SearchScroll extends GenericResultAbstractAction {
static final int MAX_SCROLL_ID_LENGTH = 1900;
private final String restMethodName;


protected SearchScroll(Builder builder) {
super(builder);

if(builder.getScrollId().length() > MAX_SCROLL_ID_LENGTH) {
this.restMethodName = "POST";
this.payload = builder.getScrollId();
// represent scroll_id in json for request body
this.payload = "{\"scroll_id\":\"" + builder.getScrollId() + "\"}";
} else {
this.restMethodName = "GET";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.junit.Test;

import java.io.IOException;
import java.util.Collections;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
Expand All @@ -31,11 +32,13 @@ public void methodIsGetIfScrollIdIsShort() throws IOException {
public void methodIsPostIfScrollIdIsLong() throws IOException {
String scrollId = Strings.padStart("scrollId", 2000, 'x');

final String expectedResults = "{\"scroll_id\":\""+scrollId+"\"}";

Action searchScroll = new SearchScroll.Builder(scrollId, "1m").build();
String uri = searchScroll.getURI();

assertEquals("POST", searchScroll.getRestMethodName());
assertEquals(scrollId, searchScroll.getData(new ObjectMapper()));
assertEquals(expectedResults, searchScroll.getData(new ObjectMapper()));
assertTrue(uri.length() < 2000);
assertFalse(uri.contains(scrollId));
}
Expand Down

0 comments on commit b90cd0d

Please sign in to comment.