belliottsmith commented on code in PR #253:
URL: https://github.com/apache/cassandra-accord/pull/253#discussion_r2377930578
##########
accord-core/src/main/java/accord/api/Tracing.java:
##########
@@ -34,35 +30,61 @@ default void trace(CommandStore store, String fmt, Object
... args)
static String safeFormat(String fmt, Object ... args)
{
- try
- {
- return String.format(fmt, args);
- }
- catch (Throwable t)
+ if (args.length == 0)
+ return fmt;
+
+ StringBuilder out = new StringBuilder();
+ int prev = 0;
+ for (int argIndex = 0 ; argIndex < args.length ; ++argIndex)
{
+ Object arg = args[argIndex];
+ int next = fmt.indexOf('%', prev);
+ if (next < 0)
+ break;
+
+ out.append(fmt, prev, next);
+ if (++next == fmt.length())
+ throw new IllegalArgumentException("Invalid substitution
declaration: % not followed by d, s or %");
+
+ char ch = fmt.charAt(next);
+ prev = next + 1;
+
+ if (ch == '%')
+ {
+ out.append('%');
+ prev = next + 1;
Review Comment:
Mostly to make the exception safety built-in and exercised as normal, rather
than an after thought we don't properly exercise.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]