Fix NPE when sending DatagramPacket

This is due to code after

  getImpl().connect(address, port);

is not executed if it throws exception, leaving DatagramPacket in an
inconsistant state.

Re-arrange the order of code so that the state is now consistent.

Bug: 31218085
Test: libcore.java.net.DatagramSocketTest
Change-Id: Iab9bfd9af211666564e49de62fdae964d6330daf
(cherry picked from commit 6764aa32a4b66a3c589f4a00615a1e36d87f308f)
CRs-Fixed: 1051067
2 files changed