Program: 90719
Project: 90719
Buggy source:
public XMLConfiguration(final ConfigurationFactory.ConfigurationSource configSource){
  this.configFile=configSource.getFile();
  byte[] buffer=null;
  try {
    final InputStream configStream=configSource.getInputStream();
    buffer=toByteArray(configStream);
    configStream.close();
    final InputSource source=new InputSource(new ByteArrayInputStream(buffer));
    final DocumentBuilder builder=DocumentBuilderFactory.newInstance().newDocumentBuilder();
    final Document document=builder.parse(source);
    rootElement=document.getDocumentElement();
    final Map<String,String> attrs=processAttributes(rootNode,rootElement);
    Level status=Level.OFF;
    boolean verbose=false;
    PrintStream stream=System.out;
    for (    final Map.Entry<String,String> entry : attrs.entrySet()) {
      if ("String_Node_Str".equalsIgnoreCase(entry.getKey())) {
        status=Level.toLevel(getSubst().replace(entry.getValue()),null);
        if (status == null) {
          status=Level.ERROR;
          messages.add("String_Node_Str" + entry.getValue() + "String_Node_Str");
        }
      }
 else       if ("String_Node_Str".equalsIgnoreCase(entry.getKey())) {
        final String dest=entry.getValue();
        if (dest != null) {
          if (dest.equalsIgnoreCase("String_Node_Str")) {
            stream=System.err;
          }
 else {
            try {
              final File destFile=FileUtils.fileFromURI(new URI(dest));
              stream=new PrintStream(new FileOutputStream(destFile));
            }
 catch (            final URISyntaxException use) {
              System.err.println("String_Node_Str" + dest + "String_Node_Str");
            }
          }
        }
      }
 else       if ("String_Node_Str".equalsIgnoreCase(entry.getKey())) {
        verbose=Boolean.parseBoolean(getSubst().replace(entry.getValue()));
      }
 else       if ("String_Node_Str".equalsIgnoreCase(getSubst().replace(entry.getKey()))) {
        final String[] packages=entry.getValue().split("String_Node_Str");
        for (        final String p : packages) {
          PluginManager.addPackage(p);
        }
      }
 else       if ("String_Node_Str".equalsIgnoreCase(entry.getKey())) {
        setName(getSubst().replace(entry.getValue()));
      }
 else       if ("String_Node_Str".equalsIgnoreCase(entry.getKey())) {
        strict=Boolean.parseBoolean(getSubst().replace(entry.getValue()));
      }
 else       if ("String_Node_Str".equalsIgnoreCase(entry.getKey())) {
        schema=getSubst().replace(entry.getValue());
      }
 else       if ("String_Node_Str".equalsIgnoreCase(entry.getKey())) {
        final int interval=Integer.parseInt(getSubst().replace(entry.getValue()));
        if (interval > 0 && configFile != null) {
          monitor=new FileConfigurationMonitor(this,configFile,listeners,interval);
        }
      }
 else       if ("String_Node_Str".equalsIgnoreCase(entry.getKey())) {
        final String advertiserString=getSubst().replace(entry.getValue());
        if (advertiserString != null) {
          @SuppressWarnings("String_Node_Str") final PluginType<Advertiser> type=getPluginManager().getPluginType(advertiserString);
          if (type != null) {
            final Class<Advertiser> clazz=type.getPluginClass();
            try {
              advertiser=clazz.newInstance();
              advertisedConfiguration=new HashMap<String,String>();
              advertisedConfiguration.put("String_Node_Str",new String(buffer));
              advertisedConfiguration.put("String_Node_Str","String_Node_Str");
              advertisedConfiguration.put("String_Node_Str","String_Node_Str");
              if (configSource.getLocation() != null) {
                advertisedConfiguration.put("String_Node_Str",configSource.getLocation());
              }
            }
 catch (            InstantiationException e) {
              System.err.println("String_Node_Str" + advertiserString);
            }
catch (            IllegalAccessException e) {
              System.err.println("String_Node_Str" + advertiserString);
            }
          }
        }
      }
    }
    final Iterator<StatusListener> iter=((StatusLogger)LOGGER).getListeners();
    boolean found=false;
    while (iter.hasNext()) {
      final StatusListener listener=iter.next();
      if (listener instanceof StatusConsoleListener) {
        found=true;
        ((StatusConsoleListener)listener).setLevel(status);
        if (!verbose) {
          ((StatusConsoleListener)listener).setFilters(VERBOSE_CLASSES);
        }
      }
    }
    if (!found && status != Level.OFF) {
      final StatusConsoleListener listener=new StatusConsoleListener(status,stream);
      if (!verbose) {
        listener.setFilters(VERBOSE_CLASSES);
      }
      ((StatusLogger)LOGGER).registerListener(listener);
      for (      final String msg : messages) {
        LOGGER.error(msg);
      }
    }
  }
 catch (  final SAXException domEx) {
    LOGGER.error("String_Node_Str" + configSource.getLocation(),domEx);
  }
catch (  final IOException ioe) {
    LOGGER.error("String_Node_Str" + configSource.getLocation(),ioe);
  }
catch (  final ParserConfigurationException pex) {
    LOGGER.error("String_Node_Str" + configSource.getLocation(),pex);
  }
  if (strict && schema != null && buffer != null) {
    InputStream is=null;
    try {
      is=getClass().getClassLoader().getResourceAsStream(schema);
    }
 catch (    final Exception ex) {
      LOGGER.error("String_Node_Str" + schema);
    }
    if (is != null) {
      final Source src=new StreamSource(is,LOG4J_XSD);
      final SchemaFactory factory=SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
      Schema schema=null;
      try {
        schema=factory.newSchema(src);
      }
 catch (      final SAXException ex) {
        LOGGER.error("String_Node_Str",ex);
      }
      if (schema != null) {
        validator=schema.newValidator();
        try {
          validator.validate(new StreamSource(new ByteArrayInputStream(buffer)));
        }
 catch (        final IOException ioe) {
          LOGGER.error("String_Node_Str",ioe);
        }
catch (        final SAXException ex) {
          LOGGER.error("String_Node_Str",ex);
        }
      }
    }
  }
  if (getName() == null) {
    setName(configSource.getLocation());
  }
}

