[SPARK-2532] Consolidated shuffle fixes

Status of the PR
- [X] Cherry pick and merge changes from internal branch to spark master
- [X] Remove WIP comments and 2G branch references.
- [X] Tests for BlockObjectWriter
- [x] Tests for ExternalAppendOnlyMap
- [x] Tests for ShuffleBlockManager



Alright, as long as you can confirm that it still happens without this. I just don't see how it could happen from the other code in there. I guess we can try disabling it after this fix goes in and see if things break.