Prevent `ServiceHandler` from retaining excess `java.io.BufferedReader` instances (see #12049) (rebased onto dev_5_0)



This is the same as gh-2156 but rebased onto dev_5_0.

----

To test: simply re-index for search or (assuming that search is
currently working) add new file attachments to an existing image and
check that the contents of the file are still retrievable by search.