I’m running into an issue with strings. I’m trying to create a string to use as the CALLBACK parameter for a UPnP request, but whenever I try to insert a < or a >, the string goes AWOL.
For example:
String x
x = "http://${hubAddress}/"
log.debug("x: ${x}")
gives the following output:
1:28:47 PM: debug x: http://10.13.13.227:39500/
If I do this:
String x
x = "<http://${hubAddress}/>"
log.debug("x: ${x}")
I get this:
1:28:47 PM: debug x:
I’ve tried escaping the < and > with backslashes, I’ve tried doubling them up, I’ve tried single quotes. What the heck am I missing?
Support suggested I tag @mager and @matthewnohr in this thread. I feel like I’m missing something so obviously simple, but nothing I try lets me get a string of the format “http://10.10.10.10/notify”.
I may be missing something about this use-case, but why do you need the <> characters? I would suspect that <something> might be interpreted as an HTML tag and actually get stripped out by the log/browser depending on how it is rendered in the logs.
Are you sure it’s not the log who’s messing with your data? I mean what you see in the logs is not necessarily the same what goes down the wire. Have you tried wireshark?
Ampersand “lt;” and ampersand “gt;” is what you used?
If you used the regular ASCII values of < and 62, it won’t escape brackets in Java because the brackets are reserved control characters, so I’m assuming the same is true for Groovy.
As suspected, the log viewer in the IDE was what was screwing things up. The packets on the wire were, in fact, correct. I’ll update my ticket with support so that they know it’s a bug report.