Skip to content

Commit 9373481

Browse files
committed
Review fixes for camel-2.20:javaagent
Automated code review of instrumentation/camel-2.20/javaagent.
1 parent 6809907 commit 9373481

4 files changed

Lines changed: 16 additions & 6 deletions

File tree

instrumentation/camel-2.20/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camel/v2_20/ActiveContextManager.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,11 @@ private static class ContextWithScope {
8484
private final CamelRequest request;
8585
@Nullable private final Scope scope;
8686

87-
ContextWithScope(ContextWithScope parent, Context context, CamelRequest request, Scope scope) {
87+
ContextWithScope(
88+
@Nullable ContextWithScope parent,
89+
@Nullable Context context,
90+
CamelRequest request,
91+
@Nullable Scope scope) {
8892
this.parent = parent;
8993
this.context = context;
9094
this.request = request;
@@ -97,11 +101,12 @@ static ContextWithScope activate(
97101
return new ContextWithScope(parent, context, request, scope);
98102
}
99103

104+
@Nullable
100105
ContextWithScope getParent() {
101106
return parent;
102107
}
103108

104-
void deactivate(Exception exception) {
109+
void deactivate(@Nullable Exception exception) {
105110
if (scope == null) {
106111
return;
107112
}

instrumentation/camel-2.20/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camel/v2_20/decorators/DecoratorRegistry.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212

1313
public class DecoratorRegistry {
1414

15-
private static final SpanDecorator DEFAULT = new BaseSpanDecorator();
16-
private static final Map<String, SpanDecorator> DECORATORS = loadDecorators();
15+
private static final SpanDecorator defaultDecorator = new BaseSpanDecorator();
16+
private static final Map<String, SpanDecorator> decorators = loadDecorators();
1717

1818
private static Map<String, SpanDecorator> loadDecorators() {
1919
Map<String, SpanDecorator> result = new HashMap<>();
@@ -64,6 +64,6 @@ private static Map<String, SpanDecorator> loadDecorators() {
6464

6565
public SpanDecorator forComponent(String component) {
6666

67-
return DECORATORS.getOrDefault(component, DEFAULT);
67+
return decorators.getOrDefault(component, defaultDecorator);
6868
}
6969
}

instrumentation/camel-2.20/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/camel/v2_20/decorators/RestSpanDecorator.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,15 @@
2828
import java.io.UnsupportedEncodingException;
2929
import java.net.URLDecoder;
3030
import java.util.logging.Logger;
31+
import javax.annotation.Nullable;
3132
import org.apache.camel.Endpoint;
3233
import org.apache.camel.Exchange;
3334

3435
class RestSpanDecorator extends HttpSpanDecorator {
3536

3637
private static final Logger logger = Logger.getLogger(RestSpanDecorator.class.getName());
3738

39+
@Nullable
3840
@Override
3941
protected String getPath(Exchange exchange, Endpoint endpoint) {
4042
String endpointUri = endpoint.getEndpointUri();

instrumentation/camel-2.20/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/camel/v2_20/TwoServicesWithDirectClientCamelTest.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,11 @@ protected void setUp() {
7777
}
7878

7979
@AfterAll
80-
protected void cleanUp() {
80+
protected void cleanUp() throws Exception {
8181
cleanupServer();
82+
if (clientContext != null) {
83+
clientContext.stop();
84+
}
8285
}
8386

8487
void createAndStartClient() throws Exception {

0 commit comments

Comments
 (0)