diff --git a/src/main/java/uk/q3c/util/MessageFormat.java b/src/main/java/uk/q3c/util/MessageFormat.java index 12070c67a..67593b6e1 100644 --- a/src/main/java/uk/q3c/util/MessageFormat.java +++ b/src/main/java/uk/q3c/util/MessageFormat.java @@ -115,17 +115,16 @@ private static String scanForParameters(String pattern, List parameters } private static Object[] sortArguments(List parameters, Object[] arguments, String pattern) { - try { - List sortedArguments = new ArrayList<>(); - for (Integer i : parameters) { - sortedArguments.add(arguments[i]); - } - return sortedArguments.toArray(); - } catch (IndexOutOfBoundsException e) { - Object[] args = new Object[] { parameters.size(), arguments.length, pattern }; - log.warn("Message pattern and arguments do not match, there are {} parameters in the pattern, " - + "and {} arguments. The pattern is: '{}'", args); + if (parameters.size() != arguments.length) { + Object[] args = new Object[]{parameters.size(), arguments.length, pattern}; + log.warn("Message pattern and arguments do not match, there are {} parameters in the pattern, " + + "and {} arguments. The pattern is: '{}'", args); throw new RuntimeException(); } + List sortedArguments = new ArrayList<>(); + for (Integer i : parameters) { + sortedArguments.add(arguments[i]); + } + return sortedArguments.toArray(); } }