Program: 63060
Project: 63060
Buggy source:
/** 
 * 上传媒体文件 <p> 正常情况下返回{"type":"TYPE","media_id":"MEDIA_ID","created_at":123456789}, 否则抛出异常. </p>
 * @param agentid 企业应用ID(<font color="red">大于0时视为上传永久媒体文件</font>)
 * @param is 媒体数据流
 * @param fileName 文件名
 * @return 上传到微信服务器返回的媒体标识
 * @see <a
	 *      href="http://qydev.weixin.qq.com/wiki/index.php?title=%E4%B8%8A%E4%BC%A0%E4%B8%B4%E6%97%B6%E7%B4%A0%E6%9D%90%E6%96%87%E4%BB%B6">上传临时素材文件说明</a>
 * @see <a
	 *      href="http://http://qydev.weixin.qq.com/wiki/index.php?title=%E4%B8%8A%E4%BC%A0%E6%B0%B8%E4%B9%85%E7%B4%A0%E6%9D%90">上传永久素材文件说明</a>
 * @throws WeixinException
 */
public String uploadMedia(int agentid,InputStream is,String fileName) throws WeixinException {
  byte[] content;
  try {
    content=IOUtil.toByteArray(is);
  }
 catch (  IOException e) {
    throw new WeixinException(e);
  }
  if (StringUtil.isBlank(fileName)) {
    fileName=ObjectId.get().toHexString();
  }
  String suffixName=IOUtil.getExtension(fileName);
  if (StringUtil.isBlank(suffixName)) {
    suffixName=FileUtil.getFileType(new ByteArrayInputStream(content));
    fileName=String.format("String_Node_Str",fileName,suffixName);
  }
  MediaType mediaType=null;
  if ("String_Node_Str".contains(suffixName)) {
    mediaType=MediaType.image;
  }
 else   if ("String_Node_Str".contains(suffixName)) {
    mediaType=MediaType.voice;
  }
 else   if ("String_Node_Str".equals(suffixName)) {
    mediaType=MediaType.video;
  }
 else {
    mediaType=MediaType.file;
  }
  Token token=tokenHolder.getToken();
  try {
    WeixinResponse response=null;
    if (agentid > 0) {
      String material_media_upload_uri=getRequestUri("String_Node_Str");
      response=weixinClient.post(String.format(material_media_upload_uri,token.getAccessToken(),mediaType.name(),agentid),new FormBodyPart("String_Node_Str",new InputStreamBody(new ByteArrayInputStream(content),mediaType.getContentType().getMimeType(),fileName)));
    }
 else {
      String file_upload_uri=getRequestUri("String_Node_Str");
      response=weixinClient.post(String.format(file_upload_uri,token.getAccessToken(),mediaType.name()),new FormBodyPart("String_Node_Str",new InputStreamBody(new ByteArrayInputStream(content),mediaType.getContentType().getMimeType(),fileName)));
    }
    return response.getAsJson().getString("String_Node_Str");
  }
  finally {
    if (is != null) {
      try {
        is.close();
      }
 catch (      IOException e) {
        ;
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * 上传媒体文件 <p> 正常情况下返回{"type":"TYPE","media_id":"MEDIA_ID","created_at":123456789}, 否则抛出异常. </p>
 * @param agentid 企业应用ID(<font color="red">大于0时视为上传永久媒体文件</font>)
 * @param is 媒体数据流
 * @param fileName 文件名
 * @return 上传到微信服务器返回的媒体标识
 * @see <a
	 *      href="http://qydev.weixin.qq.com/wiki/index.php?title=%E4%B8%8A%E4%BC%A0%E4%B8%B4%E6%97%B6%E7%B4%A0%E6%9D%90%E6%96%87%E4%BB%B6">上传临时素材文件说明</a>
 * @see <a
	 *      href="http://http://qydev.weixin.qq.com/wiki/index.php?title=%E4%B8%8A%E4%BC%A0%E6%B0%B8%E4%B9%85%E7%B4%A0%E6%9D%90">上传永久素材文件说明</a>
 * @throws WeixinException
 */
public String uploadMedia(int agentid,InputStream is,String fileName) throws WeixinException {
  byte[] content;
  try {
    content=IOUtil.toByteArray(is);
  }
 catch (  IOException e) {
    throw new WeixinException(e);
  }
  if (StringUtil.isBlank(fileName)) {
    fileName=ObjectId.get().toHexString();
  }
  String suffixName=IOUtil.getExtension(fileName);
  if (StringUtil.isBlank(suffixName)) {
    suffixName=FileUtil.getFileType(new ByteArrayInputStream(content));
    fileName=String.format("String_Node_Str",fileName,suffixName);
  }
  MediaType mediaType=null;
  if ("String_Node_Str".contains(suffixName)) {
    mediaType=MediaType.image;
  }
 else   if ("String_Node_Str".contains(suffixName)) {
    mediaType=MediaType.voice;
  }
 else   if ("String_Node_Str".contains(suffixName)) {
    mediaType=MediaType.video;
  }
 else {
    mediaType=MediaType.file;
  }
  Token token=tokenHolder.getToken();
  try {
    WeixinResponse response=null;
    if (agentid > 0) {
      String material_media_upload_uri=getRequestUri("String_Node_Str");
      response=weixinClient.post(String.format(material_media_upload_uri,token.getAccessToken(),mediaType.name(),agentid),new FormBodyPart("String_Node_Str",new InputStreamBody(new ByteArrayInputStream(content),mediaType.getContentType().getMimeType(),fileName)));
    }
 else {
      String file_upload_uri=getRequestUri("String_Node_Str");
      response=weixinClient.post(String.format(file_upload_uri,token.getAccessToken(),mediaType.name()),new FormBodyPart("String_Node_Str",new InputStreamBody(new ByteArrayInputStream(content),mediaType.getContentType().getMimeType(),fileName)));
    }
    return response.getAsJson().getString("String_Node_Str");
  }
  finally {
    if (is != null) {
      try {
        is.close();
      }
 catch (      IOException e) {
        ;
      }
    }
  }
}