Skip to content

Commit

Permalink
spotbugs
Browse files Browse the repository at this point in the history
  • Loading branch information
trask committed Jul 28, 2022
1 parent 8f29d55 commit a837346
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 4 additions & 0 deletions legacy-sdk/core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@ plugins {
}

base.archivesName.set("applicationinsights-core")

dependencies {
compileOnly("com.github.spotbugs:spotbugs-annotations")
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@

package com.microsoft.applicationinsights.internal.util;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.concurrent.ThreadLocalRandom;

public class LocalStringsUtils {
private LocalStringsUtils() {} // no instances please

/**
* Determine whether a string is null or empty.
Expand All @@ -38,6 +38,9 @@ public static boolean isNullOrEmpty(String value) {
return value == null || value.isEmpty();
}

@SuppressFBWarnings(
value = "SECPR", // Predictable pseudorandom number generator
justification = "Predictable random is ok for telemetry id")
public static String generateRandomIntegerId() {
// avoid using Math.abs(rand.nextLong()) because Math.abs(Long.MIN_VALUE) is negative
long rand = ThreadLocalRandom.current().nextLong(Long.MAX_VALUE);
Expand All @@ -47,4 +50,6 @@ public static String generateRandomIntegerId() {
public static DateFormat getDateFormatter() {
return new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZZ");
}

private LocalStringsUtils() {}
}

0 comments on commit a837346

Please sign in to comment.