Skip to content

Commit 64e3e1a

Browse files
author
Richard Jones
committed
For some reason it thinks there are two fields in the CI build. Making this more generic
1 parent 31e2940 commit 64e3e1a

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

lazy-loading/src/test/java/com/iluwatar/lazy/loading/HolderThreadSafeTest.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
import java.lang.reflect.Field;
66

7-
import static org.junit.Assert.assertEquals;
87
import static org.junit.Assert.assertNotNull;
98
import static org.junit.Assert.assertNull;
109

@@ -20,22 +19,24 @@ public void test() throws IllegalAccessException {
2019
HolderThreadSafe hts = new HolderThreadSafe();
2120

2221
{//first call is null
23-
Field[] f = HolderThreadSafe.class.getDeclaredFields();
24-
assertEquals("One field only in HolderThreadSafe", 1, f.length);
25-
f[0].setAccessible(true);
22+
Field[] ff = HolderThreadSafe.class.getDeclaredFields();
23+
for (Field f: ff) {
24+
f.setAccessible(true);
25+
}
2626

27-
assertNull(f[0].get(hts));
27+
assertNull(ff[0].get(hts));
2828
}
2929

3030
// now it is lazily loaded
3131
hts.getHeavy();
3232

3333
{//now it is not null - call via reflection so that the test is the same before and after
34-
Field[] f = HolderThreadSafe.class.getDeclaredFields();
35-
assertEquals("One field only in HolderThreadSafe", 1, f.length);
36-
f[0].setAccessible(true);
34+
Field[] ff = HolderThreadSafe.class.getDeclaredFields();
35+
for (Field f: ff) {
36+
f.setAccessible(true);
37+
}
3738

38-
assertNotNull(f[0].get(hts));
39+
assertNotNull(ff[0].get(hts));
3940
}
4041
}
4142
}

0 commit comments

Comments
 (0)