Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/test/java/uk/q3c/util/MessageFormatTest.java
  • Loading branch information
David Sowerby committed Jul 30, 2017
2 parents 7c10c2a + 8285f3d commit 2f893c9
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions src/main/java/uk/q3c/util/MessageFormat.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,17 +115,16 @@ private static String scanForParameters(String pattern, List<Integer> parameters
}

private static Object[] sortArguments(List<Integer> parameters, Object[] arguments, String pattern) {
try {
List<Object> 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<Object> sortedArguments = new ArrayList<>();
for (Integer i : parameters) {
sortedArguments.add(arguments[i]);
}
return sortedArguments.toArray();
}
}

0 comments on commit 2f893c9

Please sign in to comment.