Thanks for the patch, Rohith! This probably works for the HiveServer2 case iff the server never tries to use the filesystem after the timeline client is closed. However the timeline client is not just used by HS2, and I think this patch will be problematic for any code that could still use the filesystem after the timeline client is closed. Since the filesystem cache will implicitly link what looks like two separate creations of a filesystem to a single instance, closing one will break any subsequent use of the other.
This makes me think HS2 is missing a closeAllforUGI call in it somewhere to make sure when it's done for a certain user it cleans up all the filesystems associated with that user. It also makes me wonder why we haven't implemented a reference-counting cache for the filesystem by now.