enapps-enorman commented on code in PR #75:
URL: 
https://github.com/apache/sling-org-apache-sling-engine/pull/75#discussion_r3253368588


##########
src/main/java/org/apache/sling/engine/impl/parameters/MultipartRequestParameter.java:
##########
@@ -34,33 +35,38 @@
  */
 public class MultipartRequestParameter extends AbstractRequestParameter {
 
-    private final DiskFileItem delegatee;
+    private final Part delegatee;
 
     private String encodedFileName;
 
     private String cachedValue;
 
-    public MultipartRequestParameter(DiskFileItem delegatee) {
-        super(delegatee.getFieldName(), null);
+    public MultipartRequestParameter(Part delegatee) {
+        super(delegatee.getName(), null);
         this.delegatee = delegatee;
     }
 
     void dispose() throws IOException {
         this.delegatee.delete();
     }
 
-    DiskFileItem getFileItem() {
+    Part getPart() {
         return this.delegatee;
     }
 
     @Override
     void setEncoding(String encoding) {
         super.setEncoding(encoding);
         cachedValue = null;
+        encodedFileName = null;
     }
 
     public byte[] get() {
-        return this.delegatee.get();
+        try {
+            return getInputStream().readAllBytes();

Review Comment:
   Good catch.  I'll change this to a try-with-resources block to make sure the 
steam is closed.
   
   I think caching the bytes would be redundant and a premature optimization?  
And what if the file is really big?  Reading the stream on demand seems safer 
and lets the container spool it from memory or disk.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to