Throw IOException if negative int from port-based cli connection stream.

-Instead of failing at initializing array with negative size.
Introducing PowerMock test for the zero-size array case.
Negative-size case not tested thx to unhelping PowerMock behavior.
Using ConnectionMockTest instead of ConnectionTest; needed by PowerMock.
Merge branch 'fork_fix-nas-exception2' of github.com:marco-miller/jenkins into marco-miller-fork_fix-nas-exception2
[JENKINS-18058] Merged #1016 for better diagnosis.