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
Control whether MapperService docMapper iterator should contain DEFAULT_MAPPING #6793
Conversation
…n DEFAULT_MAPPING At the moment one can iterate the MapperService to go through all document mappers. This includes the document mapper of DEFAULT_MAPPING, which may be surprising and lead to unintended results. This commit removes the Iterable implementation and add a docMappers method that asks the caller to make an explicit choice
@Override | ||
public UnmodifiableIterator<DocumentMapper> iterator() { | ||
return Iterators.unmodifiableIterator(mappers.values().iterator()); | ||
public Iterable<DocumentMapper> docMappers(final boolean includingDefaultMapping) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe add some java doc? (emphasising that includingDefaultMapping should be false must of the time)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1. Will add.
LGTM, left one minor comment |
if (includingDefaultMapping) { | ||
iter = mappers.values().iterator(); | ||
} else { | ||
iter = Iterators.filter(mappers.values().iterator(), new Predicate<DocumentMapper>() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we have a static final inner class for this predicate? it seems static?
pushed another commit based on the feedback |
LGTM |
…n DEFAULT_MAPPING At the moment one can iterate the MapperService to go through all document mappers. This includes the document mapper of DEFAULT_MAPPING, which may be surprising and lead to unintended results. This commit removes the Iterable implementation and add a docMappers method that asks the caller to make an explicit choice Closes #6793
At the moment one can iterate the MapperService to go through all document mappers. This includes the document mapper of DEFAULT_MAPPING, which may be surprising and lead to unintended results. This commit removes the Iterable implementation and add a docMappers method that asks the caller to make an explicit choice