I had an issue where System.currentTimeMillis() was a bad seed when a few tests were running in parallel. I want to be able to override the random to use nanoTime().

Comment From: pivotal-issuemaster

@jryan128 Please sign the Contributor License Agreement!

Click here to manually synchronize the status of this Pull Request.

See the FAQ for frequently asked questions.

Comment From: NielsUll

While I understand your problem, having mutable static state which affect behaviour of static methods is very dangerous from an architectural point of view.

Any code could call SocketUtils.setRandom(new FixedRandom(0.5)) and it could break the rest of the application in hard-to-find ways.

Comment From: sbrannen

Instead of making the Random instance configurable, we are rather considering instantiating it as follows.

private static final Random random = new Random(System.nanoTime());

Would that suit your needs?

Comment From: jryan128

Yes

On Thu, Jul 2, 2020, 08:17 Sam Brannen notifications@github.com wrote:

Instead of making the Random instance configurable, we are rather considering instantiating it as follows.

private static final Random random = new Random(System.nanoTime());

Would that suit your needs?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/spring-projects/spring-framework/pull/25321#issuecomment-652971197, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAE4JYX7UMTTIHSCYCTXTJ3RZR3EVANCNFSM4OJR4VIQ .

Comment From: sbrannen

Thanks for the PR.

As mentioned above, I implemented it slightly differently in 35582ded0e6619fa0d86fe1eb0182274456767b7 for 5.2.8 and 5.3 M2.

Comment From: jryan128

Thank you so much!!

On Fri, Jul 3, 2020 at 6:20 AM Sam Brannen notifications@github.com wrote:

Thanks for the PR.

As mentioned above, I implemented it slightly differently in 35582de https://github.com/spring-projects/spring-framework/commit/35582ded0e6619fa0d86fe1eb0182274456767b7 for 5.2.8 and 5.3 M2.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/spring-projects/spring-framework/pull/25321#issuecomment-653472040, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAE4JYSZ6LKDBBWKMVVD2GLRZWWFBANCNFSM4OJR4VIQ .