Program: 15897
Project: 15897
Buggy source:
/** 
 * Handles the exception that was thrown when uploading files, and returns the error message. When uploading file(s) causes an exception, this method will be called to generate the proper error message. <p>By default, it logs the error and then use   {@link Exceptions#getMessage}to retrieve the error message. <p>If you prefer not to log or to generate the custom error message, you can extend this class and override this method. Then, specify it in web.xml as follows.  (we change from processor0 to extension0 after ZK5.)
 * @see DHtmlUpdateServlet <code><pre>&lt;servlet&gt; &lt;servlet-class&gt;org.zkoss.zk.au.http.DHtmlUpdateServlet&lt;/servlet-class&gt; &lt;init-param&gt; &lt;param-name&gt;extension0&lt;/param-name&gt; &lt;param-value&gt;/upload=com.my.MyUploader&lt;/param-value&gt; &lt;/init-param&gt; ...</pre></code>
 * @param ex the exception.Typical exceptions include org.apache.commons.fileupload .FileUploadBase.SizeLimitExceededException
 * @since 3.0.4
 */
protected String handleError(Throwable ex){
  log.error("String_Node_Str",ex);
  return Exceptions.getMessage(ex);
}

Fixed version (ground truth):
/** 
 * Handles the exception that was thrown when uploading files, and returns the error message. When uploading file(s) causes an exception, this method will be called to generate the proper error message. <p>By default, it logs the error and then use   {@link Exceptions#getMessage}to retrieve the error message. <p>If you prefer not to log or to generate the custom error message, you can extend this class and override this method. Then, specify it in web.xml as follows.  (we change from processor0 to extension0 after ZK5.)
 * @see DHtmlUpdateServlet <code><pre>&lt;servlet&gt; &lt;servlet-class&gt;org.zkoss.zk.au.http.DHtmlUpdateServlet&lt;/servlet-class&gt; &lt;init-param&gt; &lt;param-name&gt;extension0&lt;/param-name&gt; &lt;param-value&gt;/upload=com.my.MyUploader&lt;/param-value&gt; &lt;/init-param&gt; ...</pre></code>
 * @param ex the exception.Typical exceptions include org.apache.commons.fileupload .FileUploadBase.SizeLimitExceededException
 * @since 3.0.4
 */
protected String handleError(Throwable ex){
  log.error("String_Node_Str",ex);
  if (ex instanceof FileUploadBase.SizeLimitExceededException) {
    try {
      FileUploadBase.SizeLimitExceededException fex=(FileUploadBase.SizeLimitExceededException)ex;
      long size=fex.getActualSize();
      long limit=fex.getPermittedSize();
      final Class<?> msgClass=Classes.forNameByThread("String_Node_Str");
      Field msgField=msgClass.getField("String_Node_Str");
      int divisor1=1024;
      int divisor2=1024 * 1024;
      String[] units=new String[]{"String_Node_Str","String_Node_Str","String_Node_Str"};
      int i1=(int)(Math.log(size) / Math.log(1024));
      int i2=(int)(Math.log(limit) / Math.log(1024));
      String size_auto=Math.round(size / Math.pow(1024,i1)) + units[i1];
      String limit_auto=Math.round(limit / Math.pow(1024,i2)) + units[i2];
      Object[] args=new Object[]{size_auto,limit_auto,size,limit,String.valueOf((Long)(size / divisor1)) + units[1],String.valueOf((Long)(limit / divisor1)) + units[1],String.valueOf((Long)(size / divisor2)) + units[2],String.valueOf((Long)(limit / divisor2)) + units[2]};
      return Messages.get(msgField.getInt(null),args);
    }
 catch (    Throwable e) {
      log.error("String_Node_Str",ex);
    }
  }
  return Exceptions.getMessage(ex);
}