don't allow an empty type in the mapper service

This commit is contained in:
Shay Banon 2012-08-13 12:42:11 +02:00
parent bdea0e2edd
commit ad0e916fb7

View File

@ -191,6 +191,9 @@ public class MapperService extends AbstractIndexComponent implements Iterable<Do
// instances of field mappers to properly remove existing doc mapper // instances of field mappers to properly remove existing doc mapper
private void add(DocumentMapper mapper) { private void add(DocumentMapper mapper) {
synchronized (mutex) { synchronized (mutex) {
if (mapper.type().length() == 0) {
throw new InvalidTypeNameException("mapping type name is empty");
}
if (mapper.type().charAt(0) == '_') { if (mapper.type().charAt(0) == '_') {
throw new InvalidTypeNameException("mapping type name [" + mapper.type() + "] can't start with '_'"); throw new InvalidTypeNameException("mapping type name [" + mapper.type() + "] can't start with '_'");
} }