--- JSPServlet.java Tue Jul 20 22:39:10 1999 +++ JSPServlet.new Tue Jul 20 22:39:00 1999 @@ -207,12 +207,14 @@ // compile & load jsp servlet if we haven't loaded it yet if(srv == null) { - jspCompiler = new JSPCompiler(this, jspFile, className, request); - jspCompiler.compile(); - - srv = loadServlet(className); - if(srv == null) { - throw new JSPException("Could not load jsp servlet class " + className); + synchronized (this) { + jspCompiler = new JSPCompiler(this, jspFile, className, request); + jspCompiler.compile(); + + srv = loadServlet(className); + if(srv == null) { + throw new JSPException("Could not load jsp servlet class " + className); + } } } } catch(JSPException jspexc) { @@ -254,10 +256,17 @@ return "GNUJSP JSPServlet"; } - private Servlet loadServlet(String className) throws JSPException { + private synchronized Servlet loadServlet(String className) throws JSPException { Class c; Field fld; Servlet srv; + + // Ensure this is still necessary + // (some other thread might have compiled it in the meantime) + srv = (Servlet) jspServlets.get(className); + if (srv != null) { + return srv; // we now have what we need + } // load servlet class try {