Skip to content

Commit

Permalink
wrapped with try/finally block. removed static import
Browse files Browse the repository at this point in the history
  • Loading branch information
videnkz committed Dec 5, 2023
1 parent bb6da3d commit 58ff6e6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,13 @@ public void completed(T result) {
try {
finishSpan(null);
} finally {
if (delegate != null) {
delegate.completed(result);
try {
if (delegate != null) {
delegate.completed(result);
}
} finally {
helper.recycle(this);
}
helper.recycle(this);
}
}

Expand All @@ -66,10 +69,13 @@ public void failed(Exception ex) {
try {
finishSpan(ex);
} finally {
if (delegate != null) {
delegate.failed(ex);
try {
if (delegate != null) {
delegate.failed(ex);
}
} finally {
helper.recycle(this);
}
helper.recycle(this);
}
}

Expand All @@ -87,10 +93,13 @@ public void cancelled() {
try {
finishSpan(null);
} finally {
if (delegate != null) {
delegate.cancelled();
try {
if (delegate != null) {
delegate.cancelled();
}
} finally {
helper.recycle(this);
}
helper.recycle(this);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import org.apache.hc.core5.concurrent.FutureCallback;
import org.apache.hc.core5.http.ProtocolException;
import org.apache.hc.core5.net.URIAuthority;
import org.assertj.core.api.Assertions;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
Expand Down Expand Up @@ -103,7 +102,7 @@ public void testSpanFinishOnEarlyException() throws Exception {
reporter.resetChecks();
}
assertThat(reporter.getFirstSpan(500)).isNotNull();
Assertions.assertThat(reporter.getSpans()).hasSize(1);
assertThat(reporter.getSpans()).hasSize(1);
}

@Test
Expand All @@ -117,7 +116,7 @@ public void testSpanFinishWithIllegalProtocol() throws Exception {
assertThat(firstSpan).isNotNull();
assertThat(firstSpan.getOutcome()).isEqualTo(Outcome.FAILURE);
assertThat(firstSpan.getNameAsString()).isEqualTo("GET localhost");
Assertions.assertThat(reporter.getSpans()).hasSize(1);
assertThat(reporter.getSpans()).hasSize(1);
}

@Test
Expand All @@ -138,7 +137,7 @@ public void testSpanFinishWithIllegalUrl() throws Exception {
assertThat(firstSpan).isNotNull();
assertThat(firstSpan.getOutcome()).isEqualTo(Outcome.FAILURE);
assertThat(firstSpan.getNameAsString()).isEqualTo("GET ");
Assertions.assertThat(reporter.getSpans()).hasSize(1);
assertThat(reporter.getSpans()).hasSize(1);
}

/**
Expand Down

0 comments on commit 58ff6e6

Please sign in to comment.