Fixed version (ground truth):
public XMLConfiguration(final ConfigurationFactory.ConfigurationSource configSource){
  this.configFile=configSource.getFile();
  byte[] buffer=null;
  try {
    final InputStream configStream=configSource.getInputStream();
    buffer=toByteArray(configStream);
    configStream.close();
    final InputSource source=new InputSource(new ByteArrayInputStream(buffer));
    final DocumentBuilder builder=DocumentBuilderFactory.newInstance().newDocumentBuilder();
    final Document document=builder.parse(source);
    rootElement=document.getDocumentElement();
    final Map<String,String> attrs=processAttributes(rootNode,rootElement);
    Level status=Level.OFF;
    boolean verbose=false;
    PrintStream stream=System.out;
    for (    final Map.Entry<String,String> entry : attrs.entrySet()) {
      if ("String_Node_Str".equalsIgnoreCase(entry.getKey())) {
        status=Level.toLevel(getSubst().replace(entry.getValue()),null);
        if (status == null) {
          status=Level.ERROR;
          messages.add("String_Node_Str" + entry.getValue() + "String_Node_Str");
        }
      }
 else       if ("String_Node_Str".equalsIgnoreCase(entry.getKey())) {
        final String dest=entry.getValue();
        if (dest != null) {
          if (dest.equalsIgnoreCase("String_Node_Str")) {
            stream=System.err;
          }
 else {
            try {
              final File destFile=FileUtils.fileFromURI(new URI(dest));
              final String enc=Charset.defaultCharset().name();
              stream=new PrintStream(new FileOutputStream(destFile),true,enc);
            }
 catch (            final URISyntaxException use) {
              System.err.println("String_Node_Str" + dest + "String_Node_Str");
            }
          }
        }
      }
 else       if ("String_Node_Str".equalsIgnoreCase(entry.getKey())) {
        verbose=Boolean.parseBoolean(getSubst().replace(entry.getValue()));
      }
 else       if ("String_Node_Str".equalsIgnoreCase(getSubst().replace(entry.getKey()))) {
        final String[] packages=entry.getValue().split("String_Node_Str");
        for (        final String p : packages) {
          PluginManager.addPackage(p);
        }
      }
 else       if ("String_Node_Str".equalsIgnoreCase(entry.getKey())) {
        setName(getSubst().replace(entry.getValue()));
      }
 else       if ("String_Node_Str".equalsIgnoreCase(entry.getKey())) {
        strict=Boolean.parseBoolean(getSubst().replace(entry.getValue()));
      }
 else       if ("String_Node_Str".equalsIgnoreCase(entry.getKey())) {
        schema=getSubst().replace(entry.getValue());
      }
 else       if ("String_Node_Str".equalsIgnoreCase(entry.getKey())) {
        final int interval=Integer.parseInt(getSubst().replace(entry.getValue()));
        if (interval > 0 && configFile != null) {
          monitor=new FileConfigurationMonitor(this,configFile,listeners,interval);
        }
      }
 else       if ("String_Node_Str".equalsIgnoreCase(entry.getKey())) {
        final String advertiserString=getSubst().replace(entry.getValue());
        if (advertiserString != null) {
          @SuppressWarnings("String_Node_Str") final PluginType<Advertiser> type=getPluginManager().getPluginType(advertiserString);
          if (type != null) {
            final Class<Advertiser> clazz=type.getPluginClass();
            try {
              advertiser=clazz.newInstance();
              advertisedConfiguration=new HashMap<String,String>();
              advertisedConfiguration.put("String_Node_Str",new String(buffer));
              advertisedConfiguration.put("String_Node_Str","String_Node_Str");
              advertisedConfiguration.put("String_Node_Str","String_Node_Str");
              if (configSource.getLocation() != null) {
                advertisedConfiguration.put("String_Node_Str",configSource.getLocation());
              }
            }
 catch (            InstantiationException e) {
              System.err.println("String_Node_Str" + advertiserString);
            }
catch (            IllegalAccessException e) {
              System.err.println("String_Node_Str" + advertiserString);
            }
          }
        }
      }
    }
    final Iterator<StatusListener> iter=((StatusLogger)LOGGER).getListeners();
    boolean found=false;
    while (iter.hasNext()) {
      final StatusListener listener=iter.next();
      if (listener instanceof StatusConsoleListener) {
        found=true;
        ((StatusConsoleListener)listener).setLevel(status);
        if (!verbose) {
          ((StatusConsoleListener)listener).setFilters(VERBOSE_CLASSES);
        }
      }
    }
    if (!found && status != Level.OFF) {
      final StatusConsoleListener listener=new StatusConsoleListener(status,stream);
      if (!verbose) {
        listener.setFilters(VERBOSE_CLASSES);
      }
      ((StatusLogger)LOGGER).registerListener(listener);
      for (      final String msg : messages) {
        LOGGER.error(msg);
      }
    }
  }
 catch (  final SAXException domEx) {
    LOGGER.error("String_Node_Str" + configSource.getLocation(),domEx);
  }
catch (  final IOException ioe) {
    LOGGER.error("String_Node_Str" + configSource.getLocation(),ioe);
  }
catch (  final ParserConfigurationException pex) {
    LOGGER.error("String_Node_Str" + configSource.getLocation(),pex);
  }
  if (strict && schema != null && buffer != null) {
    InputStream is=null;
    try {
      is=getClass().getClassLoader().getResourceAsStream(schema);
    }
 catch (    final Exception ex) {
      LOGGER.error("String_Node_Str" + schema);
    }
    if (is != null) {
      final Source src=new StreamSource(is,LOG4J_XSD);
      final SchemaFactory factory=SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
      Schema schema=null;
      try {
        schema=factory.newSchema(src);
      }
 catch (      final SAXException ex) {
        LOGGER.error("String_Node_Str",ex);
      }
      if (schema != null) {
        validator=schema.newValidator();
        try {
          validator.validate(new StreamSource(new ByteArrayInputStream(buffer)));
        }
 catch (        final IOException ioe) {
          LOGGER.error("String_Node_Str",ioe);
        }
catch (        final SAXException ex) {
          LOGGER.error("String_Node_Str",ex);
        }
      }
    }
  }
  if (getName() == null) {
    setName(configSource.getLocation());
  }
}