rename `newBuilder()` to `builder()` (#4407)
* rename `newBuilder()` to `builder()` * code format
This commit is contained in:
parent
22ea557c41
commit
6d9e3618d3
|
@ -12,7 +12,7 @@ import javax.annotation.Nullable;
|
|||
public interface Cache<K, V> {
|
||||
|
||||
/** Returns a new {@link CacheBuilder} to configure a {@link Cache}. */
|
||||
static CacheBuilder newBuilder() {
|
||||
static CacheBuilder builder() {
|
||||
return new CacheBuilder();
|
||||
}
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ public abstract class Config {
|
|||
@Nullable private static volatile Config instance = null;
|
||||
|
||||
/** Start building a new {@link Config} instance. */
|
||||
public static ConfigBuilder newBuilder() {
|
||||
public static ConfigBuilder builder() {
|
||||
return new ConfigBuilder();
|
||||
}
|
||||
|
||||
|
@ -68,7 +68,7 @@ public abstract class Config {
|
|||
// this should only happen in library instrumentation
|
||||
//
|
||||
// no need to synchronize because worst case is creating instance more than once
|
||||
instance = newBuilder().readEnvironmentVariables().readSystemProperties().build();
|
||||
instance = builder().readEnvironmentVariables().readSystemProperties().build();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ public final class SqlStatementSanitizer {
|
|||
private static final SupportabilityMetrics supportability = SupportabilityMetrics.instance();
|
||||
|
||||
private static final Cache<String, SqlStatementInfo> sqlToStatementInfoCache =
|
||||
Cache.newBuilder().setMaximumSize(1000).build();
|
||||
Cache.builder().setMaximumSize(1000).build();
|
||||
|
||||
public static SqlStatementInfo sanitize(@Nullable String statement) {
|
||||
if (!isStatementSanitizationEnabled() || statement == null) {
|
||||
|
|
|
@ -12,9 +12,9 @@ import java.util.List;
|
|||
final class HttpHeaderAttributes {
|
||||
|
||||
private static final Cache<String, AttributeKey<List<String>>> requestKeysCache =
|
||||
Cache.newBuilder().setMaximumSize(32).build();
|
||||
Cache.builder().setMaximumSize(32).build();
|
||||
private static final Cache<String, AttributeKey<List<String>>> responseKeysCache =
|
||||
Cache.newBuilder().setMaximumSize(32).build();
|
||||
Cache.builder().setMaximumSize(32).build();
|
||||
|
||||
static AttributeKey<List<String>> requestAttributeKey(String headerName) {
|
||||
return requestKeysCache.computeIfAbsent(headerName, n -> createKey("request", n));
|
||||
|
|
|
@ -55,7 +55,7 @@ public final class RuntimeVirtualFieldSupplier {
|
|||
}
|
||||
|
||||
private static final class CacheBasedVirtualField<T, F> extends VirtualField<T, F> {
|
||||
private final Cache<T, F> cache = Cache.newBuilder().setWeakKeys().build();
|
||||
private final Cache<T, F> cache = Cache.builder().setWeakKeys().build();
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
|
|
|
@ -18,7 +18,7 @@ class CacheTest {
|
|||
class StrongKeys {
|
||||
@Test
|
||||
void unbounded() {
|
||||
Cache<String, String> cache = Cache.newBuilder().build();
|
||||
Cache<String, String> cache = Cache.builder().build();
|
||||
|
||||
assertThat(cache.computeIfAbsent("bear", unused -> "roar")).isEqualTo("roar");
|
||||
cache.remove("bear");
|
||||
|
@ -40,7 +40,7 @@ class CacheTest {
|
|||
|
||||
@Test
|
||||
void bounded() {
|
||||
Cache<String, String> cache = Cache.newBuilder().setMaximumSize(1).build();
|
||||
Cache<String, String> cache = Cache.builder().setMaximumSize(1).build();
|
||||
|
||||
assertThat(cache.computeIfAbsent("bear", unused -> "roar")).isEqualTo("roar");
|
||||
cache.remove("bear");
|
||||
|
@ -65,7 +65,7 @@ class CacheTest {
|
|||
class WeakKeys {
|
||||
@Test
|
||||
void unbounded() {
|
||||
Cache<String, String> cache = Cache.newBuilder().setWeakKeys().build();
|
||||
Cache<String, String> cache = Cache.builder().setWeakKeys().build();
|
||||
|
||||
assertThat(cache.computeIfAbsent("bear", unused -> "roar")).isEqualTo("roar");
|
||||
cache.remove("bear");
|
||||
|
@ -99,7 +99,7 @@ class CacheTest {
|
|||
|
||||
@Test
|
||||
void bounded() {
|
||||
Cache<String, String> cache = Cache.newBuilder().setWeakKeys().setMaximumSize(1).build();
|
||||
Cache<String, String> cache = Cache.builder().setWeakKeys().setMaximumSize(1).build();
|
||||
|
||||
assertThat(cache.computeIfAbsent("bear", unused -> "roar")).isEqualTo("roar");
|
||||
cache.remove("bear");
|
||||
|
|
|
@ -17,7 +17,7 @@ class PatchCaffeineTest {
|
|||
void cleanupNotForkJoinTask() {
|
||||
AtomicReference<AssertionError> errorRef = new AtomicReference<>();
|
||||
Cache<String, String> cache =
|
||||
Cache.newBuilder()
|
||||
Cache.builder()
|
||||
.setExecutor(
|
||||
task -> {
|
||||
try {
|
||||
|
|
|
@ -33,7 +33,7 @@ import org.junit.jupiter.params.provider.ArgumentsSource;
|
|||
class ConfigTest {
|
||||
@Test
|
||||
void shouldGetString() {
|
||||
Config config = Config.newBuilder().addProperty("prop.string", "some text").build();
|
||||
Config config = Config.builder().addProperty("prop.string", "some text").build();
|
||||
|
||||
assertEquals("some text", config.getString("prop.string"));
|
||||
assertEquals("some text", config.getString("prop.string", "default"));
|
||||
|
@ -43,7 +43,7 @@ class ConfigTest {
|
|||
|
||||
@Test
|
||||
void shouldGetBoolean() {
|
||||
Config config = Config.newBuilder().addProperty("prop.boolean", "true").build();
|
||||
Config config = Config.builder().addProperty("prop.boolean", "true").build();
|
||||
|
||||
assertTrue(config.getBoolean("prop.boolean"));
|
||||
assertTrue(config.getBoolean("prop.boolean", false));
|
||||
|
@ -54,10 +54,7 @@ class ConfigTest {
|
|||
@Test
|
||||
void shouldGetInt() {
|
||||
Config config =
|
||||
Config.newBuilder()
|
||||
.addProperty("prop.int", "12")
|
||||
.addProperty("prop.wrong", "twelve")
|
||||
.build();
|
||||
Config.builder().addProperty("prop.int", "12").addProperty("prop.wrong", "twelve").build();
|
||||
|
||||
assertEquals(12, config.getInt("prop.int"));
|
||||
assertEquals(12, config.getInt("prop.int", 1000));
|
||||
|
@ -68,7 +65,7 @@ class ConfigTest {
|
|||
|
||||
@Test
|
||||
void shouldFailOnInvalidInt() {
|
||||
Config config = Config.newBuilder().addProperty("prop.wrong", "twelve").build();
|
||||
Config config = Config.builder().addProperty("prop.wrong", "twelve").build();
|
||||
|
||||
assertThrows(ConfigParsingException.class, () -> config.getInt("prop.wrong"));
|
||||
}
|
||||
|
@ -76,10 +73,7 @@ class ConfigTest {
|
|||
@Test
|
||||
void shouldGetLong() {
|
||||
Config config =
|
||||
Config.newBuilder()
|
||||
.addProperty("prop.long", "12")
|
||||
.addProperty("prop.wrong", "twelve")
|
||||
.build();
|
||||
Config.builder().addProperty("prop.long", "12").addProperty("prop.wrong", "twelve").build();
|
||||
|
||||
assertEquals(12, config.getLong("prop.long"));
|
||||
assertEquals(12, config.getLong("prop.long", 1000));
|
||||
|
@ -90,7 +84,7 @@ class ConfigTest {
|
|||
|
||||
@Test
|
||||
void shouldFailOnInvalidLong() {
|
||||
Config config = Config.newBuilder().addProperty("prop.wrong", "twelve").build();
|
||||
Config config = Config.builder().addProperty("prop.wrong", "twelve").build();
|
||||
|
||||
assertThrows(ConfigParsingException.class, () -> config.getLong("prop.wrong"));
|
||||
}
|
||||
|
@ -98,7 +92,7 @@ class ConfigTest {
|
|||
@Test
|
||||
void shouldGetDouble() {
|
||||
Config config =
|
||||
Config.newBuilder()
|
||||
Config.builder()
|
||||
.addProperty("prop.double", "12.345")
|
||||
.addProperty("prop.wrong", "twelve point something")
|
||||
.build();
|
||||
|
@ -112,7 +106,7 @@ class ConfigTest {
|
|||
|
||||
@Test
|
||||
void shouldFailOnInvalidDouble() {
|
||||
Config config = Config.newBuilder().addProperty("prop.wrong", "twelve point something").build();
|
||||
Config config = Config.builder().addProperty("prop.wrong", "twelve point something").build();
|
||||
|
||||
assertThrows(ConfigParsingException.class, () -> config.getDouble("prop.wrong"));
|
||||
}
|
||||
|
@ -120,7 +114,7 @@ class ConfigTest {
|
|||
@Test
|
||||
void shouldGetDuration_defaultUnit() {
|
||||
Config config =
|
||||
Config.newBuilder()
|
||||
Config.builder()
|
||||
.addProperty("prop.duration", "5000")
|
||||
.addProperty("prop.wrong", "hundred days")
|
||||
.build();
|
||||
|
@ -134,32 +128,32 @@ class ConfigTest {
|
|||
|
||||
@Test
|
||||
void shouldFailOnInvalidDuration() {
|
||||
Config config = Config.newBuilder().addProperty("prop.wrong", "hundred days").build();
|
||||
Config config = Config.builder().addProperty("prop.wrong", "hundred days").build();
|
||||
|
||||
assertThrows(ConfigParsingException.class, () -> config.getDuration("prop.wrong"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldGetDuration_variousUnits() {
|
||||
Config config = Config.newBuilder().addProperty("prop.duration", "100ms").build();
|
||||
Config config = Config.builder().addProperty("prop.duration", "100ms").build();
|
||||
assertEquals(Duration.ofMillis(100), config.getDuration("prop.duration"));
|
||||
|
||||
config = Config.newBuilder().addProperty("prop.duration", "100s").build();
|
||||
config = Config.builder().addProperty("prop.duration", "100s").build();
|
||||
assertEquals(Duration.ofSeconds(100), config.getDuration("prop.duration"));
|
||||
|
||||
config = Config.newBuilder().addProperty("prop.duration", "100m").build();
|
||||
config = Config.builder().addProperty("prop.duration", "100m").build();
|
||||
assertEquals(Duration.ofMinutes(100), config.getDuration("prop.duration"));
|
||||
|
||||
config = Config.newBuilder().addProperty("prop.duration", "100h").build();
|
||||
config = Config.builder().addProperty("prop.duration", "100h").build();
|
||||
assertEquals(Duration.ofHours(100), config.getDuration("prop.duration"));
|
||||
|
||||
config = Config.newBuilder().addProperty("prop.duration", "100d").build();
|
||||
config = Config.builder().addProperty("prop.duration", "100d").build();
|
||||
assertEquals(Duration.ofDays(100), config.getDuration("prop.duration"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldGetList() {
|
||||
Config config = Config.newBuilder().addProperty("prop.list", "one, two ,three").build();
|
||||
Config config = Config.builder().addProperty("prop.list", "one, two ,three").build();
|
||||
|
||||
assertEquals(asList("one", "two", "three"), config.getList("prop.list"));
|
||||
assertEquals(
|
||||
|
@ -172,7 +166,7 @@ class ConfigTest {
|
|||
@Test
|
||||
void shouldGetMap() {
|
||||
Config config =
|
||||
Config.newBuilder()
|
||||
Config.builder()
|
||||
.addProperty("prop.map", "one=1, two=2")
|
||||
.addProperty("prop.wrong", "one=1, but not two!")
|
||||
.addProperty("prop.trailing", "one=1,")
|
||||
|
@ -191,7 +185,7 @@ class ConfigTest {
|
|||
|
||||
@Test
|
||||
void shouldFailOnInvalidMap() {
|
||||
Config config = Config.newBuilder().addProperty("prop.wrong", "one=1, but not two!").build();
|
||||
Config config = Config.builder().addProperty("prop.wrong", "one=1, but not two!").build();
|
||||
|
||||
assertThrows(ConfigParsingException.class, () -> config.getMap("prop.wrong"));
|
||||
}
|
||||
|
@ -199,7 +193,7 @@ class ConfigTest {
|
|||
@ParameterizedTest
|
||||
@ArgumentsSource(AgentDebugParams.class)
|
||||
void shouldCheckIfAgentDebugModeIsEnabled(String propertyValue, boolean expected) {
|
||||
Config config = Config.newBuilder().addProperty("otel.javaagent.debug", propertyValue).build();
|
||||
Config config = Config.builder().addProperty("otel.javaagent.debug", propertyValue).build();
|
||||
|
||||
assertEquals(expected, config.isAgentDebugEnabled());
|
||||
}
|
||||
|
@ -217,7 +211,7 @@ class ConfigTest {
|
|||
void shouldCheckIfInstrumentationIsEnabled(
|
||||
List<String> names, boolean defaultEnabled, boolean expected) {
|
||||
Config config =
|
||||
Config.newBuilder()
|
||||
Config.builder()
|
||||
.addProperty("otel.instrumentation.order.enabled", "true")
|
||||
.addProperty("otel.instrumentation.test-prop.enabled", "true")
|
||||
.addProperty("otel.instrumentation.disabled-prop.enabled", "false")
|
||||
|
|
|
@ -78,7 +78,7 @@ class SupportabilityMetricsTest {
|
|||
}
|
||||
|
||||
private static Config configWithJavaagentDebug(boolean enabled) {
|
||||
return Config.newBuilder()
|
||||
return Config.builder()
|
||||
.readProperties(Collections.singletonMap("otel.javaagent.debug", Boolean.toString(enabled)))
|
||||
.build();
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ import io.opentelemetry.instrumentation.guava.GuavaAsyncOperationEndStrategy;
|
|||
public final class InstrumentationHelper {
|
||||
static {
|
||||
asyncOperationEndStrategy =
|
||||
GuavaAsyncOperationEndStrategy.newBuilder()
|
||||
GuavaAsyncOperationEndStrategy.builder()
|
||||
.setCaptureExperimentalSpanAttributes(
|
||||
Config.get()
|
||||
.getBoolean("otel.instrumentation.guava.experimental-span-attributes", false))
|
||||
|
|
|
@ -20,10 +20,10 @@ public final class GuavaAsyncOperationEndStrategy implements AsyncOperationEndSt
|
|||
AttributeKey.booleanKey("guava.canceled");
|
||||
|
||||
public static GuavaAsyncOperationEndStrategy create() {
|
||||
return newBuilder().build();
|
||||
return builder().build();
|
||||
}
|
||||
|
||||
public static GuavaAsyncOperationEndStrategyBuilder newBuilder() {
|
||||
public static GuavaAsyncOperationEndStrategyBuilder builder() {
|
||||
return new GuavaAsyncOperationEndStrategyBuilder();
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ class GuavaAsyncOperationEndStrategyTest extends Specification {
|
|||
|
||||
def underTest = GuavaAsyncOperationEndStrategy.create()
|
||||
|
||||
def underTestWithExperimentalAttributes = GuavaAsyncOperationEndStrategy.newBuilder()
|
||||
def underTestWithExperimentalAttributes = GuavaAsyncOperationEndStrategy.builder()
|
||||
.setCaptureExperimentalSpanAttributes(true)
|
||||
.build()
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ public final class FutureListenerWrappers {
|
|||
// to the key, that means it's no longer used (referenced) by the netty future anyways.
|
||||
private static final Cache<
|
||||
GenericFutureListener<? extends Future<?>>, GenericFutureListener<? extends Future<?>>>
|
||||
wrappers = Cache.newBuilder().setWeakKeys().setWeakValues().build();
|
||||
wrappers = Cache.builder().setWeakKeys().setWeakValues().build();
|
||||
|
||||
private static final ClassValue<Boolean> shouldWrap =
|
||||
new ClassValue<Boolean>() {
|
||||
|
|
|
@ -34,7 +34,7 @@ public class HooksInstrumentation implements TypeInstrumentation {
|
|||
|
||||
@Advice.OnMethodExit(suppress = Throwable.class)
|
||||
public static void postStaticInitializer() {
|
||||
ContextPropagationOperator.newBuilder()
|
||||
ContextPropagationOperator.builder()
|
||||
.setCaptureExperimentalSpanAttributes(
|
||||
Config.get()
|
||||
.getBoolean("otel.instrumentation.reactor.experimental-span-attributes", false))
|
||||
|
|
|
@ -40,10 +40,10 @@ import reactor.core.publisher.Operators;
|
|||
public final class ContextPropagationOperator {
|
||||
|
||||
public static ContextPropagationOperator create() {
|
||||
return newBuilder().build();
|
||||
return builder().build();
|
||||
}
|
||||
|
||||
public static ContextPropagationOperatorBuilder newBuilder() {
|
||||
public static ContextPropagationOperatorBuilder builder() {
|
||||
return new ContextPropagationOperatorBuilder();
|
||||
}
|
||||
|
||||
|
@ -87,7 +87,7 @@ public final class ContextPropagationOperator {
|
|||
|
||||
ContextPropagationOperator(boolean captureExperimentalSpanAttributes) {
|
||||
this.asyncOperationEndStrategy =
|
||||
ReactorAsyncOperationEndStrategy.newBuilder()
|
||||
ReactorAsyncOperationEndStrategy.builder()
|
||||
.setCaptureExperimentalSpanAttributes(captureExperimentalSpanAttributes)
|
||||
.build();
|
||||
}
|
||||
|
|
|
@ -23,10 +23,10 @@ public final class ReactorAsyncOperationEndStrategy implements AsyncOperationEnd
|
|||
AttributeKey.booleanKey("reactor.canceled");
|
||||
|
||||
public static ReactorAsyncOperationEndStrategy create() {
|
||||
return newBuilder().build();
|
||||
return builder().build();
|
||||
}
|
||||
|
||||
public static ReactorAsyncOperationEndStrategyBuilder newBuilder() {
|
||||
public static ReactorAsyncOperationEndStrategyBuilder builder() {
|
||||
return new ReactorAsyncOperationEndStrategyBuilder();
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ class ReactorAsyncOperationEndStrategyTest extends Specification {
|
|||
|
||||
def underTest = ReactorAsyncOperationEndStrategy.create()
|
||||
|
||||
def underTestWithExperimentalAttributes = ReactorAsyncOperationEndStrategy.newBuilder()
|
||||
def underTestWithExperimentalAttributes = ReactorAsyncOperationEndStrategy.builder()
|
||||
.setCaptureExperimentalSpanAttributes(true)
|
||||
.build()
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ public final class TracingAssemblyActivation {
|
|||
|
||||
public static void activate(Class<?> clz) {
|
||||
if (activated.get(clz).compareAndSet(false, true)) {
|
||||
TracingAssembly.newBuilder()
|
||||
TracingAssembly.builder()
|
||||
.setCaptureExperimentalSpanAttributes(
|
||||
Config.get()
|
||||
.getBoolean("otel.instrumentation.rxjava.experimental-span-attributes", false))
|
||||
|
|
|
@ -29,10 +29,10 @@ public final class RxJava2AsyncOperationEndStrategy implements AsyncOperationEnd
|
|||
AttributeKey.booleanKey("rxjava.canceled");
|
||||
|
||||
public static RxJava2AsyncOperationEndStrategy create() {
|
||||
return newBuilder().build();
|
||||
return builder().build();
|
||||
}
|
||||
|
||||
public static RxJava2AsyncOperationEndStrategyBuilder newBuilder() {
|
||||
public static RxJava2AsyncOperationEndStrategyBuilder builder() {
|
||||
return new RxJava2AsyncOperationEndStrategyBuilder();
|
||||
}
|
||||
|
||||
|
|
|
@ -97,10 +97,10 @@ public final class TracingAssembly {
|
|||
private static boolean enabled;
|
||||
|
||||
public static TracingAssembly create() {
|
||||
return newBuilder().build();
|
||||
return builder().build();
|
||||
}
|
||||
|
||||
public static TracingAssemblyBuilder newBuilder() {
|
||||
public static TracingAssemblyBuilder builder() {
|
||||
return new TracingAssemblyBuilder();
|
||||
}
|
||||
|
||||
|
@ -249,7 +249,7 @@ public final class TracingAssembly {
|
|||
|
||||
private static void enableWithSpanStrategy(boolean captureExperimentalSpanAttributes) {
|
||||
asyncOperationEndStrategy =
|
||||
RxJava2AsyncOperationEndStrategy.newBuilder()
|
||||
RxJava2AsyncOperationEndStrategy.builder()
|
||||
.setCaptureExperimentalSpanAttributes(captureExperimentalSpanAttributes)
|
||||
.build();
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ class RxJava2AsyncOperationEndStrategyTest extends Specification {
|
|||
|
||||
def underTest = RxJava2AsyncOperationEndStrategy.create()
|
||||
|
||||
def underTestWithExperimentalAttributes = RxJava2AsyncOperationEndStrategy.newBuilder()
|
||||
def underTestWithExperimentalAttributes = RxJava2AsyncOperationEndStrategy.builder()
|
||||
.setCaptureExperimentalSpanAttributes(true)
|
||||
.build()
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ public final class TracingAssemblyActivation {
|
|||
|
||||
public static void activate(Class<?> clz) {
|
||||
if (activated.get(clz).compareAndSet(false, true)) {
|
||||
TracingAssembly.newBuilder()
|
||||
TracingAssembly.builder()
|
||||
.setCaptureExperimentalSpanAttributes(
|
||||
Config.get()
|
||||
.getBoolean("otel.instrumentation.rxjava.experimental-span-attributes", false))
|
||||
|
|
|
@ -29,10 +29,10 @@ public final class RxJava3AsyncOperationEndStrategy implements AsyncOperationEnd
|
|||
AttributeKey.booleanKey("rxjava.canceled");
|
||||
|
||||
public static RxJava3AsyncOperationEndStrategy create() {
|
||||
return newBuilder().build();
|
||||
return builder().build();
|
||||
}
|
||||
|
||||
public static RxJava3AsyncOperationEndStrategyBuilder newBuilder() {
|
||||
public static RxJava3AsyncOperationEndStrategyBuilder builder() {
|
||||
return new RxJava3AsyncOperationEndStrategyBuilder();
|
||||
}
|
||||
|
||||
|
|
|
@ -97,10 +97,10 @@ public final class TracingAssembly {
|
|||
private static boolean enabled;
|
||||
|
||||
public static TracingAssembly create() {
|
||||
return newBuilder().build();
|
||||
return builder().build();
|
||||
}
|
||||
|
||||
public static TracingAssemblyBuilder newBuilder() {
|
||||
public static TracingAssemblyBuilder builder() {
|
||||
return new TracingAssemblyBuilder();
|
||||
}
|
||||
|
||||
|
@ -247,7 +247,7 @@ public final class TracingAssembly {
|
|||
|
||||
private static void enableWithSpanStrategy(boolean captureExperimentalSpanAttributes) {
|
||||
asyncOperationEndStrategy =
|
||||
RxJava3AsyncOperationEndStrategy.newBuilder()
|
||||
RxJava3AsyncOperationEndStrategy.builder()
|
||||
.setCaptureExperimentalSpanAttributes(captureExperimentalSpanAttributes)
|
||||
.build();
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ class RxJava3AsyncOperationEndStrategyTest extends Specification {
|
|||
|
||||
def underTest = RxJava3AsyncOperationEndStrategy.create()
|
||||
|
||||
def underTestWithExperimentalAttributes = RxJava3AsyncOperationEndStrategy.newBuilder()
|
||||
def underTestWithExperimentalAttributes = RxJava3AsyncOperationEndStrategy.builder()
|
||||
.setCaptureExperimentalSpanAttributes(true)
|
||||
.build()
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||
public final class HelperResources {
|
||||
|
||||
private static final Cache<ClassLoader, Map<String, URL>> RESOURCES =
|
||||
Cache.newBuilder().setWeakKeys().build();
|
||||
Cache.builder().setWeakKeys().build();
|
||||
|
||||
/** Registers the {@code payload} to be available to instrumentation at {@code path}. */
|
||||
public static void register(ClassLoader classLoader, String path, URL url) {
|
||||
|
|
|
@ -13,7 +13,7 @@ import net.bytebuddy.matcher.ElementMatcher;
|
|||
class ClassLoaderHasClassesNamedMatcher extends ElementMatcher.Junction.AbstractBase<ClassLoader> {
|
||||
|
||||
private final Cache<ClassLoader, Boolean> cache =
|
||||
Cache.newBuilder().setWeakKeys().setMaximumSize(25).build();
|
||||
Cache.builder().setWeakKeys().setMaximumSize(25).build();
|
||||
|
||||
private final String[] resources;
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ public final class ConfigInitializer {
|
|||
|
||||
// visible for testing
|
||||
static Config create(Properties spiConfiguration, Properties configurationFile) {
|
||||
return Config.newBuilder()
|
||||
return Config.builder()
|
||||
.readProperties(spiConfiguration)
|
||||
.readProperties(configurationFile)
|
||||
.readEnvironmentVariables()
|
||||
|
|
|
@ -264,7 +264,7 @@ final class VirtualFieldImplementationsGenerator {
|
|||
@SuppressWarnings({"UnusedMethod", "UnusedVariable", "MethodCanBeStatic"})
|
||||
static final class VirtualFieldImplementationTemplate extends VirtualField<Object, Object> {
|
||||
private static final VirtualFieldImplementationTemplate INSTANCE =
|
||||
new VirtualFieldImplementationTemplate(Cache.newBuilder().setWeakKeys().build());
|
||||
new VirtualFieldImplementationTemplate(Cache.builder().setWeakKeys().build());
|
||||
|
||||
private final Cache<Object, Object> map;
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ public class IgnoredClassLoadersMatcher extends ElementMatcher.Junction.Abstract
|
|||
|
||||
/* Cache of classloader-instance -> (true|false). True = skip instrumentation. False = safe to instrument. */
|
||||
private static final Cache<ClassLoader, Boolean> skipCache =
|
||||
Cache.newBuilder().setWeakKeys().build();
|
||||
Cache.builder().setWeakKeys().build();
|
||||
|
||||
private final Trie<IgnoreAllow> ignoredClassLoaders;
|
||||
|
||||
|
|
|
@ -9,9 +9,9 @@ import io.opentelemetry.javaagent.extension.ignore.IgnoredTypesBuilder;
|
|||
import io.opentelemetry.javaagent.tooling.util.Trie;
|
||||
|
||||
public class IgnoredTypesBuilderImpl implements IgnoredTypesBuilder {
|
||||
private final Trie.Builder<IgnoreAllow> ignoredTypesTrie = Trie.newBuilder();
|
||||
private final Trie.Builder<IgnoreAllow> ignoredClassLoadersTrie = Trie.newBuilder();
|
||||
private final Trie.Builder<Boolean> ignoredTasksTrie = Trie.newBuilder();
|
||||
private final Trie.Builder<IgnoreAllow> ignoredTypesTrie = Trie.builder();
|
||||
private final Trie.Builder<IgnoreAllow> ignoredClassLoadersTrie = Trie.builder();
|
||||
private final Trie.Builder<Boolean> ignoredTasksTrie = Trie.builder();
|
||||
|
||||
@Override
|
||||
public IgnoredTypesBuilder ignoreClass(String classNameOrPrefix) {
|
||||
|
|
|
@ -11,7 +11,7 @@ import javax.annotation.Nullable;
|
|||
public interface Trie<V> {
|
||||
|
||||
/** Start building a trie. */
|
||||
static <V> Builder<V> newBuilder() {
|
||||
static <V> Builder<V> builder() {
|
||||
return new TrieImpl.BuilderImpl<>();
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ class OpenTelemetryInstallerTest extends Specification {
|
|||
def "should initialize noop"() {
|
||||
|
||||
given:
|
||||
def config = Config.newBuilder()
|
||||
def config = Config.builder()
|
||||
.readProperties([
|
||||
(OpenTelemetryInstaller.JAVAAGENT_NOOP_CONFIG) : "true",
|
||||
(OpenTelemetryInstaller.JAVAAGENT_ENABLED_CONFIG): "true"
|
||||
|
@ -43,7 +43,7 @@ class OpenTelemetryInstallerTest extends Specification {
|
|||
def "should NOT initialize noop"() {
|
||||
|
||||
given:
|
||||
def config = Config.newBuilder()
|
||||
def config = Config.builder()
|
||||
.readProperties([
|
||||
(OpenTelemetryInstaller.JAVAAGENT_NOOP_CONFIG) : "true",
|
||||
(OpenTelemetryInstaller.JAVAAGENT_ENABLED_CONFIG): "false"
|
||||
|
|
|
@ -176,6 +176,6 @@ class ConfigPropertiesAdapterTest {
|
|||
}
|
||||
|
||||
private static ConfigProperties createConfig(Map<String, String> properties) {
|
||||
return new ConfigPropertiesAdapter(Config.newBuilder().readProperties(properties).build());
|
||||
return new ConfigPropertiesAdapter(Config.builder().readProperties(properties).build());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ class UserExcludedClassesConfigurerTest {
|
|||
@Test
|
||||
void shouldAddNothingToBuilderWhenPropertyIsEmpty() {
|
||||
// when
|
||||
underTest.configure(Config.newBuilder().build(), builder);
|
||||
underTest.configure(Config.builder().build(), builder);
|
||||
|
||||
// then
|
||||
verifyNoInteractions(builder);
|
||||
|
@ -37,7 +37,7 @@ class UserExcludedClassesConfigurerTest {
|
|||
void shouldIgnoreClassesAndPackages() {
|
||||
// given
|
||||
Config config =
|
||||
Config.newBuilder()
|
||||
Config.builder()
|
||||
.readProperties(
|
||||
singletonMap(
|
||||
EXCLUDED_CLASSES_CONFIG,
|
||||
|
|
|
@ -16,7 +16,7 @@ class TrieTest {
|
|||
@Test
|
||||
void shouldMatchExactString() {
|
||||
Trie<Integer> trie =
|
||||
Trie.<Integer>newBuilder().put("abc", 0).put("abcd", 10).put("abcde", 20).build();
|
||||
Trie.<Integer>builder().put("abc", 0).put("abcd", 10).put("abcde", 20).build();
|
||||
|
||||
assertNull(trie.getOrNull("ab"));
|
||||
assertFalse(trie.contains("ab"));
|
||||
|
@ -29,7 +29,7 @@ class TrieTest {
|
|||
@Test
|
||||
void shouldReturnLastMatchedValue() {
|
||||
Trie<Integer> trie =
|
||||
Trie.<Integer>newBuilder().put("abc", 0).put("abcde", 10).put("abcdfgh", 20).build();
|
||||
Trie.<Integer>builder().put("abc", 0).put("abcde", 10).put("abcdfgh", 20).build();
|
||||
|
||||
assertNull(trie.getOrNull("ababababa"));
|
||||
assertEquals(0, trie.getOrNull("abcd"));
|
||||
|
@ -39,14 +39,14 @@ class TrieTest {
|
|||
|
||||
@Test
|
||||
void shouldOverwritePreviousValue() {
|
||||
Trie<Integer> trie = Trie.<Integer>newBuilder().put("abc", 0).put("abc", 12).build();
|
||||
Trie<Integer> trie = Trie.<Integer>builder().put("abc", 0).put("abc", 12).build();
|
||||
|
||||
assertEquals(12, trie.getOrNull("abc"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldReturnDefaultValueWhenNotMatched() {
|
||||
Trie<Integer> trie = Trie.<Integer>newBuilder().put("abc", 42).build();
|
||||
Trie<Integer> trie = Trie.<Integer>builder().put("abc", 42).build();
|
||||
|
||||
assertEquals(-1, trie.getOrDefault("acdc", -1));
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ public class HelperInjector implements Transformer {
|
|||
};
|
||||
|
||||
private static final Cache<Class<?>, Boolean> injectedClasses =
|
||||
Cache.newBuilder().setWeakKeys().build();
|
||||
Cache.builder().setWeakKeys().build();
|
||||
|
||||
private final String requestingName;
|
||||
|
||||
|
@ -70,7 +70,7 @@ public class HelperInjector implements Transformer {
|
|||
private final Map<String, byte[]> dynamicTypeMap = new LinkedHashMap<>();
|
||||
|
||||
private final Cache<ClassLoader, Boolean> injectedClassLoaders =
|
||||
Cache.newBuilder().setWeakKeys().build();
|
||||
Cache.builder().setWeakKeys().build();
|
||||
|
||||
private final List<WeakReference<Object>> helperModules = new CopyOnWriteArrayList<>();
|
||||
|
||||
|
|
|
@ -49,13 +49,13 @@ public class AgentCachingPoolStrategy implements AgentBuilder.PoolStrategy {
|
|||
* </ul>
|
||||
*/
|
||||
final Cache<ClassLoader, WeakReference<ClassLoader>> loaderRefCache =
|
||||
Cache.newBuilder().setWeakKeys().build();
|
||||
Cache.builder().setWeakKeys().build();
|
||||
|
||||
/**
|
||||
* Single shared Type.Resolution cache -- uses a composite key -- conceptually of loader & name
|
||||
*/
|
||||
final Cache<TypeCacheKey, TypePool.Resolution> sharedResolutionCache =
|
||||
Cache.newBuilder().setMaximumSize(TYPE_CAPACITY).build();
|
||||
Cache.builder().setMaximumSize(TYPE_CAPACITY).build();
|
||||
|
||||
// fast path for bootstrap
|
||||
final SharedResolutionCacheAdapter bootstrapCacheProvider =
|
||||
|
|
|
@ -31,8 +31,7 @@ import net.bytebuddy.pool.TypePool;
|
|||
/** Matches a set of references against a classloader. */
|
||||
public final class ReferenceMatcher {
|
||||
|
||||
private final Cache<ClassLoader, Boolean> mismatchCache =
|
||||
Cache.newBuilder().setWeakKeys().build();
|
||||
private final Cache<ClassLoader, Boolean> mismatchCache = Cache.builder().setWeakKeys().build();
|
||||
private final Map<String, ClassRef> references;
|
||||
private final Set<String> helperClassNames;
|
||||
private final HelperClassPredicate helperClassPredicate;
|
||||
|
|
|
@ -47,7 +47,7 @@ public class TestAgentListener implements AgentBuilder.Listener {
|
|||
}
|
||||
|
||||
private static Trie<IgnoreAllow> buildOtherConfiguredIgnores() {
|
||||
Config config = Config.newBuilder().build();
|
||||
Config config = Config.builder().build();
|
||||
IgnoredTypesBuilderImpl builder = new IgnoredTypesBuilderImpl();
|
||||
for (IgnoredTypesConfigurer configurer :
|
||||
SafeServiceLoader.loadOrdered(IgnoredTypesConfigurer.class)) {
|
||||
|
|
Loading…
Reference in New Issue