Program: 16122
Project: 16122
Buggy source:
/** 
 * Process the specified fileitem.
 */
private static final Media processItem(Desktop desktop,FileItem fi,boolean alwaysNative) throws IOException {
  String name=getBaseName(fi);
  if (name != null) {
    final int j=name.lastIndexOf(';');
    if (j > 0) {
      final int k=name.lastIndexOf('.');
      if (k >= 0 && j > k && k > name.lastIndexOf('/'))       name=name.substring(0,j);
    }
  }
  String ctype=fi.getContentType(), ctypelc=ctype != null ? ctype.toLowerCase() : null;
  if (name != null && "String_Node_Str".equals(ctypelc)) {
    final int j=name.lastIndexOf('.');
    if (j >= 0) {
      String s=ContentTypes.getContentType(name.substring(j + 1));
      if (s != null)       ctypelc=ctype=s;
    }
  }
  if (!alwaysNative && ctypelc != null) {
    if (ctypelc.startsWith("String_Node_Str")) {
      try {
        return fi.isInMemory() ? new AImage(name,fi.get()) : new AImage(name,fi.getInputStream());
      }
 catch (      Throwable ex) {
        if (log.debugable())         log.debug("String_Node_Str" + ctype);
      }
    }
 else     if (ctypelc.startsWith("String_Node_Str")) {
      try {
        return fi.isInMemory() ? new AAudio(name,fi.get()) : new StreamAudio(name,fi,ctypelc);
      }
 catch (      Throwable ex) {
        if (log.debugable())         log.debug("String_Node_Str" + ctype);
      }
    }
 else     if (ctypelc.startsWith("String_Node_Str")) {
      String charset=getCharset(ctype);
      if (charset == null) {
        final Configuration conf=desktop.getWebApp().getConfiguration();
        final CharsetFinder chfd=conf.getUploadCharsetFinder();
        if (chfd != null)         charset=chfd.getCharset(ctype,fi.isInMemory() ? new ByteArrayInputStream(fi.get()) : fi.getInputStream());
        if (charset == null)         charset=conf.getUploadCharset();
      }
      return fi.isInMemory() ? new AMedia(name,null,ctype,fi.getString(charset)) : new ReaderMedia(name,null,ctype,fi,charset);
    }
  }
  return fi.isInMemory() ? new AMedia(name,null,ctype,fi.get()) : new StreamMedia(name,null,ctype,fi);
}

Fixed version (ground truth):
/** 
 * Process the specified fileitem.
 */
private static final Media processItem(Desktop desktop,FileItem fi,boolean alwaysNative) throws IOException {
  String name=getBaseName(fi);
  if (name != null) {
    final int j=name.lastIndexOf(';');
    if (j > 0) {
      final int k=name.lastIndexOf('.');
      if (k >= 0 && j > k && k > name.lastIndexOf('/'))       name=name.substring(0,j);
    }
  }
  String ctype=fi.getContentType(), ctypelc=ctype != null ? ctype.toLowerCase(java.util.Locale.ENGLISH) : null;
  if (name != null && "String_Node_Str".equals(ctypelc)) {
    final int j=name.lastIndexOf('.');
    if (j >= 0) {
      String s=ContentTypes.getContentType(name.substring(j + 1));
      if (s != null)       ctypelc=ctype=s;
    }
  }
  if (!alwaysNative && ctypelc != null) {
    if (ctypelc.startsWith("String_Node_Str")) {
      try {
        return fi.isInMemory() ? new AImage(name,fi.get()) : new AImage(name,fi.getInputStream());
      }
 catch (      Throwable ex) {
        if (log.debugable())         log.debug("String_Node_Str" + ctype);
      }
    }
 else     if (ctypelc.startsWith("String_Node_Str")) {
      try {
        return fi.isInMemory() ? new AAudio(name,fi.get()) : new StreamAudio(name,fi,ctypelc);
      }
 catch (      Throwable ex) {
        if (log.debugable())         log.debug("String_Node_Str" + ctype);
      }
    }
 else     if (ctypelc.startsWith("String_Node_Str")) {
      String charset=getCharset(ctype);
      if (charset == null) {
        final Configuration conf=desktop.getWebApp().getConfiguration();
        final CharsetFinder chfd=conf.getUploadCharsetFinder();
        if (chfd != null)         charset=chfd.getCharset(ctype,fi.isInMemory() ? new ByteArrayInputStream(fi.get()) : fi.getInputStream());
        if (charset == null)         charset=conf.getUploadCharset();
      }
      return fi.isInMemory() ? new AMedia(name,null,ctype,fi.getString(charset)) : new ReaderMedia(name,null,ctype,fi,charset);
    }
  }
  return fi.isInMemory() ? new AMedia(name,null,ctype,fi.get()) : new StreamMedia(name,null,ctype,fi);
}