#vulnerable code 
                              @Override
  public void run() {

    try {
      init();
      Peer self = client.peersStorage.getSelf();
      logger.info("BitTorrent client [{}] started and " +
                      "listening at {}:{}...",
              new Object[]{
                      self.getShortHexPeerId(),
                      self.getIp(),
                      self.getPort()
              });
    } catch (IOException e) {
      LoggerUtils.warnAndDebugDetails(logger, "error in initialization server channel", e);
      return;
    }

    while (!Thread.interrupted()) {
      int selected = -1;
      try {
        selected = selector.select();// TODO: 11/13/17 timeout
      } catch (IOException e) {
        LoggerUtils.warnAndDebugDetails(logger, "unable to select channel keys", e);
      }
      logger.trace("select keys from selector. Keys count is " + selected);
      if (selected < 0) {
        logger.info("selected count less that zero");
      }
      if (selected == 0) {
        continue;
      }
      processSelectedKeys();
    }
    try {
      close();
    } catch (IOException e) {
      LoggerUtils.warnAndDebugDetails(logger, "unable to close connection receiver", e);
    }
  } 
                            #location 10 
                            #vulnerability type NULL_DEREFERENCE
#fixed code
                              @Override
  public void run() {

    try {
      init();
      Peer self = peersStorageFactory.getPeersStorage().getSelf();
      logger.info("BitTorrent client [{}] started and " +
                      "listening at {}:{}...",
              new Object[]{
                      self.getShortHexPeerId(),
                      self.getIp(),
                      self.getPort()
              });
    } catch (IOException e) {
      LoggerUtils.warnAndDebugDetails(logger, "error in initialization server channel", e);
      return;
    }

    while (!Thread.interrupted()) {
      int selected = -1;
      try {
        selected = selector.select();// TODO: 11/13/17 timeout
      } catch (IOException e) {
        LoggerUtils.warnAndDebugDetails(logger, "unable to select channel keys", e);
      }
      logger.trace("select keys from selector. Keys count is " + selected);
      if (selected < 0) {
        logger.info("selected count less that zero");
      }
      if (selected == 0) {
        continue;
      }
      processSelectedKeys();
    }
    try {
      close();
    } catch (IOException e) {
      LoggerUtils.warnAndDebugDetails(logger, "unable to close connection receiver", e);
    }
  }