updated implementation of SandboxConnection to be compliant with java 6 and 7
(cherry picked from commit 3acb03f)