cloudfoundry-community / tomee-buildpack

Cloud Foundry buildpack for running Java applications using TomEE
Apache License 2.0
11 stars 24 forks source link

Pretty formatting potential issues #27

Closed tom-collings closed 6 years ago

tom-collings commented 6 years ago

If I am using the tomee buildpack in a chain with another buildpack (multi-buildpack pattern), the tomee buildpack must be last in the chain as it lacks a supply script.

Suppose that other buildpack (https://github.com/tom-collings/simple-buildpack as an example) automatically creates resources based on bound services and produces a Resource node as follows:

<Resource class-name='org.cloudfoundry.test.MyType' id='someId'>
  name1 = val1
  name2 = val2
</Resource>

` The whitespace in the property values (name1, name2) is very important to tomee. While the sample buildpack uses the REXML:Formatter:Transitive formatter (which respects whitespace) to write the file, the tomee buildpack uses the REXML:Formatter:Pretty formatter (which does not respect whitespace) which removes the necessary whitespace and results in a Resource node like:

<Resource class-name='org.cloudfoundry.test.MyType' id='someId'>name1 = val1 name2 = val2</Resource>

As the tomee buildpack is last in the multi-buildpack chain, this final Pretty format is the one that is used for the final form of the resources.xml file.

Which prevents the proper loading of the resource.

tom-collings commented 6 years ago

Found a work-around to this: If the new-line delimited properties are enclosed in a CDATA block, the formatting remains.