HBASE-4386 Fix a potential NPE in TaskMonitor

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1179479 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Todd Lipcon 2011-10-06 00:16:45 +00:00
parent ead9159ecd
commit 3d156a5a24
2 changed files with 8 additions and 3 deletions

View File

@ -339,6 +339,7 @@ Release 0.92.0 - Unreleased
HBASE-4494 AvroServer:: get fails with NPE on a non-existent row HBASE-4494 AvroServer:: get fails with NPE on a non-existent row
(Kay Kay) (Kay Kay)
HBASE-4481 TestMergeTool failed in 0.92 build 20 HBASE-4481 TestMergeTool failed in 0.92 build 20
HBASE-4386 Fix a potential NPE in TaskMonitor (todd)
TESTS TESTS
HBASE-4450 test for number of blocks read: to serve as baseline for expected HBASE-4450 test for number of blocks read: to serve as baseline for expected

View File

@ -72,7 +72,9 @@ public class TaskMonitor {
new Class<?>[] { MonitoredTask.class }, new Class<?>[] { MonitoredTask.class },
new PassthroughInvocationHandler<MonitoredTask>(stat)); new PassthroughInvocationHandler<MonitoredTask>(stat));
TaskAndWeakRefPair pair = new TaskAndWeakRefPair(stat, proxy); TaskAndWeakRefPair pair = new TaskAndWeakRefPair(stat, proxy);
synchronized (this) {
tasks.add(pair); tasks.add(pair);
}
return proxy; return proxy;
} }
@ -84,7 +86,9 @@ public class TaskMonitor {
new Class<?>[] { MonitoredRPCHandler.class }, new Class<?>[] { MonitoredRPCHandler.class },
new PassthroughInvocationHandler<MonitoredRPCHandler>(stat)); new PassthroughInvocationHandler<MonitoredRPCHandler>(stat));
TaskAndWeakRefPair pair = new TaskAndWeakRefPair(stat, proxy); TaskAndWeakRefPair pair = new TaskAndWeakRefPair(stat, proxy);
synchronized (this) {
tasks.add(pair); tasks.add(pair);
}
return proxy; return proxy;
} }
@ -142,7 +146,7 @@ public class TaskMonitor {
public void dumpAsText(PrintWriter out) { public void dumpAsText(PrintWriter out) {
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
List<MonitoredTask> tasks = TaskMonitor.get().getTasks(); List<MonitoredTask> tasks = getTasks();
for (MonitoredTask task : tasks) { for (MonitoredTask task : tasks) {
out.println("Task: " + task.getDescription()); out.println("Task: " + task.getDescription());
out.println("Status: " + task.getState() + ":" + task.getStatus()); out.println("Status: " + task.getState() + ":" + task.getStatus());