Skip to content
This repository has been archived by the owner on Jul 1, 2022. It is now read-only.

Fix repeated resolving of sender in configuration #555

Merged
merged 3 commits into from
Sep 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions jaeger-core/src/main/java/io/jaegertracing/Configuration.java
Original file line number Diff line number Diff line change
Expand Up @@ -631,12 +631,10 @@ public SenderConfiguration withAuthPassword(String password) {
* @return the sender passed via the constructor or a properly configured sender
*/
public Sender getSender() {
// if we have a sender, that's the one we return
if (null != sender) {
return sender;
if (sender == null) {
sender = SenderResolver.resolve(this);
}

return SenderResolver.resolve(this);
return sender;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import io.jaegertracing.Configuration.CodecConfiguration;
import io.jaegertracing.Configuration.ReporterConfiguration;
import io.jaegertracing.Configuration.SamplerConfiguration;
import io.jaegertracing.Configuration.SenderConfiguration;
import io.jaegertracing.internal.JaegerSpanContext;
import io.jaegertracing.internal.JaegerTracer;
import io.jaegertracing.internal.metrics.InMemoryMetricsFactory;
Expand Down Expand Up @@ -183,6 +184,12 @@ public void testSenderBackwardsCompatibilityGettingAgentHostAndPort() {
.getSenderConfiguration().getAgentPort());
}

@Test
public void testSenderInstanceIsCached() {
SenderConfiguration senderConfiguration = SenderConfiguration.fromEnv();
assertEquals(senderConfiguration.getSender(), senderConfiguration.getSender());
}

@Test
public void testPropagationB3Only() {
System.setProperty(Configuration.JAEGER_PROPAGATION, "b3");
Expand Down