[GEOS-5651] Uploading smaller freemarker template file leads to invalid file on server, and also make sure all file based resources (including the random access file) are properly closed no matter what might happen during the upload
Merge branch 'master' of git://github.com/geoserver/geoserver