commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From evebill8 <evebi...@hotmail.com>
Subject Is DiskFileItemFactory Thread Safe?
Date Thu, 04 Feb 2010 18:25:06 GMT

I have a servlet that will handle few hundread thousand requests per day.  I
am using the commons FileUpload to loop thru the fields and file items. 
Here is the code 


    public void doPost(HttpServletRequest req, HttpServletResponse res)
            throws ServletException, IOException {

        try {
            DiskFileItemFactory factory = new DiskFileItemFactory();

            ServletFileUpload upload = new ServletFileUpload(factory);
            List<FileItem> items = upload.parseRequest(req);

            for (FileItem item : items) {
                ....
            }
        }
        catch (Exception e) {
            ...
        }
    }

Since the servlet is being called so many times, can I make the
DiskFileItemFactory global static so it won't create the factory object so
many times?  In sum, is DiskFileItemFactory class thread safe?


    DiskFileItemFactory factory = new DiskFileItemFactory();

    public void doPost(HttpServletRequest req, HttpServletResponse res)
            throws ServletException, IOException {

        try {

            ServletFileUpload upload = new ServletFileUpload(factory);
            List<FileItem> items = upload.parseRequest(req);

            for (FileItem item : items) {
                ....
            }
        }
        catch (Exception e) {
            ...
        }
    }

Thanks!

-- 
View this message in context: http://n4.nabble.com/Is-DiskFileItemFactory-Thread-Safe-tp1469216p1469216.html
Sent from the Commons - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message