diff --git a/server/src/main/java/io/druid/client/DruidDataSource.java b/server/src/main/java/io/druid/client/DruidDataSource.java index ab6ba436551..9b68daf7ad3 100644 --- a/server/src/main/java/io/druid/client/DruidDataSource.java +++ b/server/src/main/java/io/druid/client/DruidDataSource.java @@ -114,19 +114,23 @@ public class DruidDataSource @Override public String toString() { - return "DruidDataSource{" + - "properties=" + properties + - ", partitions=" + segmentsHolder.toString() + - '}'; + synchronized (lock) { + return "DruidDataSource{" + + "properties=" + properties + + ", partitions=" + segmentsHolder.toString() + + '}'; + } } public ImmutableDruidDataSource toImmutableDruidDataSource() { - return new ImmutableDruidDataSource( - name, - ImmutableMap.copyOf(properties), - ImmutableMap.copyOf(partitionNames), - ImmutableSet.copyOf(segmentsHolder) - ); + synchronized (lock) { + return new ImmutableDruidDataSource( + name, + ImmutableMap.copyOf(properties), + ImmutableMap.copyOf(partitionNames), + ImmutableSet.copyOf(segmentsHolder) + ); + } } }