You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by xk...@apache.org on 2019/06/07 21:32:20 UTC
[hadoop] branch branch-3.0 updated: HADOOP-16345. Fix a potential
NPE when instantiating FairCallQueue metrics. Contributed by Erik Krogen.
This is an automated email from the ASF dual-hosted git repository.
xkrogen pushed a commit to branch branch-3.0
in repository https://gitbox.apache.org/repos/asf/hadoop.git
The following commit(s) were added to refs/heads/branch-3.0 by this push:
new d43219c HADOOP-16345. Fix a potential NPE when instantiating FairCallQueue metrics. Contributed by Erik Krogen.
d43219c is described below
commit d43219c21d830b198710f70c16ea880302f88d77
Author: Erik Krogen <ek...@linkedin.com>
AuthorDate: Fri Jun 7 14:20:44 2019 -0700
HADOOP-16345. Fix a potential NPE when instantiating FairCallQueue metrics. Contributed by Erik Krogen.
(cherry-picked from 76b94c274fe9775efcfd51c676d80c88a4f7fdb9)
(cherry-picked from f607efd1950211f85eb571564b774184f8fa1687)
(cherry-picked from cf3c1b9ffc8cfce2e2248a1c1600bd34ff412933)
---
.../main/java/org/apache/hadoop/ipc/FairCallQueue.java | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/FairCallQueue.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/FairCallQueue.java
index 1431254..bfbb8bc 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/FairCallQueue.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/FairCallQueue.java
@@ -377,9 +377,21 @@ public class FairCallQueue<E extends Schedulable> extends AbstractQueue<E>
this.revisionNumber++;
}
+ /**
+ * Fetch the current call queue from the weak reference delegate. If there
+ * is no delegate, or the delegate is empty, this will return null.
+ */
+ private FairCallQueue<? extends Schedulable> getCallQueue() {
+ WeakReference<FairCallQueue<? extends Schedulable>> ref = this.delegate;
+ if (ref == null) {
+ return null;
+ }
+ return ref.get();
+ }
+
@Override
public int[] getQueueSizes() {
- FairCallQueue<? extends Schedulable> obj = this.delegate.get();
+ FairCallQueue<? extends Schedulable> obj = getCallQueue();
if (obj == null) {
return new int[]{};
}
@@ -389,7 +401,7 @@ public class FairCallQueue<E extends Schedulable> extends AbstractQueue<E>
@Override
public long[] getOverflowedCalls() {
- FairCallQueue<? extends Schedulable> obj = this.delegate.get();
+ FairCallQueue<? extends Schedulable> obj = getCallQueue();
if (obj == null) {
return new long[]{};
}
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org