For certain DH parameter values, a shorter secret is generated, i.e. the leading one or two bytes have value 0x00.
Thus, the regression test "com/sun/crypto/provider/KeyAgreement/DHKeyAgreement2.java" failed intermittently when such shorter secret is generated.
A slight modification to the above test program reveals the frequency of the failures as following:
Failure reproduced at 421
Failure reproduced at 241
Failure reproduced at 433
Failure reproduced at 85
Failure reproduced at 118
Failure reproduced at 184
Failure reproduced at 1418
Failure reproduced at 170
Anyway, a ShortBufferException is thrown when the failure is reproduced.