### Question:
WeakReferenceUtil { static <T> void cleanNullReferences(final List<WeakReference<T>> weakReferences) { weakReferences.removeIf(weakReference -> weakReference.isEnqueued() || weakReference.get() == null); } private  WeakReferenceUtil();   }### Answer:
@Test void cleanNullReferences() throws InterruptedException { list.add(weak1); list.add(weak2); list.add(weak3); data2 = null; data3 = null; for (int i = 0; i < 50; i++) { System.gc(); Thread.sleep(50); System.gc(); } WeakReferenceUtil.cleanNullReferences(list); Assertions.assertEquals(1, list.size()); Assertions.assertEquals(weak1, list.get(0)); }