0

I use spring MessageSource to fetch messages from my localisation properties files.

In this case I use it to create a mail before sendiing it to the user:

String eventTitle = tournament.getEvent().getTitle();
String tournamentMessageTitle = messageSource.getMessage("tournament.subscribe_title",  new Object[] {eventTitle}, "", locale);

DateFormat df = new SimpleDateFormat("dd.MM.yyyy");
String formatedDate = df.format(tournament.getDate());
String barName = bar.getName();
String tournamentMessageContent = messageSource.getMessage("tournament.subscribe_content", new Object[] {username, eventTitle, formatedDate, barName}, "", locale);

and here are the properties in message.properties

tournament.subscribe_title = You signed up for "{0}"
tournament.subscribe_content = Hello {0], <br /><br /> You&rsquo;ve sucessfully signed up for &ldquo;{1}&rdquo;. See you on {2} at Meltdown {3}!<br/><br/>You&rsquo;ll have to confirm your participation with an admin prior to the start of the event.<br/><br/>See you soon!<br/><br/>The Meltdown {3} team

So here, we have two usages of messageSource.getMessage. The first one works, the second one throws IllegalArgumentException: Unmatched braces in the pattern.

I tried to change the message, change/remove the variables, remove the quotes and double quotes, move the properties somewhere else in the message.properties file but I always get the same error

Labe
  • 1,262
  • 2
  • 20
  • 30
  • 3
    Looks like here is an issue `Hello {0]`. Shouldn't that be like all other variables ``Hello {0}` ? – Artem Bilan Mar 12 '15 at 11:24
  • OMG, I am so ashamed :D! Thank you – Labe Mar 12 '15 at 13:52
  • What really annoys me about this exception is that it's not caught as a compiler error. This message has happened to me many time and off many times over the years. When doing conversion work that takes hours to run. What a time wasting PITA it is! – JGFMK Oct 09 '21 at 04:34

0 Answers0