Program: 47252
Project: 47252
Buggy source:
public void addChild(DLNAResource child,boolean isNew){
  if (child == null) {
    LOGGER.error("String_Node_Str",getName());
    LOGGER.debug("String_Node_Str",new NullPointerException("String_Node_Str"));
    return;
  }
  child.setParent(this);
  child.setMasterParent(getMasterParent());
  if (getParent() != null) {
    setDefaultRenderer(getParent().getDefaultRenderer());
  }
  if (PMS.filter(getDefaultRenderer(),child)) {
    LOGGER.debug("String_Node_Str" + child.getName() + "String_Node_Str"+ getDefaultRenderer().getRendererName());
    return;
  }
  try {
    if (child.isValid()) {
      LOGGER.trace("String_Node_Str",isNew ? "String_Node_Str" : "String_Node_Str",child.getName(),child.getClass().getName());
      if (allChildrenAreFolders && !child.isFolder()) {
        allChildrenAreFolders=false;
      }
      child.resHash=Math.abs(child.getSystemName().hashCode() + resumeHash());
      DLNAResource resumeRes=null;
      boolean addResumeFile=false;
      ResumeObj r=ResumeObj.create(child);
      if (r != null) {
        resumeRes=child.clone();
        resumeRes.resume=r;
        resumeRes.resHash=child.resHash;
        addResumeFile=true;
      }
      boolean parserV2=child.getMedia() != null && getDefaultRenderer() != null && getDefaultRenderer().isMediaParserV2();
      if (parserV2) {
        String mimeType=getDefaultRenderer().getFormatConfiguration().match(child.getMedia());
        if (mimeType != null) {
          if (!FormatConfiguration.MIMETYPE_AUTO.equals(mimeType)) {
            LOGGER.trace("String_Node_Str",child.getMedia().getMimeType(),child.getName(),mimeType);
            child.getMedia().setMimeType(mimeType);
          }
          LOGGER.trace("String_Node_Str",child.getName(),child.getMedia().getMimeType());
        }
 else {
          LOGGER.trace("String_Node_Str",child.getName());
        }
      }
      if (child.getFormat() != null) {
        String configurationSkipExtensions=configuration.getDisableTranscodeForExtensions();
        String rendererSkipExtensions=null;
        if (getDefaultRenderer() != null) {
          rendererSkipExtensions=getDefaultRenderer().getStreamedExtensions();
        }
        boolean skip=child.getFormat().skip(configurationSkipExtensions,rendererSkipExtensions);
        setSkipTranscode(skip);
        if (skip) {
          LOGGER.trace("String_Node_Str",child.getName());
        }
        if (child.getFormat().transcodable() || child.getMedia() != null) {
          if (child.getMedia() == null) {
            child.setMedia(new DLNAMediaInfo());
          }
          Player player=null;
          String name=getName();
          if (!configuration.isHideRecentlyPlayedFolder(null)) {
            player=child.getPlayer();
          }
 else {
            for (            Player p : PlayerFactory.getPlayers()) {
              String end="String_Node_Str" + p.id() + "String_Node_Str";
              if (name.endsWith(end)) {
                nametruncate=name.lastIndexOf(end);
                player=p;
                LOGGER.trace("String_Node_Str");
                break;
              }
 else               if (getParent() != null && getParent().getName().endsWith(end)) {
                getParent().nametruncate=getParent().getName().lastIndexOf(end);
                player=p;
                LOGGER.trace("String_Node_Str");
                break;
              }
            }
          }
          if (player == null) {
            player=PlayerFactory.getPlayer(child);
          }
          if (player != null && !allChildrenAreFolders) {
            String configurationForceExtensions=configuration.getForceTranscodeForExtensions();
            String rendererForceExtensions=null;
            if (getDefaultRenderer() != null) {
              rendererForceExtensions=getDefaultRenderer().getTranscodedExtensions();
            }
            boolean forceTranscode=child.getFormat().skip(configurationForceExtensions,rendererForceExtensions);
            if (forceTranscode) {
              LOGGER.trace("String_Node_Str",child.getName());
            }
            boolean hasEmbeddedSubs=false;
            if (child.getMedia() != null) {
              for (              DLNAMediaSubtitle s : child.getMedia().getSubtitleTracksList()) {
                hasEmbeddedSubs=(hasEmbeddedSubs || s.isEmbedded());
              }
            }
            boolean hasSubsToTranscode=false;
            if (!configuration.isDisableSubtitles()) {
              if (child.isSubsFile()) {
                hasSubsToTranscode=getDefaultRenderer() != null && StringUtils.isBlank(getDefaultRenderer().getSupportedSubtitles());
              }
 else {
                hasSubsToTranscode=hasEmbeddedSubs;
              }
              if (hasSubsToTranscode) {
                LOGGER.trace("String_Node_Str",child.getName());
              }
            }
            boolean isIncompatible=false;
            String audioTracksList=child.getName() + child.getMedia().getAudioTracksList().toString();
            if (!child.getFormat().isCompatible(child.getMedia(),getDefaultRenderer())) {
              isIncompatible=true;
              LOGGER.trace("String_Node_Str",child.getName());
            }
 else             if (configuration.isEncodedAudioPassthrough() && (audioTracksList.contains("String_Node_Str") || audioTracksList.contains("String_Node_Str"))) {
              isIncompatible=true;
              LOGGER.trace("String_Node_Str",child.getName());
            }
            boolean preferTranscode=isIncompatible || hasSubsToTranscode;
            if (forceTranscode || (preferTranscode && !isSkipTranscode())) {
              child.setPlayer(player);
              if (resumeRes != null) {
                resumeRes.setPlayer(player);
              }
              if (parserV2) {
                LOGGER.trace("String_Node_Str",child.getName(),player.toString(),child.getMedia().getMimeType());
              }
 else {
                LOGGER.trace("String_Node_Str",child.getName(),player.toString());
              }
            }
 else {
              LOGGER.trace("String_Node_Str",child.getName());
            }
            if ((child.getFormat().isVideo() || child.getFormat().isAudio()) && child.isTranscodeFolderAvailable()) {
              VirtualFolder transcodeFolder=getTranscodeFolder(true);
              if (transcodeFolder != null) {
                VirtualFolder fileTranscodeFolder=new FileTranscodeVirtualFolder(child.getDisplayName(),null);
                DLNAResource newChild=child.clone();
                newChild.setPlayer(player);
                newChild.setMedia(child.getMedia());
                fileTranscodeFolder.addChildInternal(newChild);
                LOGGER.trace("String_Node_Str",child.getName(),player.toString());
                transcodeFolder.updateChild(fileTranscodeFolder);
              }
            }
            if (child.getFormat().isVideo() && child.isSubSelectable() && !(this instanceof SubSelFile)) {
              VirtualFolder vf=getSubSelector(true);
              if (vf != null) {
                DLNAResource newChild=child.clone();
                newChild.setPlayer(player);
                newChild.setMedia(child.getMedia());
                LOGGER.trace("String_Node_Str" + child.getName() + "String_Node_Str"+ player.toString());
                vf.addChild(new SubSelFile(newChild));
              }
            }
            for (            ExternalListener listener : ExternalFactory.getExternalListeners()) {
              if (listener instanceof AdditionalResourceFolderListener) {
                try {
                  ((AdditionalResourceFolderListener)listener).addAdditionalFolder(this,child);
                }
 catch (                Throwable t) {
                  LOGGER.error("String_Node_Str",listener.getClass(),t);
                }
              }
            }
          }
 else           if (!child.getFormat().isCompatible(child.getMedia(),getDefaultRenderer()) && !child.isFolder()) {
            LOGGER.trace("String_Node_Str",child.getName(),getDefaultRenderer().getRendererName());
            getChildren().remove(child);
          }
        }
        if (resumeRes != null) {
          resumeRes.setMedia(child.getMedia());
        }
        if (child.getFormat().getSecondaryFormat() != null && child.getMedia() != null && getDefaultRenderer() != null && getDefaultRenderer().supportsFormat(child.getFormat().getSecondaryFormat())) {
          DLNAResource newChild=child.clone();
          newChild.setFormat(newChild.getFormat().getSecondaryFormat());
          LOGGER.trace("String_Node_Str",newChild.getFormat().toString(),newChild.getName());
          newChild.first=child;
          child.second=newChild;
          if (!newChild.getFormat().isCompatible(newChild.getMedia(),getDefaultRenderer())) {
            Player player=PlayerFactory.getPlayer(newChild);
            newChild.setPlayer(player);
            LOGGER.trace("String_Node_Str",newChild.getFormat().toString(),child.getPlayer().name(),newChild.getName());
          }
          if (child.getMedia() != null && child.getMedia().isSecondaryFormatValid()) {
            addChild(newChild);
            LOGGER.trace("String_Node_Str",newChild.getFormat().toString(),newChild.getName());
          }
 else {
            LOGGER.trace("String_Node_Str",newChild.getFormat().toString(),newChild.getName());
          }
        }
      }
      if (addResumeFile) {
        addChildInternal(resumeRes);
      }
      if (isNew) {
        addChildInternal(child);
      }
    }
  }
 catch (  Throwable t) {
    LOGGER.error("String_Node_Str",child.getName(),t);
    child.setParent(null);
    getChildren().remove(child);
  }
}

