提交 799d182a 编写于 作者: J JessYan

Fix ArrayIndexOutOfBoundsException on DefaultFormatPrinter

上级 1ec02987
...@@ -176,16 +176,21 @@ public class DefaultFormatPrinter implements FormatPrinter { ...@@ -176,16 +176,21 @@ public class DefaultFormatPrinter implements FormatPrinter {
} }
} }
private static int last; private static ThreadLocal<Integer> last = new ThreadLocal<Integer>() {
@Override
protected Integer initialValue() {
return 0;
}
};
private static final String[] ARMS = new String[]{"-A-", "-R-", "-M-", "-S-"}; private static final String[] ARMS = new String[]{"-A-", "-R-", "-M-", "-S-"};
private static String computeKey() { public static String computeKey() {
if (last == 4) { if (last.get() >= 4) {
last = 0; last.set(0);
} }
String s = String.valueOf(ARMS[last]); String s = ARMS[last.get()];
last++; last.set(last.get() + 1);
return s; return s;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册