Description
When mustache expression requests an item with a non-existent index from a Collection
object, an IndexOutOfBoundsException
will be thrown which in turn results in template execution failure.
The mustache java library does not support indexing into Collection object. This feature is provided by a custom CustomReflectionObjectHandler
which wraps a Collection
object inside a specialised map of class CustomReflectionObjectHandler#CollectionMap
. The exception is thrown when checking whether the given index is available in the collection through the Map#containsKey
method, whose implementation is simply trying to retrieve the item at given index. Therefore when the index does not exist, an IndexOutOfBoundsException
will be thrown.
Mustache is in general very lenient of missing items. When an item does not exist, it will be simply rendered as empty string. Hence there are values to have a consistent behaviour for collection items. On the flipside, it is worth note that silently ignore all missing items could be a separate issue on its own.