Synchronize on lock in close() to avoid NPE from read()-close() race. Reviewed-by: alanb, dfuchs
Reviewed-by: darcy, weijun