Cargo
  1. Cargo
  2. CARGO-880

cargo-maven2-plugin - blank property value in container systemProperties causes NullPointerException

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.0.4
    • Fix Version/s: 1.0.6
    • Component/s: Maven2
    • Labels:
      None
    • Environment:
      Linux, Maven 3.0
    • Complexity:
      Intermediate
    • Tested on JDKs:
      1.6.0_22
    • Number of attachments :
      0

      Description

      Consider the following POM fragment:

      <plugin>
      <groupId>org.codehaus.cargo</groupId>
      <artifactId>cargo-maven2-plugin</artifactId>
      <version>1.0.4</version>
      <configuration>
      <container>
      <containerId>jetty7x</containerId>
      <type>embedded</type>
      ...
      <systemProperties>
      <some.systemProperty>$

      {maven.some.systemProperty}</some.systemProperty>
      </systemProperties>
      </container>
      </configuration>
      ...
      </plugin>

      When included in a build, an exception is thrown if ${maven.some.systemProperty}

      is blank:

      Caused by: java.lang.NullPointerException
      at java.util.Hashtable.put(Hashtable.java:394)
      at java.util.Properties.setProperty(Properties.java:143)
      at java.lang.System.setProperty(System.java:729)
      at org.codehaus.cargo.maven2.configuration.Container.setupEmbeddedSystemProperties(Container.java:290)
      at org.codehaus.cargo.maven2.configuration.Container.createContainer(Container.java:231)
      at org.codehaus.cargo.maven2.AbstractCargoMojo.createNewContainer(AbstractCargoMojo.java:470)
      at org.codehaus.cargo.maven2.AbstractCargoMojo.createContainer(AbstractCargoMojo.java:410)
      at org.codehaus.cargo.maven2.ContainerStartMojo.doExecute(ContainerStartMojo.java:53)
      at org.codehaus.cargo.maven2.AbstractCargoMojo.execute(AbstractCargoMojo.java:268)
      at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:107)

      Of course, one could argue why include the system property in the POM if it's blank. I am wanting to use such functionality as a means of including a runtime "override" to a default value in the WAR being deployed - code in my WAR reads in the system property and uses it as an override only if it is not null; otherwise the default value defined in the WAR is used instead.

      Looking at the stack trace a simple check for null in org.codehaus.cargo.maven2.configuration.Container.setupEmbeddedSystemProperties should solve the problem - if the value is null just don't define the system property.

      I'll take a look at pulling a patch together later when I get a spare moment.

        Activity

        Hide
        Savas Ali Tokmen added a comment -

        Fixed revision 2601.

        Thank you

        Show
        Savas Ali Tokmen added a comment - Fixed revision 2601. Thank you
        Hide
        Alistair Dutton added a comment -

        Have taken a look at revision 2601 - yes, that's exactly what I was suggesting. Thanks for the lightning-quick turnaround!

        Show
        Alistair Dutton added a comment - Have taken a look at revision 2601 - yes, that's exactly what I was suggesting. Thanks for the lightning-quick turnaround!
        Hide
        Savas Ali Tokmen added a comment -

        My pleasure

        Show
        Savas Ali Tokmen added a comment - My pleasure

          People

          • Assignee:
            Savas Ali Tokmen
            Reporter:
            Alistair Dutton
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: