Program: 30331
Project: 30331
Buggy source:
/** 
 * Allocate an initialized instance of this Servlet that is ready to have its <code>service()</code> method called.  If the servlet class does not implement <code>SingleThreadModel</code>, the (only) initialized instance may be returned immediately.  If the servlet class implements <code>SingleThreadModel</code>, the Wrapper implementation must ensure that this instance is not allocated again until it is deallocated by a call to <code>deallocate()</code>.
 * @exception ServletException if the servlet init() method threwan exception
 * @exception ServletException if a loading error occurs
 */
public synchronized Servlet allocate() throws ServletException {
  if (unloading) {
    throw new ServletException(sm.getString("String_Node_Str",getName()));
  }
  if (!singleThreadModel) {
    if (instance == null) {
      try {
        if (log.isLoggable(Level.FINEST))         log.finest("String_Node_Str");
        instance=loadServlet();
        initServlet(instance);
      }
 catch (      ServletException e) {
        throw e;
      }
catch (      Throwable e) {
        throw new ServletException(sm.getString("String_Node_Str"),e);
      }
    }
 else     if (instance.getServletConfig() == null) {
      initServlet(instance);
    }
    if (!singleThreadModel) {
      if (log.isLoggable(Level.FINEST))       log.finest("String_Node_Str");
      countAllocated.incrementAndGet();
      return (instance);
    }
  }
synchronized (instancePool) {
    while (countAllocated.get() >= nInstances) {
      if (nInstances < maxInstances) {
        try {
          Servlet servlet=loadServlet();
          initServlet(servlet);
          instancePool.push(servlet);
          nInstances++;
        }
 catch (        ServletException e) {
          throw e;
        }
catch (        Throwable e) {
          throw new ServletException(sm.getString("String_Node_Str"),e);
        }
      }
 else {
        try {
          instancePool.wait();
        }
 catch (        InterruptedException e) {
        }
      }
    }
    if (log.isLoggable(Level.FINEST)) {
      log.finest("String_Node_Str");
    }
    countAllocated.incrementAndGet();
    return instancePool.pop();
  }
}

Fixed version (ground truth):
/** 
 * Allocate an initialized instance of this Servlet that is ready to have its <code>service()</code> method called.  If the servlet class does not implement <code>SingleThreadModel</code>, the (only) initialized instance may be returned immediately.  If the servlet class implements <code>SingleThreadModel</code>, the Wrapper implementation must ensure that this instance is not allocated again until it is deallocated by a call to <code>deallocate()</code>.
 * @exception ServletException if the servlet init() method threwan exception
 * @exception ServletException if a loading error occurs
 */
public synchronized Servlet allocate() throws ServletException {
  if (unloading) {
    throw new ServletException(sm.getString("String_Node_Str",getName()));
  }
  if (!singleThreadModel) {
    if (instance == null) {
      try {
        if (log.isLoggable(Level.FINEST))         log.finest("String_Node_Str");
        instance=loadServlet();
        initServlet(instance);
      }
 catch (      ServletException e) {
        throw e;
      }
catch (      Throwable e) {
        throw new ServletException(sm.getString("String_Node_Str"),e);
      }
    }
 else     if (!instanceInitialized) {
      initServlet(instance);
    }
    if (!singleThreadModel) {
      if (log.isLoggable(Level.FINEST))       log.finest("String_Node_Str");
      countAllocated.incrementAndGet();
      return (instance);
    }
  }
synchronized (instancePool) {
    while (countAllocated.get() >= nInstances) {
      if (nInstances < maxInstances) {
        try {
          Servlet servlet=loadServlet();
          initServlet(servlet);
          instancePool.push(servlet);
          nInstances++;
        }
 catch (        ServletException e) {
          throw e;
        }
catch (        Throwable e) {
          throw new ServletException(sm.getString("String_Node_Str"),e);
        }
      }
 else {
        try {
          instancePool.wait();
        }
 catch (        InterruptedException e) {
        }
      }
    }
    if (log.isLoggable(Level.FINEST)) {
      log.finest("String_Node_Str");
    }
    countAllocated.incrementAndGet();
    return instancePool.pop();
  }
}