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

Camel Jasypt component throws NPE

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.17.0
    • 2.17.6, 2.18.3, 2.19.0
    • camel-jasypt
    • None
    • Patch Available
    • Unknown

    Description

      Camel Jasypt component throws NPE if the jasypt master password is configured to use environment variable but not set to any value.

      For instance, I had a bean configured for JasyptPropertiesParser:

      <bean id="jasypt" class="org.apache.camel.component.jasypt.JasyptPropertiesParser">
              <property name="password" value="sysenv:JASYPT_ENCRYPTION_PASSWORD"/>
          </bean>
      

      But I did not set value for the environment variable "JASYPT_ENCRYPTION_PASSWORD", then my camel-jasypt route would fail with a NPE:

      Caused by: java.lang.NullPointerException
      	at org.apache.camel.component.jasypt.JasyptPropertiesParser.setPassword(JasyptPropertiesParser.java:95)
      ...
      

      The reason is the org.apache.camel.component.jasypt.JasyptPropertiesParser.java code setPassword method here:

      public void setPassword(String password) {
          // lookup password as either environment or JVM system property
          if (password.startsWith("sysenv:")) {
              password = System.getenv(ObjectHelper.after(password, "sysenv:"));
          }
          if (password.startsWith("sys:")) {
              password = System.getProperty(ObjectHelper.after(password, "sys:"));
          }
          this.password = password;
      }
      

      The first "if" statement returns a NULL and the second "if" statement throws a NPE due to lack of NPE check.

      Attachments

        1. patch.txt
          0.9 kB
          Joe Luo

        Activity

          People

            acosentino Andrea Cosentino
            joeluo Joe Luo
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: