Buggy code:
public class PathsTestCase extends AbstractControllerTestBase { PathManagerService pathManagerService ; @ Test public void testReadResourceDescription ( ) throws Exception { } @ Test public void testAddPath ( ) throws Exception { } @ Test public void testRemovePath ( ) throws Exception { } @ Test public void testChangeAbsolutePath ( ) throws Exception { } @ Test public void testChangeRelativePath ( ) throws Exception { } @ Test public void testChangeBetweenRelativeAndAbsolutePaths ( ) throws Exception { } @ Test public void testRemoveHardcodedPathFails ( ) throws Exception { } @ Test public void testChangeHardcodedPathFails ( ) throws Exception { } @ Test public void testLegacyPathServices ( ) throws Exception { } private void checkServiceAndPathEntry ( String name , String path , String relativeTo ) { } @ Test public void testPathManagerAddNotifications ( ) throws Exception { } @ Test public void testPathManagerRemoveNotifications ( ) throws Exception { } @ Test public void testPathManagerChangeNotifications ( ) throws Exception { } @ Test public void testCannotRemoveDependentService ( ) throws Exception { } @ Test public void testBadAdd ( ) throws Exception { } @ Test public void testBadChangeNoNotification ( ) throws Exception { } @ Test public void testChangeDependentServiceNotificationIsCascaded ( ) throws Exception { } private void checkPath ( ModelNode result , String pathName , String path , String relativeTo , boolean readOnly ) { } private ModelNode readResource ( ) throws Exception { } protected ModelNode createOperation ( String operationName , String ... address ) { } public ModelNode executeForResult ( ModelNode operation ) throws OperationFailedException { } public void executeForFailure ( ModelNode operation ) throws OperationFailedException { } @ Override protected DescriptionProvider getRootDescriptionProvider ( ) { } @ Override protected void initModel ( Resource rootResource , ManagementResourceRegistration registration ) { } private class TestServiceListener extends AbstractServiceListener < Object > { volatile CountDownLatch latch ; LinkedHashMap < Transition , ServiceName > services = new LinkedHashMap < ServiceController . Transition , ServiceName > ( ) ; void reset ( int count ) { <START_BUG> latch = new CountDownLatch ( 1 ) ; <END_BUG> services . clear ( ) ; } public void transition ( ServiceController < ? extends Object > controller , Transition transition ) { } } private static class ExpectedResultBuilder { LinkedHashMap < Transition , ServiceName > map = new LinkedHashMap < ServiceController . Transition , ServiceName > ( ) ; PathsTestCase . ExpectedResultBuilder addUp ( ServiceName name ) { } PathsTestCase . ExpectedResultBuilder addRemove ( ServiceName name ) { } } private static class PerformChangeCallback implements PathManager . Callback { private LinkedHashMap < Event , PathEntry > paths = new LinkedHashMap < PathManager . Event , PathEntry > ( ) ; private Handle handle ; PerformChangeCallback ( PathManager pathManager , String pathName , Event ... events ) { } void remove ( ) { } void clear ( ) { } @ Override public void pathEvent ( Event event , PathEntry pathEntry ) { } void checkEvent ( Event event , String name , String path , String relativeTo ) { } void checkDone ( ) { } @ Override public void pathModelEvent ( PathEventContext eventContext , String name ) { } } }

Fix:
latch = new CountDownLatch ( count ) ;