Skip to content

Commit

Permalink
Rename shallowCopy to newConcurrentHashMap
Browse files Browse the repository at this point in the history
  • Loading branch information
maciejwalkowiak committed May 12, 2021
1 parent 9057338 commit 32ae92f
Show file tree
Hide file tree
Showing 13 changed files with 24 additions and 23 deletions.
2 changes: 1 addition & 1 deletion sentry/api/sentry.api
Original file line number Diff line number Diff line change
Expand Up @@ -1854,8 +1854,8 @@ public final class io/sentry/util/ApplyScopeUtils {
public final class io/sentry/util/CollectionUtils {
public static fun filterMapEntries (Ljava/util/Map;Lio/sentry/util/CollectionUtils$Predicate;)Ljava/util/Map;
public static fun newArrayList (Ljava/util/List;)Ljava/util/List;
public static fun newConcurrentHashMap (Ljava/util/Map;)Ljava/util/Map;
public static fun newHashMap (Ljava/util/Map;)Ljava/util/Map;
public static fun shallowCopy (Ljava/util/Map;)Ljava/util/Map;
public static fun size (Ljava/lang/Iterable;)I
}

Expand Down
4 changes: 2 additions & 2 deletions sentry/src/main/java/io/sentry/Breadcrumb.java
Original file line number Diff line number Diff line change
Expand Up @@ -247,11 +247,11 @@ Map<String, Object> getUnknown() {
public @NotNull Breadcrumb clone() throws CloneNotSupportedException {
final Breadcrumb clone = (Breadcrumb) super.clone();

final Map<String, Object> dataCopy = CollectionUtils.shallowCopy(this.data);
final Map<String, Object> dataCopy = CollectionUtils.newConcurrentHashMap(this.data);
if (dataCopy != null) {
clone.data = dataCopy;
}
clone.unknown = CollectionUtils.shallowCopy(unknown);
clone.unknown = CollectionUtils.newConcurrentHashMap(unknown);

final SentryLevel levelRef = level;
clone.level =
Expand Down
2 changes: 1 addition & 1 deletion sentry/src/main/java/io/sentry/SpanContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ void setSampled(final @Nullable Boolean sampled) {
@Override
public SpanContext clone() throws CloneNotSupportedException {
final SpanContext clone = (SpanContext) super.clone();
final Map<String, String> copiedTags = CollectionUtils.shallowCopy(this.tags);
final Map<String, String> copiedTags = CollectionUtils.newConcurrentHashMap(this.tags);
if (copiedTags != null) {
clone.tags = copiedTags;
}
Expand Down
2 changes: 1 addition & 1 deletion sentry/src/main/java/io/sentry/protocol/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public void acceptUnknownProperties(@NotNull Map<String, Object> unknown) {
public @NotNull App clone() throws CloneNotSupportedException {
final App clone = (App) super.clone();

clone.unknown = CollectionUtils.shallowCopy(unknown);
clone.unknown = CollectionUtils.newConcurrentHashMap(unknown);

return clone;
}
Expand Down
2 changes: 1 addition & 1 deletion sentry/src/main/java/io/sentry/protocol/Browser.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public void acceptUnknownProperties(final @NotNull Map<String, Object> unknown)
public @NotNull Browser clone() throws CloneNotSupportedException {
final Browser clone = (Browser) super.clone();

clone.unknown = CollectionUtils.shallowCopy(unknown);
clone.unknown = CollectionUtils.newConcurrentHashMap(unknown);

return clone;
}
Expand Down
2 changes: 1 addition & 1 deletion sentry/src/main/java/io/sentry/protocol/Device.java
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ public void acceptUnknownProperties(final @NotNull Map<String, Object> unknown)
final TimeZone timezoneRef = this.timezone;
clone.timezone = timezoneRef != null ? (TimeZone) timezoneRef.clone() : null;

clone.unknown = CollectionUtils.shallowCopy(unknown);
clone.unknown = CollectionUtils.newConcurrentHashMap(unknown);

return clone;
}
Expand Down
2 changes: 1 addition & 1 deletion sentry/src/main/java/io/sentry/protocol/Gpu.java
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public void acceptUnknownProperties(final @NotNull Map<String, Object> unknown)
public @NotNull Gpu clone() throws CloneNotSupportedException {
final Gpu clone = (Gpu) super.clone();

clone.unknown = CollectionUtils.shallowCopy(unknown);
clone.unknown = CollectionUtils.newConcurrentHashMap(unknown);

return clone;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public void acceptUnknownProperties(final @NotNull Map<String, Object> unknown)
public @NotNull OperatingSystem clone() throws CloneNotSupportedException {
final OperatingSystem clone = (OperatingSystem) super.clone();

clone.unknown = CollectionUtils.shallowCopy(unknown);
clone.unknown = CollectionUtils.newConcurrentHashMap(unknown);

return clone;
}
Expand Down
14 changes: 7 additions & 7 deletions sentry/src/main/java/io/sentry/protocol/Request.java
Original file line number Diff line number Diff line change
Expand Up @@ -144,23 +144,23 @@ public void setCookies(final @Nullable String cookies) {
}

public void setHeaders(final @Nullable Map<String, String> headers) {
this.headers = CollectionUtils.shallowCopy(headers);
this.headers = CollectionUtils.newConcurrentHashMap(headers);
}

public @Nullable Map<String, String> getEnvs() {
return env;
}

public void setEnvs(final @Nullable Map<String, String> env) {
this.env = CollectionUtils.shallowCopy(env);
this.env = CollectionUtils.newConcurrentHashMap(env);
}

public @Nullable Map<String, String> getOthers() {
return other;
}

public void setOthers(final @Nullable Map<String, String> other) {
this.other = CollectionUtils.shallowCopy(other);
this.other = CollectionUtils.newConcurrentHashMap(other);
}

/**
Expand Down Expand Up @@ -190,10 +190,10 @@ public void acceptUnknownProperties(final @NotNull Map<String, Object> unknown)
public @NotNull Request clone() throws CloneNotSupportedException {
final Request clone = (Request) super.clone();

clone.headers = CollectionUtils.shallowCopy(headers);
clone.env = CollectionUtils.shallowCopy(env);
clone.other = CollectionUtils.shallowCopy(other);
clone.unknown = CollectionUtils.shallowCopy(unknown);
clone.headers = CollectionUtils.newConcurrentHashMap(headers);
clone.env = CollectionUtils.newConcurrentHashMap(env);
clone.other = CollectionUtils.newConcurrentHashMap(other);
clone.unknown = CollectionUtils.newConcurrentHashMap(unknown);

return clone;
}
Expand Down
2 changes: 1 addition & 1 deletion sentry/src/main/java/io/sentry/protocol/SentryRuntime.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public void acceptUnknownProperties(final @NotNull Map<String, Object> unknown)
public @NotNull SentryRuntime clone() throws CloneNotSupportedException {
final SentryRuntime clone = (SentryRuntime) super.clone();

clone.unknown = CollectionUtils.shallowCopy(unknown);
clone.unknown = CollectionUtils.newConcurrentHashMap(unknown);

return clone;
}
Expand Down
2 changes: 1 addition & 1 deletion sentry/src/main/java/io/sentry/protocol/SentrySpan.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public SentrySpan(final @NotNull Span span) {
this.parentSpanId = span.getParentSpanId();
this.traceId = span.getTraceId();
this.status = span.getStatus();
final Map<String, String> tagsCopy = CollectionUtils.shallowCopy(span.getTags());
final Map<String, String> tagsCopy = CollectionUtils.newConcurrentHashMap(span.getTags());
this.tags = tagsCopy != null ? tagsCopy : new ConcurrentHashMap<>();
this.timestamp = span.getTimestamp();
this.startTimestamp = span.getStartTimestamp();
Expand Down
6 changes: 3 additions & 3 deletions sentry/src/main/java/io/sentry/protocol/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public void setIpAddress(final @Nullable String ipAddress) {
* @param other the other user related data..
*/
public void setOthers(final @Nullable Map<String, @NotNull String> other) {
this.other = CollectionUtils.shallowCopy(other);
this.other = CollectionUtils.newConcurrentHashMap(other);
}

/**
Expand Down Expand Up @@ -160,8 +160,8 @@ public void acceptUnknownProperties(final @NotNull Map<String, Object> unknown)
public @NotNull User clone() throws CloneNotSupportedException {
final User clone = (User) super.clone();

clone.other = CollectionUtils.shallowCopy(other);
clone.unknown = CollectionUtils.shallowCopy(unknown);
clone.other = CollectionUtils.newConcurrentHashMap(other);
clone.unknown = CollectionUtils.newConcurrentHashMap(unknown);

return clone;
}
Expand Down
5 changes: 3 additions & 2 deletions sentry/src/main/java/io/sentry/util/CollectionUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,15 @@ public static int size(final @NotNull Iterable<?> data) {
}

/**
* Creates a shallow copy of map given by parameter.
* Creates a new {@link ConcurrentHashMap} as a shallow copy of map given by parameter.
*
* @param map the map to copy
* @param <K> the type of map keys
* @param <V> the type of map values
* @return the shallow copy of map
*/
public static <K, V> @Nullable Map<K, @NotNull V> shallowCopy(@Nullable Map<K, @NotNull V> map) {
public static <K, V> @Nullable Map<K, @NotNull V> newConcurrentHashMap(
@Nullable Map<K, @NotNull V> map) {
if (map != null) {
return new ConcurrentHashMap<>(map);
} else {
Expand Down

0 comments on commit 32ae92f

Please sign in to comment.