@Test void noExceptionsStressTest() { List<Thread> ts = new ArrayList<>(); ts.add(new NewThread("EntityRepo1", 0, 10).getThread()); ts.add(new NewThread("EntityRepo1", 0, 10).getThread()); ts.add(new NewThread("EntityRepo2", 0, 10).getThread()); ts.add(new NewThread("EntityRepo2", 0, 10).getThread()); ts.forEach( t -> { try { t.join(); } catch (InterruptedException e) { throw new RuntimeException(e); } }); ts.forEach(t -> assertFalse(t.isAlive())); assertTrue(entityListenersService.isEmpty("EntityRepo1")); assertTrue(entityListenersService.isEmpty("EntityRepo2")); }
boolean isEmpty(String repoFullName) { lock.readLock().lock(); try { verifyRepoRegistered(repoFullName); return entityListenersByRepo.get(repoFullName).isEmpty(); } finally { lock.readLock().unlock(); } }
EntityListenersService { boolean isEmpty(String repoFullName) { lock.readLock().lock(); try { verifyRepoRegistered(repoFullName); return entityListenersByRepo.get(repoFullName).isEmpty(); } finally { lock.readLock().unlock(); } } }
EntityListenersService { boolean isEmpty(String repoFullName) { lock.readLock().lock(); try { verifyRepoRegistered(repoFullName); return entityListenersByRepo.get(repoFullName).isEmpty(); } finally { lock.readLock().unlock(); } }  }
EntityListenersService { boolean isEmpty(String repoFullName) { lock.readLock().lock(); try { verifyRepoRegistered(repoFullName); return entityListenersByRepo.get(repoFullName).isEmpty(); } finally { lock.readLock().unlock(); } }  void addEntityListener(String repoFullName, EntityListener entityListener); boolean removeEntityListener(String repoFullName, EntityListener entityListener); }
EntityListenersService { boolean isEmpty(String repoFullName) { lock.readLock().lock(); try { verifyRepoRegistered(repoFullName); return entityListenersByRepo.get(repoFullName).isEmpty(); } finally { lock.readLock().unlock(); } }  void addEntityListener(String repoFullName, EntityListener entityListener); boolean removeEntityListener(String repoFullName, EntityListener entityListener);  }