Fixed version (ground truth):
public void addChild(DLNAResource child,boolean isNew){
  if (child == null) {
    LOGGER.error("String_Node_Str",getName());
    LOGGER.debug("String_Node_Str",new NullPointerException("String_Node_Str"));
    return;
  }
  child.setParent(this);
  child.setMasterParent(getMasterParent());
  if (getParent() != null) {
    setDefaultRenderer(getParent().getDefaultRenderer());
  }
  if (PMS.filter(getDefaultRenderer(),child)) {
    LOGGER.debug("String_Node_Str" + child.getName() + "String_Node_Str"+ getDefaultRenderer().getRendererName());
    return;
  }
  try {
    if (child.isValid()) {
      LOGGER.trace("String_Node_Str",isNew ? "String_Node_Str" : "String_Node_Str",child.getName(),child.getClass().getName());
      if (allChildrenAreFolders && !child.isFolder()) {
        allChildrenAreFolders=false;
      }
      child.resHash=Math.abs(child.getSystemName().hashCode() + resumeHash());
      DLNAResource resumeRes=null;
      boolean addResumeFile=false;
      ResumeObj r=ResumeObj.create(child);
      if (r != null) {
        resumeRes=child.clone();
        resumeRes.resume=r;
        resumeRes.resHash=child.resHash;
        addResumeFile=true;
      }
      boolean parserV2=child.getMedia() != null && getDefaultRenderer() != null && getDefaultRenderer().isMediaParserV2();
      if (parserV2) {
        String mimeType=getDefaultRenderer().getFormatConfiguration().match(child.getMedia());
        if (mimeType != null) {
          if (!FormatConfiguration.MIMETYPE_AUTO.equals(mimeType)) {
            LOGGER.trace("String_Node_Str",child.getMedia().getMimeType(),child.getName(),mimeType);
            child.getMedia().setMimeType(mimeType);
          }
          LOGGER.trace("String_Node_Str",child.getName(),child.getMedia().getMimeType());
        }
 else {
          LOGGER.trace("String_Node_Str",child.getName());
        }
      }
      if (child.getFormat() != null) {
        String configurationSkipExtensions=configuration.getDisableTranscodeForExtensions();
        String rendererSkipExtensions=null;
        if (getDefaultRenderer() != null) {
          rendererSkipExtensions=getDefaultRenderer().getStreamedExtensions();
        }
        boolean skip=child.getFormat().skip(configurationSkipExtensions,rendererSkipExtensions);
        setSkipTranscode(skip);
        if (skip) {
          LOGGER.trace("String_Node_Str",child.getName());
        }
        if (child.getFormat().transcodable() || child.getMedia() != null) {
          if (child.getMedia() == null) {
            child.setMedia(new DLNAMediaInfo());
          }
          Player player=null;
          String name=getName();
          if (!configuration.isHideRecentlyPlayedFolder(null)) {
            player=child.getPlayer();
          }
 else {
            for (            Player p : PlayerFactory.getPlayers()) {
              String end="String_Node_Str" + p.id() + "String_Node_Str";
              if (name.endsWith(end)) {
                nametruncate=name.lastIndexOf(end);
                player=p;
                LOGGER.trace("String_Node_Str");
                break;
              }
 else               if (getParent() != null && getParent().getName().endsWith(end)) {
                getParent().nametruncate=getParent().getName().lastIndexOf(end);
                player=p;
                LOGGER.trace("String_Node_Str");
                break;
              }
            }
          }
          if (player == null) {
            player=PlayerFactory.getPlayer(child);
          }
          if (player != null && !allChildrenAreFolders) {
            String configurationForceExtensions=configuration.getForceTranscodeForExtensions();
            String rendererForceExtensions=null;
            if (getDefaultRenderer() != null) {
              rendererForceExtensions=getDefaultRenderer().getTranscodedExtensions();
            }
            boolean forceTranscode=child.getFormat().skip(configurationForceExtensions,rendererForceExtensions);
            if (forceTranscode) {
              LOGGER.trace("String_Node_Str",child.getName());
            }
            boolean hasEmbeddedSubs=false;
            if (child.getMedia() != null) {
              for (              DLNAMediaSubtitle s : child.getMedia().getSubtitleTracksList()) {
                hasEmbeddedSubs=(hasEmbeddedSubs || s.isEmbedded());
              }
            }
            boolean hasSubsToTranscode=false;
            if (!configuration.isDisableSubtitles()) {
              if (child.isSubsFile()) {
                hasSubsToTranscode=getDefaultRenderer() != null && StringUtils.isBlank(getDefaultRenderer().getSupportedSubtitles());
              }
 else {
                hasSubsToTranscode=hasEmbeddedSubs;
              }
              if (hasSubsToTranscode) {
                LOGGER.trace("String_Node_Str",child.getName());
              }
            }
            boolean isIncompatible=false;
            String audioTracksList=child.getName() + child.getMedia().getAudioTracksList().toString();
            if (!child.getFormat().isCompatible(child.getMedia(),getDefaultRenderer())) {
              isIncompatible=true;
              LOGGER.trace("String_Node_Str",child.getName());
            }
 else             if (configuration.isEncodedAudioPassthrough() && (audioTracksList.contains("String_Node_Str") || audioTracksList.contains("String_Node_Str"))) {
              isIncompatible=true;
              LOGGER.trace("String_Node_Str",child.getName());
            }
            boolean preferTranscode=isIncompatible || hasSubsToTranscode;
            if (forceTranscode || (preferTranscode && !isSkipTranscode())) {
              child.setPlayer(player);
              if (resumeRes != null) {
                resumeRes.setPlayer(player);
              }
              if (parserV2) {
                LOGGER.trace("String_Node_Str",child.getName(),player.toString(),child.getMedia().getMimeType());
              }
 else {
                LOGGER.trace("String_Node_Str",child.getName(),player.toString());
              }
            }
 else {
              LOGGER.trace("String_Node_Str",child.getName());
            }
            if ((child.getFormat().isVideo() || child.getFormat().isAudio()) && child.isTranscodeFolderAvailable()) {
              VirtualFolder transcodeFolder=getTranscodeFolder(true);
              if (transcodeFolder != null) {
                VirtualFolder fileTranscodeFolder=new FileTranscodeVirtualFolder(child.getDisplayName(),null);
                DLNAResource newChild=child.clone();
                newChild.setPlayer(player);
                newChild.setMedia(child.getMedia());
                fileTranscodeFolder.addChildInternal(newChild);
                LOGGER.trace("String_Node_Str",child.getName(),player.toString());
                transcodeFolder.updateChild(fileTranscodeFolder);
              }
            }
            if (child.getFormat().isVideo() && child.isSubSelectable() && !(this instanceof SubSelFile)) {
              VirtualFolder vf=getSubSelector(true);
              if (vf != null) {
                DLNAResource newChild=child.clone();
                newChild.setPlayer(player);
                newChild.setMedia(child.getMedia());
                LOGGER.trace("String_Node_Str" + child.getName() + "String_Node_Str"+ player.toString());
                vf.addChild(new SubSelFile(newChild));
              }
            }
            for (            ExternalListener listener : ExternalFactory.getExternalListeners()) {
              if (listener instanceof AdditionalResourceFolderListener) {
                try {
                  ((AdditionalResourceFolderListener)listener).addAdditionalFolder(this,child);
                }
 catch (                Throwable t) {
                  LOGGER.error("String_Node_Str",listener.getClass(),t);
                }
              }
            }
          }
 else           if (!child.getFormat().isCompatible(child.getMedia(),getDefaultRenderer()) && !child.isFolder()) {
            LOGGER.trace("String_Node_Str",child.getName(),getDefaultRenderer().getRendererName());
            getChildren().remove(child);
          }
        }
        if (resumeRes != null) {
          resumeRes.setMedia(child.getMedia());
        }
        if (child.getFormat().getSecondaryFormat() != null && child.getMedia() != null && getDefaultRenderer() != null && getDefaultRenderer().supportsFormat(child.getFormat().getSecondaryFormat())) {
          DLNAResource newChild=child.clone();
          newChild.setFormat(newChild.getFormat().getSecondaryFormat());
          LOGGER.trace("String_Node_Str",newChild.getFormat().toString(),newChild.getName());
          newChild.first=child;
          child.second=newChild;
          if (!newChild.getFormat().isCompatible(newChild.getMedia(),getDefaultRenderer())) {
            Player player=PlayerFactory.getPlayer(newChild);
            newChild.setPlayer(player);
            LOGGER.trace("String_Node_Str",newChild.getFormat().toString(),newChild.getPlayer().name(),newChild.getName());
          }
          if (child.getMedia() != null && child.getMedia().isSecondaryFormatValid()) {
            addChild(newChild);
            LOGGER.trace("String_Node_Str",newChild.getFormat().toString(),newChild.getName());
          }
 else {
            LOGGER.trace("String_Node_Str",newChild.getFormat().toString(),newChild.getName());
          }
        }
      }
      if (addResumeFile) {
        addChildInternal(resumeRes);
      }
      if (isNew) {
        addChildInternal(child);
      }
    }
  }
 catch (  Throwable t) {
    LOGGER.error("String_Node_Str",child.getName(),t);
    child.setParent(null);
    getChildren().remove(child);
  }
}