stbischof commented on code in PR #367:
URL: https://github.com/apache/felix-dev/pull/367#discussion_r1913096524


##########
http/base/src/main/java/org/apache/felix/http/base/internal/dispatch/ServletRequestWrapper.java:
##########
@@ -411,143 +381,17 @@ public boolean isAsyncSupported()
         return this.asyncSupported;
     }
 
-    private RequestContext getMultipartContext() {
-        final RequestContext multipartContext;
-        if (!POST_METHOD.equalsIgnoreCase(this.getMethod())) {
-            multipartContext = null;
-        } else {
-            multipartContext = new RequestContext() {
-
-                @Override
-                public InputStream getInputStream() throws IOException {
-                    return ServletRequestWrapper.this.getInputStream();
-                }
-
-                @Override
-                public String getContentType() {
-                    return ServletRequestWrapper.this.getContentType();
-                }
-
-                @Override
-                public int getContentLength() {
-                    return ServletRequestWrapper.this.getContentLength();
-                }
-
-                @Override
-                public String getCharacterEncoding() {
-                    return ServletRequestWrapper.this.getCharacterEncoding();
-                }
-            };
-        }
-        return multipartContext;
-    }
-
-    private Collection<PartImpl> checkMultipart() throws IOException, 
ServletException {
-        if ( parts == null ) {
-            final RequestContext multipartContext = getMultipartContext();
-            if ( multipartContext != null && 
FileUploadBase.isMultipartContent(multipartContext) ) {
-                if ( this.multipartConfig == null) {
-                    throw new IllegalStateException("Multipart not enabled for 
servlet.");
-                }
-
-                if ( System.getSecurityManager() == null ) {
-                    handleMultipart(multipartContext);
-                } else {
-                    final AccessControlContext ctx = 
bundleForSecurityCheck.adapt(AccessControlContext.class);
-                    final IOException ioe = AccessController.doPrivileged(new 
PrivilegedAction<IOException>() {
-
-                        @Override
-                        public IOException run() {
-                            try {
-                                handleMultipart(multipartContext);
-                            } catch ( final IOException ioe) {
-                                return ioe;
-                            }
-                            return null;
-                        }
-                    }, ctx);
-                    if ( ioe != null ) {
-                        throw ioe;
-                    }
-                }
-
-            } else {
-                throw new ServletException("Not a multipart request");
-            }
-        }
-        return parts;
-    }
-
-    private void handleMultipart(final RequestContext multipartContext) throws 
IOException {
-        // Create a new file upload handler
-        final FileUpload upload = new FileUpload();
-        upload.setSizeMax(this.multipartConfig.multipartMaxRequestSize);
-        upload.setFileSizeMax(this.multipartConfig.multipartMaxFileSize);
-        upload.setFileItemFactory(new 
DiskFileItemFactory(this.multipartConfig.multipartThreshold,
-                new File(this.multipartConfig.multipartLocation)));
-        upload.setFileCountMax(this.multipartConfig.multipartMaxFileCount);
-        // Parse the request
-        List<FileItem> items = null;
-        try {
-            items = upload.parseRequest(multipartContext);
-        } catch (final FileUploadException fue) {
-            throw new IOException("Error parsing multipart request", fue);
-        }
-        this.parts = new ArrayList<>();
-        for(final FileItem item : items) {
-            this.parts.add(new PartImpl(item));
-        }
-    }
-
     @Override
     @SuppressWarnings({ "unchecked", "rawtypes" })
     public Collection<Part> getParts() throws IOException, ServletException {
-        return (Collection)checkMultipart();
-
+        return null;

Review Comment:
   Thank you!
   I now throw an ServletException.



##########
http/base/src/main/java/org/apache/felix/http/base/internal/dispatch/ServletRequestWrapper.java:
##########
@@ -411,143 +381,17 @@ public boolean isAsyncSupported()
         return this.asyncSupported;
     }
 
-    private RequestContext getMultipartContext() {
-        final RequestContext multipartContext;
-        if (!POST_METHOD.equalsIgnoreCase(this.getMethod())) {
-            multipartContext = null;
-        } else {
-            multipartContext = new RequestContext() {
-
-                @Override
-                public InputStream getInputStream() throws IOException {
-                    return ServletRequestWrapper.this.getInputStream();
-                }
-
-                @Override
-                public String getContentType() {
-                    return ServletRequestWrapper.this.getContentType();
-                }
-
-                @Override
-                public int getContentLength() {
-                    return ServletRequestWrapper.this.getContentLength();
-                }
-
-                @Override
-                public String getCharacterEncoding() {
-                    return ServletRequestWrapper.this.getCharacterEncoding();
-                }
-            };
-        }
-        return multipartContext;
-    }
-
-    private Collection<PartImpl> checkMultipart() throws IOException, 
ServletException {
-        if ( parts == null ) {
-            final RequestContext multipartContext = getMultipartContext();
-            if ( multipartContext != null && 
FileUploadBase.isMultipartContent(multipartContext) ) {
-                if ( this.multipartConfig == null) {
-                    throw new IllegalStateException("Multipart not enabled for 
servlet.");
-                }
-
-                if ( System.getSecurityManager() == null ) {
-                    handleMultipart(multipartContext);
-                } else {
-                    final AccessControlContext ctx = 
bundleForSecurityCheck.adapt(AccessControlContext.class);
-                    final IOException ioe = AccessController.doPrivileged(new 
PrivilegedAction<IOException>() {
-
-                        @Override
-                        public IOException run() {
-                            try {
-                                handleMultipart(multipartContext);
-                            } catch ( final IOException ioe) {
-                                return ioe;
-                            }
-                            return null;
-                        }
-                    }, ctx);
-                    if ( ioe != null ) {
-                        throw ioe;
-                    }
-                }
-
-            } else {
-                throw new ServletException("Not a multipart request");
-            }
-        }
-        return parts;
-    }
-
-    private void handleMultipart(final RequestContext multipartContext) throws 
IOException {
-        // Create a new file upload handler
-        final FileUpload upload = new FileUpload();
-        upload.setSizeMax(this.multipartConfig.multipartMaxRequestSize);
-        upload.setFileSizeMax(this.multipartConfig.multipartMaxFileSize);
-        upload.setFileItemFactory(new 
DiskFileItemFactory(this.multipartConfig.multipartThreshold,
-                new File(this.multipartConfig.multipartLocation)));
-        upload.setFileCountMax(this.multipartConfig.multipartMaxFileCount);
-        // Parse the request
-        List<FileItem> items = null;
-        try {
-            items = upload.parseRequest(multipartContext);
-        } catch (final FileUploadException fue) {
-            throw new IOException("Error parsing multipart request", fue);
-        }
-        this.parts = new ArrayList<>();
-        for(final FileItem item : items) {
-            this.parts.add(new PartImpl(item));
-        }
-    }
-
     @Override
     @SuppressWarnings({ "unchecked", "rawtypes" })
     public Collection<Part> getParts() throws IOException, ServletException {
-        return (Collection)checkMultipart();
-
+        return null;
     }
 
     @Override
     public Part getPart(String name) throws IOException, ServletException {
-        Collection<PartImpl> parts = this.checkMultipart();
-        for(final Part p : parts) {
-            if ( p.getName().equals(name) ) {
-                return p;
-            }
-        }

Review Comment:
   I now throw an ServletException.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@felix.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to