shashank created CAMEL-26047:
--------------------------------

             Summary: camel-minio - the producer uploads a changed body with 
the stale CamelMinioContentLength of the object it was read from, and cuts or 
fails it
                 Key: CAMEL-26047
                 URL: https://issues.apache.org/jira/browse/CAMEL-26047
             Project: Camel
          Issue Type: Bug
          Components: camel-minio
            Reporter: shashank
            Assignee: shashank


The minio consumer sets {{CamelMinioContentLength}} to the size of the object 
it read. {{MinioProducer.putObject}} uses that header as the upload length and 
takes the length of the body only when there is no header, also for a 
{{java.io.File}} body (main 9f839f4bcc9d). A route that reads an object, 
changes the body (unzip, convert, enrich) and stores it with a minio producer 
uploads with the old length. minio 9.0.3 {{PartReader}} reads exactly that many 
bytes: a longer body is stored cut to the old length with no error, and a 
shorter one fails with {{MinioException: unexpected EOF}}. This is the same 
problem as CAMEL-25743 in aws2-s3.

*Fix*: as CAMEL-25743: the producer uploads with the length of the body when it 
is known without reading it ({{PayloadHelper.getLength}} of the body, then of 
its input stream), and uses the header (or the {{WrappedFile}} length) only for 
a stream whose length is not known. Upgrade guide (4.24) entry next to the 
aws2-s3 one. The test-only {{FakeS3Server}} of the module also answers a single 
part PUT.

*Tests*: new {{MinioProducerStaleContentLengthTest}}, 4 tests: the real 
{{MinioClient}} uploads to the in-process fake S3 server and the test reads 
back the stored bytes.
* {{bodyLongerThanAStaleContentLengthHeaderIsStoredWhole}} fails on main: {{the 
whole body must be stored, not the length of the header ==> expected: <a body 
made longer by the route> but was: <a body mad>}};
* {{bodyShorterThanAStaleContentLengthHeaderIsStoredWithItsLength}} fails on 
main: {{a body shorter than the header must be stored ==> expected: <null> but 
was: <io.minio.errors.MinioException: unexpected EOF>}};
* {{fileBodyIsStoredWithItsLength}} fails on main: {{expected: <the content of 
the file> but was: <the>}};
* {{streamOfUnknownLengthUsesTheContentLengthHeader}} is a control that passes 
on main and with the fix.
Unit tests of camel-minio with the fix: 20 run, 0 failures.

*How it was found*: variant analysis of CAMEL-25743 (aws2-s3); kept back until 
that fix was merged.

*Affected*: main, camel-4.23.x, camel-4.22.x and camel-4.18.x (same producer). 
Read, not run.

_Filed with Claude Code on behalf of allthingssecurity._



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to