Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ArrayIndexOutOfBoundsException when using empty preference parameter #3591

Closed
lmenezes opened this Issue Aug 28, 2013 · 1 comment

Comments

Projects
None yet
2 participants
@lmenezes
Copy link
Contributor

lmenezes commented Aug 28, 2013

to reproduce(tested on 0.90.3):

curl -XGET http://localhost:9200/_search?preference=

this returns:

{
error: "StringIndexOutOfBoundsException[String index out of range: 0]",
status: 500
}

I'm not really sure what is the desired behavior in this case, because it could be one of:
1 - ignore the parameter and treat as if nothing was sent
2 - treat the empty string as the preference parameter
3 - return a friendly error message for it

anyway, the error happens here (https://github.com/elasticsearch/elasticsearch/blob/master/src/main/java/org/elasticsearch/cluster/routing/operation/plain/PlainOperationRouting.java#L172)
and it could be easily fixed by either making a check for an empty string before comparing its first character, or changing this line https://github.com/elasticsearch/elasticsearch/blob/master/src/main/java/org/elasticsearch/cluster/routing/operation/plain/PlainOperationRouting.java#L164 for something like preference.isEmpty(), which also covers the empty string case.

@ghost ghost assigned s1monw Aug 28, 2013

@s1monw s1monw closed this in 82397c0 Aug 28, 2013

s1monw added a commit that referenced this issue Aug 28, 2013

Treat empty prefrence as a `not set` in Plain Operation Routing
An empty preference was causing a AIOOB exception in
PlainOperationRouting. We now check for `null` or `empty` instead of
just `null`

Closes #3591
@s1monw

This comment has been minimized.

Copy link
Contributor

s1monw commented Aug 28, 2013

thanks for reporting

mute pushed a commit to mute/elasticsearch that referenced this issue Jul 29, 2015

Treat empty prefrence as a `not set` in Plain Operation Routing
An empty preference was causing a AIOOB exception in
PlainOperationRouting. We now check for `null` or `empty` instead of
just `null`

Closes elastic#3591
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.