Fix incorrect use of ReentrantLock in GRPCExporter (#8177)

fix that an imse (IllegalMonitorStateException) exception will be thrown when finally releasing the lock when an exception occurs in lock() locking
This commit is contained in:
xuxiawei 2021-11-24 12:02:20 +08:00 committed by GitHub
parent 8436135dc9
commit 7cf82f318e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -104,8 +104,8 @@ public class GRPCExporter extends MetricFormatter implements MetricValuesExportS
public void fetchSubscriptionList() {
final long currentTimeMillis = System.currentTimeMillis();
if (currentTimeMillis - lastFetchTimestamp > FETCH_SUBSCRIPTION_PERIOD) {
fetchListLock.lock();
try {
fetchListLock.lock();
if (currentTimeMillis - lastFetchTimestamp > FETCH_SUBSCRIPTION_PERIOD) {
lastFetchTimestamp = currentTimeMillis;
SubscriptionsResp subscription = blockingStub.withDeadlineAfter(10, TimeUnit.SECONDS)