technicalpickles

Open Source ProjectsCode that Might be Useful to You

Talks I've GivenOn Technologies and Ideas

ThoughtsWhere I Sometimes Write Things

Resume If You Believe In Those

Follow Me On

GitHubIf coding is your thing

TwitterIf you tweet

Annoyances when specifying property values in Spring


Can you spot any issues with specifying a value like this:

<bean id="casProxyTicketValidator" 
   class="org.acegisecurity.providers.cas.ticketvalidator.CasProxyTicketValidator">
  <property name="casValidate">
    <value>https://localhost:8443/cas/proxyValidate</value>
  </property>
  <property name="proxyCallbackUrl">
    <value>
      http://localhost:8085/cbip/casProxy/receptor
    </value>
  </property>
  <property name="serviceProperties">
    <ref bean="serviceProperties" />
  </property>
</bean>

See the value of proxyCallbackUrl? Because of the way it’s spaced, it ends up getting newlines and spaces in the value. This issue caused me quite a headache today.

One way to address would be to make sure <value> immediately surrounds the actual value. But there’s actually a cleaner syntax for doing this. It also has the benefit of being more succinct. Here’s what it looks like after being fixed:

<bean id="casProxyTicketValidator"
     class="org.acegisecurity.providers.cas.ticketvalidator.CasProxyTicketValidator">
  <property name="casValidate" value="https://localhost:8443/cas/proxyValidate"/>
  <property name="proxyCallbackUrl" value="http://localhost:8085/cbip/casProxy/receptor"/>
  <property name="serviceProperties" ref="serviceProperties"/>
</bean>`

Much better, right?

comments powered by Disqus