See gh-37984
This commit is contained in:
Johnny Lim 2023-10-21 16:45:11 +09:00 committed by Moritz Halbritter
parent 6b8c340de0
commit b5d4983829
15 changed files with 29 additions and 40 deletions

View File

@ -53,7 +53,7 @@ public class OpenTelemetryAutoConfiguration {
*/
private static final String DEFAULT_APPLICATION_NAME = "application";
static final AttributeKey<String> ATTRIBUTE_KEY_SERVICE_NAME = AttributeKey.stringKey("service.name");
private static final AttributeKey<String> ATTRIBUTE_KEY_SERVICE_NAME = AttributeKey.stringKey("service.name");
@Bean
@ConditionalOnMissingBean(OpenTelemetry.class)

View File

@ -99,13 +99,13 @@ public class MicrometerTracingAutoConfiguration {
static class SpanAspectConfiguration {
@Bean
@ConditionalOnMissingBean
@ConditionalOnMissingBean(NewSpanParser.class)
DefaultNewSpanParser newSpanParser() {
return new DefaultNewSpanParser();
}
@Bean
@ConditionalOnMissingBean
@ConditionalOnMissingBean(MethodInvocationProcessor.class)
ImperativeMethodInvocationProcessor imperativeMethodInvocationProcessor(NewSpanParser newSpanParser,
Tracer tracer, ObjectProvider<SpanTagAnnotationHandler> spanTagAnnotationHandler) {
ImperativeMethodInvocationProcessor methodInvocationProcessor = new ImperativeMethodInvocationProcessor(

View File

@ -120,11 +120,11 @@ class WavefrontPropertiesConfigAdapterTests extends
CSP_CLIENT_CREDENTIALS, CSP_CLIENT_CREDENTIALS
""")
void whenTokenTypeIsSetAdapterReturnsIt(String property, String wavefront) {
TokenType propertyToken = property.equals("null") ? null : TokenType.valueOf(property);
Type wavefrontToken = Type.valueOf(wavefront);
TokenType propertyTokenType = property.equals("null") ? null : TokenType.valueOf(property);
Type wavefrontTokenType = Type.valueOf(wavefront);
WavefrontProperties properties = new WavefrontProperties();
properties.setApiTokenType(propertyToken);
assertThat(new WavefrontPropertiesConfigAdapter(properties).apiTokenType()).isEqualTo(wavefrontToken);
properties.setApiTokenType(propertyTokenType);
assertThat(new WavefrontPropertiesConfigAdapter(properties).apiTokenType()).isEqualTo(wavefrontTokenType);
}
}

View File

@ -34,12 +34,10 @@ import org.aspectj.weaver.Advice;
import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.test.context.FilteredClassLoader;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.util.ReflectionTestUtils;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
@ -158,9 +156,8 @@ class MicrometerTracingAutoConfigurationTests {
.run((context) -> {
assertThat(context).hasSingleBean(DefaultNewSpanParser.class);
assertThat(context).hasSingleBean(SpanAspect.class);
assertThat(ReflectionTestUtils.getField(context.getBean(ImperativeMethodInvocationProcessor.class),
"spanTagAnnotationHandler"))
.isSameAs(context.getBean(SpanTagAnnotationHandler.class));
assertThat(context.getBean(ImperativeMethodInvocationProcessor.class)).hasFieldOrPropertyWithValue(
"spanTagAnnotationHandler", context.getBean(SpanTagAnnotationHandler.class));
});
}
@ -208,14 +205,12 @@ class MicrometerTracingAutoConfigurationTests {
}
@Bean
@ConditionalOnMissingBean
ImperativeMethodInvocationProcessor customImperativeMethodInvocationProcessor(NewSpanParser newSpanParser,
Tracer tracer) {
return new ImperativeMethodInvocationProcessor(newSpanParser, tracer);
}
@Bean
@ConditionalOnMissingBean
SpanAspect customSpanAspect(MethodInvocationProcessor methodInvocationProcessor) {
return new SpanAspect(methodInvocationProcessor);
}

View File

@ -162,7 +162,7 @@ class ZipkinWebClientSenderTests extends ZipkinHttpSenderTests {
if (async) {
CallbackResult callbackResult = makeAsyncRequest(sender, Collections.emptyList());
assertThat(callbackResult.success()).isFalse();
assertThat(callbackResult.error()).isNotNull().isInstanceOf(TimeoutException.class);
assertThat(callbackResult.error()).isInstanceOf(TimeoutException.class);
}
else {
assertThatException().isThrownBy(() -> makeSyncRequest(sender, Collections.emptyList()))

View File

@ -81,7 +81,7 @@ public class MultipartProperties {
private boolean resolveLazily = false;
/**
* Whether to resolve the multipart request strictly comply with the Servlet
* Whether to resolve the multipart request strictly complying with the Servlet
* specification, only to be used for "multipart/form-data" requests.
*/
private boolean strictServletCompliance = false;

View File

@ -287,9 +287,9 @@ class RedisAutoConfigurationJedisTests {
void shouldUseVirtualThreadsIfEnabled() {
this.contextRunner.withPropertyValues("spring.threads.virtual.enabled=true").run((context) -> {
JedisConnectionFactory factory = context.getBean(JedisConnectionFactory.class);
SimpleAsyncTaskExecutor executor = (SimpleAsyncTaskExecutor) ReflectionTestUtils.getField(factory,
"executor");
SimpleAsyncTaskExecutorAssert.assertThat(executor).usesVirtualThreads();
assertThat(factory).extracting("executor")
.satisfies((executor) -> SimpleAsyncTaskExecutorAssert.assertThat((SimpleAsyncTaskExecutor) executor)
.usesVirtualThreads());
});
}

View File

@ -599,9 +599,9 @@ class RedisAutoConfigurationTests {
void shouldUseVirtualThreadsIfEnabled() {
this.contextRunner.withPropertyValues("spring.threads.virtual.enabled=true").run((context) -> {
LettuceConnectionFactory factory = context.getBean(LettuceConnectionFactory.class);
SimpleAsyncTaskExecutor executor = (SimpleAsyncTaskExecutor) ReflectionTestUtils.getField(factory,
"executor");
SimpleAsyncTaskExecutorAssert.assertThat(executor).usesVirtualThreads();
assertThat(factory).extracting("executor")
.satisfies((executor) -> SimpleAsyncTaskExecutorAssert.assertThat((SimpleAsyncTaskExecutor) executor)
.usesVirtualThreads());
});
}

View File

@ -214,7 +214,7 @@ class GraphQlAutoConfigurationTests {
GraphQlSource graphQlSource = context.getBean(GraphQlSource.class);
GraphQLSchema schema = graphQlSource.schema();
GraphQLOutputType bookConnection = schema.getQueryType().getField("books").getType();
assertThat(bookConnection).isNotNull().isInstanceOf(GraphQLObjectType.class);
assertThat(bookConnection).isInstanceOf(GraphQLObjectType.class);
assertThat((GraphQLObjectType) bookConnection)
.satisfies((connection) -> assertThat(connection.getFieldDefinition("edges")).isNotNull());
});

View File

@ -217,7 +217,7 @@ class ValidationAutoConfigurationTests {
.isSameAs(userMethodValidationPostProcessor);
assertThat(context.getBeansOfType(MethodValidationPostProcessor.class)).hasSize(1);
Object validator = ReflectionTestUtils.getField(userMethodValidationPostProcessor, "validator");
assertThat(validator).isNotNull().isInstanceOf(Supplier.class);
assertThat(validator).isInstanceOf(Supplier.class);
assertThat(context.getBean(Validator.class)).isNotSameAs(((Supplier<Validator>) validator).get());
});
}

View File

@ -32,13 +32,11 @@ class MyHealthMetricsExportConfiguration(registry: MeterRegistry, healthEndpoint
}.strongReference(true).register(registry)
}
private fun getStatusCode(health: HealthEndpoint): Int {
return when (health.health().status) {
Status.UP -> 3
Status.OUT_OF_SERVICE -> 2
Status.DOWN -> 1
else -> 0
}
private fun getStatusCode(health: HealthEndpoint) = when (health.health().status) {
Status.UP -> 3
Status.OUT_OF_SERVICE -> 2
Status.DOWN -> 1
else -> 0
}
}

View File

@ -160,7 +160,6 @@ public final class DockerImageNames {
/**
* Return a {@link DockerImageName} suitable for running OpenTelemetry.
* @return a docker image name for running OpenTelemetry
* @since 3.2.0
*/
public static DockerImageName opentelemetry() {
return DockerImageName.parse("otel/opentelemetry-collector-contrib").withTag(OPENTELEMETRY_VERSION);

View File

@ -412,7 +412,7 @@ public class LogbackLoggingSystem extends AbstractLoggingSystem implements BeanF
}
catch (InterruptedException ex) {
Thread.currentThread().interrupt();
throw new IllegalStateException("Interrupted while waiting for non-subtitute logger factory", ex);
throw new IllegalStateException("Interrupted while waiting for non-substitute logger factory", ex);
}
factory = LoggerFactory.getILoggerFactory();
}

View File

@ -39,8 +39,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*/
class LogbackLoggingSystemParallelInitializationTests {
private final LoggingSystem loggingSystem = LoggingSystem
.get(LogbackLoggingSystemParallelInitializationTests.class.getClassLoader());
private final LoggingSystem loggingSystem = LoggingSystem.get(getClass().getClassLoader());
@AfterEach
void cleanUp() {

View File

@ -475,11 +475,9 @@ class PaketoBuilderTests {
if (javaVersion.startsWith("1.")) {
return javaVersion.substring(2, 3);
}
else {
int firstDotIndex = javaVersion.indexOf(".");
if (firstDotIndex != -1) {
return javaVersion.substring(0, firstDotIndex);
}
int firstDotIndex = javaVersion.indexOf(".");
if (firstDotIndex != -1) {
return javaVersion.substring(0, firstDotIndex);
}
return javaVersion;
}