#vulnerable code 
                              private void assertDockerReachable(final int probePort) throws Exception {
    final DockerClient docker = new DefaultDockerClient(DOCKER_HOST.uri());

    try {
      docker.inspectImage(BUSYBOX);
    } catch (ImageNotFoundException e) {
      docker.pull(BUSYBOX);
    }

    final ContainerConfig config = ContainerConfig.builder()
        .image(BUSYBOX)
        .cmd("nc", "-p", "4711", "-lle", "cat")
        .exposedPorts(ImmutableSet.of("4711/tcp"))
        .build();
    final HostConfig hostConfig = HostConfig.builder()
        .portBindings(ImmutableMap.of("4711/tcp",
                                      asList(PortBinding.of("0.0.0.0", probePort))))
        .build();
    final ContainerCreation creation = docker.createContainer(config, testTag + "-probe");
    final String containerId = creation.id();
    docker.startContainer(containerId, hostConfig);

    // Wait for container to come up
    Polling.await(5, SECONDS, new Callable<Object>() {
      @Override
      public Object call() throws Exception {
        final ContainerInfo info = docker.inspectContainer(containerId);
        return info.state().running() ? true : null;
      }
    });

    log.info("Verifying that docker containers are reachable");
    try {
      Polling.awaitUnchecked(5, SECONDS, new Callable<Object>() {
        @Override
        public Object call() throws Exception {
          log.info("Probing: {}:{}", DOCKER_HOST.address(), probePort);
          try (final Socket ignored = new Socket(DOCKER_HOST.address(), probePort)) {
            return true;
          } catch (IOException e) {
            return false;
          }
        }
      });
    } catch (TimeoutException e) {
      fail("Please ensure that DOCKER_HOST is set to an address that where containers can " +
           "be reached. If docker is running in a local VM, DOCKER_HOST must be set to the " +
           "address of that VM. If docker can only be reached on a limited port range, " +
           "set the environment variable DOCKER_PORT_RANGE=start:end");
    }

    docker.killContainer(containerId);
  } 
                            #location 52 
                            #vulnerability type RESOURCE_LEAK
#fixed code
                              private void assertDockerReachable(final int probePort) throws Exception {
    try (final DefaultDockerClient docker = new DefaultDockerClient(DOCKER_HOST.uri())) {
      try {
        docker.inspectImage(BUSYBOX);
      } catch (ImageNotFoundException e) {
        docker.pull(BUSYBOX);
      }

      final ContainerConfig config = ContainerConfig.builder()
          .image(BUSYBOX)
          .cmd("nc", "-p", "4711", "-lle", "cat")
          .exposedPorts(ImmutableSet.of("4711/tcp"))
          .build();
      final HostConfig hostConfig = HostConfig.builder()
          .portBindings(ImmutableMap.of("4711/tcp",
                                        asList(PortBinding.of("0.0.0.0", probePort))))
          .build();
      final ContainerCreation creation = docker.createContainer(config, testTag + "-probe");
      final String containerId = creation.id();
      docker.startContainer(containerId, hostConfig);

      // Wait for container to come up
      Polling.await(5, SECONDS, new Callable<Object>() {
        @Override
        public Object call() throws Exception {
          final ContainerInfo info = docker.inspectContainer(containerId);
          return info.state().running() ? true : null;
        }
      });

      log.info("Verifying that docker containers are reachable");
      try {
        Polling.awaitUnchecked(5, SECONDS, new Callable<Object>() {
          @Override
          public Object call() throws Exception {
            log.info("Probing: {}:{}", DOCKER_HOST.address(), probePort);
            try (final Socket ignored = new Socket(DOCKER_HOST.address(), probePort)) {
              return true;
            } catch (IOException e) {
              return false;
            }
          }
        });
      } catch (TimeoutException e) {
        fail("Please ensure that DOCKER_HOST is set to an address that where containers can " +
             "be reached. If docker is running in a local VM, DOCKER_HOST must be set to the " +
             "address of that VM. If docker can only be reached on a limited port range, " +
             "set the environment variable DOCKER_PORT_RANGE=start:end");
      }

      docker.killContainer(containerId);
    }
  }