Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-17702

[camel-google-storage] Payload type File causes NPE on consumer

    XMLWordPrintableJSON

Details

    • Unknown

    Description

      When sending a file payload to google-storage consumer it causes Null Pointer Exception in GoogleCloudStorageProducer.processFile method. 
              if (obj instanceof File)

      {             filePayload = (File) obj;             is = new FileInputStream(filePayload);         }

      else {
                  is = exchange.getIn().getMandatoryBody(InputStream.class);
                  baos = determineLengthInputStream(is);

       

      baos is not initialized and causing NPE later on.

      Test Case:

      <route id="CopyToGoogleCloudStorage" streamCache="true">
        <from uri="{{file-fromUri}}"/>
        <log message="Found file: '${header[CamelFileNameOnly]}'"/>
            <log message="Uploading to GCS file ${header.CamelFileNameOnly}"/>
            <!-- google-storage does not know File payload type and throws NPE -->
            <convertBodyTo type="String"/> <-- comment this out to create NPE
            <toD uri="google-storage://test?objectName=test.txt&amp;serviceAccountKey=classpath:keys/test.json"/>
        <log message="Moved file: '${header.CamelFileNameOnly}'"/>
      </route> 

       

       

       

       

      Attachments

        Issue Links

          Activity

            People

              klease78 Karen Lease
              Bican Radovan Bičiště
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: