Skip to content

Commit

Permalink
check for null before closing delegates of instrumented clients (#163)
Browse files Browse the repository at this point in the history
  • Loading branch information
radai-rosenblatt authored Jan 12, 2020
1 parent 1f981de commit ab76279
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -707,9 +707,12 @@ public void close() {
return;
}
try {
delegate.close();
Consumer<K, V> delegate = this.delegate;
if (delegate != null) {
delegate.close();
}
} finally {
delegate = null;
this.delegate = null;
closeMdsClient();
}
}
Expand All @@ -723,9 +726,12 @@ public void close(long timeout, TimeUnit unit) {
return;
}
try {
delegate.close(timeout, unit);
Consumer<K, V> delegate = this.delegate;
if (delegate != null) {
delegate.close(timeout, unit);
}
} finally {
delegate = null;
this.delegate = null;
closeMdsClient();
}
}
Expand All @@ -738,9 +744,12 @@ public void close(Duration timeout) {
return;
}
try {
delegate.close(timeout);
Consumer<K, V> delegate = this.delegate;
if (delegate != null) {
delegate.close(timeout);
}
} finally {
delegate = null;
this.delegate = null;
closeMdsClient();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -407,9 +407,12 @@ public void close() {
return;
}
try {
delegate.close();
Producer<K, V> delegate = this.delegate;
if (delegate != null) {
delegate.close();
}
} finally {
delegate = null;
this.delegate = null;
closeMdsClient();
}
}
Expand All @@ -426,10 +429,13 @@ public void close(Duration timeout) {
return;
}
try {
//TODO - fix back after bumping up kafka
delegate.close(timeout.toMillis(), TimeUnit.MILLISECONDS);
Producer<K, V> delegate = this.delegate;
if (delegate != null) {
//TODO - fix back after bumping up kafka
delegate.close(timeout.toMillis(), TimeUnit.MILLISECONDS);
}
} finally {
delegate = null;
this.delegate = null;
closeMdsClient();
}
}
Expand Down

0 comments on commit ab76279

Please sign in to comment.