Skip to content

Commit 45b0ac3

Browse files
author
Richard Jones
committed
Add additional unit tests to show that singletons can be created in single thread environment and multithread environment. Also add a test to demonstrate a whole with Singleton when instantiating using reflection
Add some logging. Tests pass locally but not on github?
1 parent 6ba7f5e commit 45b0ac3

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

singleton/src/test/java/com/iluwatar/singleton/LazyLoadedSingletonThreadSafetyTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ public void test_MultipleCallsReturnTheSameObjectInDifferentThreads() throws Int
7575
@SuppressWarnings("unchecked")
7676
public void test_HoleInSingletonCreationIfUsingReflection() throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
7777
Field[] f = ThreadSafeLazyLoadedIvoryTower.class.getDeclaredFields();
78+
for (Field ff : f) {
79+
System.out.println(ff.getDeclaringClass());
80+
}
7881
assertEquals("One field only in ThreadSafeLazyLoadedIvoryTower", 1, f.length);
7982
f[0].setAccessible(true);
8083

0 commit comments

Comments
 (0)