]> source.dussan.org Git - jgit.git/commitdiff
PackInserterTest#newLargeBlob: Factor Random instance out to class member 09/115209/1
authorDavid Pursehouse <david.pursehouse@gmail.com>
Thu, 11 Jan 2018 05:22:09 +0000 (14:22 +0900)
committerDavid Pursehouse <david.pursehouse@gmail.com>
Thu, 11 Jan 2018 05:23:21 +0000 (14:23 +0900)
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>
org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/PackInserterTest.java

index b782ce87ff63ecc98eaed2cb6eb57a48703f2b6f..8e438bc0e042c0f13e523fc08c204dcafcf52a37 100644 (file)
@@ -95,6 +95,8 @@ import org.junit.Test;
 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 @@ public class PackInserterTest extends RepositoryTestCase {
 
        private static byte[] newLargeBlob() {
                byte[] blob = new byte[10240];
-               new Random(0).nextBytes(blob);
+               random.nextBytes(blob);
                return blob;
        }