PackInserterTest#newLargeBlob: Factor Random instance out to class member

Instead of instantiating a new Random on each invocation of newLargeBlob,
create it once and reuse it.

This fixes a warning raised by Spotbugs about the Random object being
created and only used once.

Change-Id: I5b8e6ccbbc92641811537808aed9eae2034c1133
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
This commit is contained in:
David Pursehouse 2018-01-11 14:22:09 +09:00
parent dadbdcdcfc
commit 1842c70b8d
1 changed files with 3 additions and 1 deletions

View File

@ -95,6 +95,8 @@
public class PackInserterTest extends RepositoryTestCase {
private WindowCacheConfig origWindowCacheConfig;
private static final Random random = new Random(0);
@Before
public void setWindowCacheConfig() {
origWindowCacheConfig = new WindowCacheConfig();
@ -518,7 +520,7 @@ private PackInserter newInserter() {
private static byte[] newLargeBlob() {
byte[] blob = new byte[10240];
new Random(0).nextBytes(blob);
random.nextBytes(blob);
return blob;
}