Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tika may "hang up" client application
Sometimes Tika may crash while parsing some files. In this case it may generate just runtime errors (Throwable), not TikaException. But there is no “catch” clause for Throwable in the AttachmentMapper.java : String parsedContent; try { // Set the maximum length of strings returned by the parseToString method, -1 sets no limit parsedContent = tika().parseToString(new FastByteArrayInputStream(content), metadata, indexedChars); } catch (TikaException e) { throw new MapperParsingException("Failed to extract [" + indexedChars + "] characters of text for [" + name + "]", e); } As a result, tika() may “hang up” the whole application. (we have some pdf-files that "hang up" Elastic client if you try to parse them using mapper-attahcment plugin) We propose the following fix: String parsedContent; try { // Set the maximum length of strings returned by the parseToString method, -1 sets no limit parsedContent = tika().parseToString(new FastByteArrayInputStream(content), metadata, indexedChars); } catch (Throwable e) { throw new MapperParsingException("Failed to extract [" + indexedChars + "] characters of text for [" + name + "]", e); } (just replace “TikaException” with “Throwable” – it works for our cases) Thank you! Closes elastic#21.
- Loading branch information