malformed elasticsearch.yml causes unresponsive hang

fixes #2693
This commit is contained in:
Shay Banon 2013-02-27 18:58:08 +01:00
parent f02c3ec39a
commit 3b2d403292
1 changed files with 4 additions and 0 deletions

View File

@ -19,6 +19,7 @@
package org.elasticsearch.common.settings.loader; package org.elasticsearch.common.settings.loader;
import org.elasticsearch.ElasticSearchParseException;
import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.common.xcontent.XContentType; import org.elasticsearch.common.xcontent.XContentType;
@ -66,6 +67,9 @@ public abstract class XContentSettingsLoader implements SettingsLoader {
if (token == null) { if (token == null) {
return settings; return settings;
} }
if (token != XContentParser.Token.START_OBJECT) {
throw new ElasticSearchParseException("malformed, expected settings to start with 'object', instead was [" + token + "]");
}
serializeObject(settings, sb, path, jp, null); serializeObject(settings, sb, path, jp, null);
return settings; return settings;
} }