提交 f9995103 编写于 作者: K kohsuke

fixed data race

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@11286 71c3de6d-444a-0410-be80-ed276b4c234a
上级 bab29034
......@@ -14,7 +14,7 @@ public class RingBufferLogHandler extends Handler {
private int start = 0;
private final LogRecord[] records;
private int size = 0;
private volatile int size = 0;
public RingBufferLogHandler() {
this(256);
......@@ -44,7 +44,9 @@ public class RingBufferLogHandler extends Handler {
return new AbstractList<LogRecord>() {
public LogRecord get(int index) {
// flip the order
return records[(start+(size-(index+1)))%records.length];
synchronized (RingBufferLogHandler.this) {
return records[(start+(size-(index+1)))%records.length];
}
}
public int size() {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册