SPARK-1676: (branch-0.9 fix) Cache Hadoop UGIs to prevent FileSystem leak

This is a followup patch to #607, which contains a discussion about the proper solution for this problem. This PR is pointed to branch-0.9 to provide a very low-impact fix that allows users to enable UGI caching if they run into this problem without affecting the default behavior.