Disable YodaCondition check and revert some of the changes (#7596)

Let's keep close to the SDK repo config. 

I reverted some of the changes, only left those that I think make sense
anyway (e.g. comparing enums with `==`)
This commit is contained in:
Mateusz Rzeszutek 2023-01-18 04:44:15 +01:00 committed by GitHub
parent dfb4a6239d
commit d89932098a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
38 changed files with 72 additions and 89 deletions

View File

@ -115,6 +115,10 @@ tasks {
// lots of low level APIs use arrays
disable("AvoidObjectArrays")
// YodaConditions may improve safety in some cases. The argument of increased
// cognitive load is dubious.
disable("YodaCondition")
if (name.contains("Jmh") || name.contains("Test")) {
// Allow underscore in test-type method names
disable("MemberName")

View File

@ -62,7 +62,7 @@ public final class InternalNetClientAttributesExtractor<REQUEST, RESPONSE> {
}
String sockFamily = getter.sockFamily(request, response);
if (sockFamily != null && !sockFamily.equals(SemanticAttributes.NetSockFamilyValues.INET)) {
if (sockFamily != null && !SemanticAttributes.NetSockFamilyValues.INET.equals(sockFamily)) {
internalSet(attributes, SemanticAttributes.NET_SOCK_FAMILY, sockFamily);
}

View File

@ -73,7 +73,7 @@ public final class InternalNetServerAttributesExtractor<REQUEST> {
if (setSockFamily) {
String sockFamily = getter.sockFamily(request);
if (sockFamily != null && !sockFamily.equals(SemanticAttributes.NetSockFamilyValues.INET)) {
if (sockFamily != null && !SemanticAttributes.NetSockFamilyValues.INET.equals(sockFamily)) {
internalSet(attributes, SemanticAttributes.NET_SOCK_FAMILY, sockFamily);
}
}

View File

@ -44,7 +44,7 @@ class MessagingSpanDecorator extends BaseSpanDecorator {
public String getOperationName(
Exchange exchange, Endpoint endpoint, CamelDirection camelDirection) {
if (component.equals("mqtt")) {
if ("mqtt".equals(component)) {
return stripSchemeAndOptions(endpoint);
}
return getDestination(exchange, endpoint);

View File

@ -30,7 +30,7 @@ public final class OperationNameUtil {
}
public static String getSessionMethodOperationName(String methodName) {
if (methodName.equals("fireLock")) {
if ("fireLock".equals(methodName)) {
return "Session.lock";
}
return "Session." + methodName;

View File

@ -43,10 +43,11 @@ public class GetOutputStreamContext implements ImplicitContextKeyed {
String requestMethod) {
GetOutputStreamContext getOutputStreamContext = context.get(KEY);
String connectionClassName = connectionClass.getName();
if (connectionClassName.equals("sun.net.www.protocol.http.HttpURLConnection")
&& methodName.equals("getOutputStream")
&& requestMethod.equals(
"POST") // To be sure that getOutputStream has transformed GET into POST if
if ("sun.net.www.protocol.http.HttpURLConnection".equals(connectionClassName)
&& "getOutputStream".equals(methodName)
&& "POST"
.equals(
requestMethod) // To be sure that getOutputStream has transformed GET into POST if
// the method raised an exception
) {
getOutputStreamContext.outputStreamMethodOfSunConnectionCalled = true;

View File

@ -82,8 +82,8 @@ public class InnerClassLambdaMetafactoryInstrumentation implements TypeInstrumen
// This transformation uses ASM instead of Byte-Buddy advice because advice allows adding
// code to the start and end of the method, but here we are modifying a call in the middle of
// the method.
if ((name.equals("spinInnerClass") || name.equals("generateInnerClass"))
&& descriptor.equals("()Ljava/lang/Class;")) {
if (("spinInnerClass".equals(name) || "generateInnerClass".equals(name))
&& "()Ljava/lang/Class;".equals(descriptor)) {
mv =
new MethodVisitor(api, mv) {
@Override
@ -93,8 +93,8 @@ public class InnerClassLambdaMetafactoryInstrumentation implements TypeInstrumen
// if current instruction is a call to ASM ClassWriter.toByteArray() insert call to
// our lambda transformer
if (opcode == Opcodes.INVOKEVIRTUAL
&& name.equals("toByteArray")
&& descriptor.equals("()[B")) {
&& "toByteArray".equals(name)
&& "()[B".equals(descriptor)) {
mv.visitVarInsn(Opcodes.ALOAD, 0);
mv.visitFieldInsn(
Opcodes.GETFIELD, slashClassName, "lambdaClassName", "Ljava/lang/String;");

View File

@ -70,9 +70,9 @@ public class ClassInstrumentation implements TypeInstrumentation {
public MethodVisitor visitMethod(
int access, String name, String descriptor, String signature, String[] exceptions) {
MethodVisitor mv = super.visitMethod(access, name, descriptor, signature, exceptions);
if (name.equals("getInterfaces")
&& (descriptor.equals("()[Ljava/lang/Class;")
|| descriptor.equals("(Z)[Ljava/lang/Class;"))) {
if ("getInterfaces".equals(name)
&& ("()[Ljava/lang/Class;".equals(descriptor)
|| "(Z)[Ljava/lang/Class;".equals(descriptor))) {
mv =
new MethodVisitor(api, mv) {
@Override
@ -82,12 +82,12 @@ public class ClassInstrumentation implements TypeInstrumentation {
// filter the result of call to getInterfaces0, which is used on hotspot, and
// J9VMInternals.getInterfaces which is used on openj9
if (((opcode == Opcodes.INVOKEVIRTUAL || opcode == Opcodes.INVOKESPECIAL)
&& name.equals("getInterfaces0")
&& descriptor.equals("()[Ljava/lang/Class;"))
&& "getInterfaces0".equals(name)
&& "()[Ljava/lang/Class;".equals(descriptor))
|| (opcode == Opcodes.INVOKESTATIC
&& name.equals("getInterfaces")
&& owner.equals("java/lang/J9VMInternals")
&& descriptor.equals("(Ljava/lang/Class;)[Ljava/lang/Class;"))) {
&& "getInterfaces".equals(name)
&& "java/lang/J9VMInternals".equals(owner)
&& "(Ljava/lang/Class;)[Ljava/lang/Class;".equals(descriptor))) {
mv.visitVarInsn(Opcodes.ALOAD, 0);
mv.visitMethodInsn(
Opcodes.INVOKESTATIC,

View File

@ -7,7 +7,7 @@ public class TomeeArquillianJaxWsTest extends AbstractArquillianJaxWsTest {
@Override
protected String getServicePath(String service) {
if (service.equals("EjbHelloService")) {
if ("EjbHelloService".equals(service)) {
service = "webservices/EjbHelloServiceImpl";
}
return service;

View File

@ -7,7 +7,7 @@ public class WildflyArquillianJaxWsTest extends AbstractArquillianJaxWsTest {
@Override
protected String getServicePath(String service) {
if (service.equals("EjbHelloService")) {
if ("EjbHelloService".equals(service)) {
service = "EjbHelloService/EjbHelloServiceImpl";
}
return service;

View File

@ -21,7 +21,6 @@ import io.opentelemetry.javaagent.bootstrap.Java8BytecodeBridge;
import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation;
import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer;
import java.util.Map;
import java.util.Objects;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher;
@ -58,9 +57,7 @@ public class JbossExtLogRecordInstrumentation implements TypeInstrumentation {
@Advice.This ExtLogRecord record,
@Advice.Argument(0) String key,
@Advice.Return(readOnly = false) String value) {
if (Objects.equals(key, TRACE_ID)
|| Objects.equals(key, SPAN_ID)
|| Objects.equals(key, TRACE_FLAGS)) {
if (TRACE_ID.equals(key) || SPAN_ID.equals(key) || TRACE_FLAGS.equals(key)) {
if (value != null) {
// Assume already instrumented event if traceId/spanId/sampled is present.
return;

View File

@ -89,7 +89,7 @@ public final class KafkaTelemetry {
(proxy, method, args) -> {
// Future<RecordMetadata> send(ProducerRecord<K, V> record)
// Future<RecordMetadata> send(ProducerRecord<K, V> record, Callback callback)
if (method.getName().equals("send")
if ("send".equals(method.getName())
&& method.getParameterCount() >= 1
&& method.getParameterTypes()[0] == ProducerRecord.class) {
ProducerRecord<K, V> record = (ProducerRecord<K, V>) args[0];
@ -124,7 +124,7 @@ public final class KafkaTelemetry {
}
// ConsumerRecords<K, V> poll(long timeout)
// ConsumerRecords<K, V> poll(Duration duration)
if (method.getName().equals("poll") && result instanceof ConsumerRecords) {
if ("poll".equals(method.getName()) && result instanceof ConsumerRecords) {
buildAndFinishSpan((ConsumerRecords) result);
}
return result;

View File

@ -20,7 +20,6 @@ import io.opentelemetry.instrumentation.api.util.VirtualField;
import io.opentelemetry.javaagent.bootstrap.Java8BytecodeBridge;
import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation;
import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer;
import java.util.Objects;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher;
@ -51,9 +50,7 @@ public class LoggingEventInstrumentation implements TypeInstrumentation {
@Advice.This LoggingEvent event,
@Advice.Argument(0) String key,
@Advice.Return(readOnly = false) Object value) {
if (Objects.equals(key, TRACE_ID)
|| Objects.equals(key, SPAN_ID)
|| Objects.equals(key, TRACE_FLAGS)) {
if (TRACE_ID.equals(key) || SPAN_ID.equals(key) || TRACE_FLAGS.equals(key)) {
if (value != null) {
// Assume already instrumented event if traceId/spanId/sampled is present.
return;

View File

@ -111,7 +111,7 @@ public abstract class AbstractNetty41ClientTest
protected Set<AttributeKey<?>> httpAttributes(URI uri) {
String uriString = uri.toString();
// http://localhost:61/ => unopened port, https://192.0.2.1/ => non routable address
if (uriString.equals("http://localhost:61/") || uriString.equals("https://192.0.2.1/")) {
if ("http://localhost:61/".equals(uriString) || "https://192.0.2.1/".equals(uriString)) {
return Collections.emptySet();
}
Set<AttributeKey<?>> attributes = super.httpAttributes(uri);

View File

@ -22,7 +22,6 @@ import io.netty.handler.ssl.SslContext;
import io.netty.handler.ssl.SslContextBuilder;
import io.netty.handler.timeout.ReadTimeoutHandler;
import java.net.URI;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
import java.util.function.Consumer;
import java.util.function.Supplier;
@ -101,9 +100,9 @@ public class Netty41ClientExtension implements BeforeAllCallback, AfterAllCallba
}
public Bootstrap getBootstrap(URI uri) {
if (Objects.equals(uri.getScheme(), "https")) {
if ("https".equals(uri.getScheme())) {
return httpsBootstrap;
} else if (Objects.equals(uri.getPath(), "/read-timeout")) {
} else if ("/read-timeout".equals(uri.getPath())) {
return readTimeoutBootstrap;
}
return httpBootstrap;

View File

@ -102,10 +102,9 @@ public class OkHttp2Test extends AbstractHttpClientTest<Request> {
// flavor is extracted from the response, and those URLs cause exceptions (= null
// response)
String uriString = uri.toString();
if (uriString.equals("http://localhost:61/")
|| uriString.equals("https://192.0.2.1/")
|| uriString.equals(resolveAddress("/read-timeout").toString())) {
if ("http://localhost:61/".equals(uri.toString())
|| "https://192.0.2.1/".equals(uri.toString())
|| resolveAddress("/read-timeout").toString().equals(uri.toString())) {
attributes.remove(SemanticAttributes.HTTP_FLAVOR);
}

View File

@ -120,8 +120,8 @@ public abstract class AbstractOkHttp3Test extends AbstractHttpClientTest<Request
// flavor is extracted from the response, and those URLs cause exceptions (= null
// response)
if (uri.toString().equals("http://localhost:61/")
|| uri.toString().equals("https://192.0.2.1/")
if ("http://localhost:61/".equals(uri.toString())
|| "https://192.0.2.1/".equals(uri.toString())
|| resolveAddress("/read-timeout").toString().equals(uri.toString())) {
attributes.remove(SemanticAttributes.HTTP_FLAVOR);
}

View File

@ -111,8 +111,8 @@ abstract class AbstractReactorNettyHttpClientTest
(uri, exception) -> {
if (exception.getClass().getName().endsWith("ReactiveException")) {
// unopened port or non routable address
if (uri.toString().equals("http://localhost:61/")
|| uri.toString().equals("https://192.0.2.1/")) {
if ("http://localhost:61/".equals(uri.toString())
|| "https://192.0.2.1/".equals(uri.toString())) {
exception = exception.getCause();
}
}
@ -124,8 +124,8 @@ abstract class AbstractReactorNettyHttpClientTest
protected Set<AttributeKey<?>> getHttpAttributes(URI uri) {
// unopened port or non routable address
if (uri.toString().equals("http://localhost:61/")
|| uri.toString().equals("https://192.0.2.1/")) {
if ("http://localhost:61/".equals(uri.toString())
|| "https://192.0.2.1/".equals(uri.toString())) {
return emptySet();
}

View File

@ -19,7 +19,6 @@ import java.nio.file.InvalidPathException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Map;
import java.util.Objects;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.function.Supplier;
@ -73,15 +72,14 @@ public final class JarServiceNameDetector implements ConditionalResourceProvider
Map<String, String> resourceAttributes = config.getMap("otel.resource.attributes");
return serviceName == null
&& !resourceAttributes.containsKey(ResourceAttributes.SERVICE_NAME.getKey())
&& Objects.equals(
existing.getAttribute(ResourceAttributes.SERVICE_NAME), "unknown_service:java");
&& "unknown_service:java".equals(existing.getAttribute(ResourceAttributes.SERVICE_NAME));
}
@Nullable
private Path getJarPathFromProcessHandle() {
String[] javaArgs = getProcessHandleArguments.get();
for (int i = 0; i < javaArgs.length; ++i) {
if (javaArgs[i].equals("-jar") && (i < javaArgs.length - 1)) {
if ("-jar".equals(javaArgs[i]) && (i < javaArgs.length - 1)) {
return Paths.get(javaArgs[i + 1]);
}
}

View File

@ -85,7 +85,7 @@ class JarServiceNameDetectorTest {
@ArgumentsSource(SunCommandLineProvider.class)
void createResource_sunCommandLine(String commandLine, Path jarPath) {
Function<String, String> getProperty =
key -> key.equals("sun.java.command") ? commandLine : null;
key -> "sun.java.command".equals(key) ? commandLine : null;
Predicate<Path> fileExists = jarPath::equals;
JarServiceNameDetector serviceNameProvider =

View File

@ -69,7 +69,7 @@ public class RmiClientContextInstrumentation implements TypeInstrumentation {
(builder, typeDescription, classLoader, javaModule, protectionDomain) -> {
if (JavaModule.isSupported()
&& classLoader == null
&& typeDescription.getName().equals("sun.rmi.transport.StreamRemoteCall")
&& "sun.rmi.transport.StreamRemoteCall".equals(typeDescription.getName())
&& javaModule != null) {
Instrumentation instrumentation = InstrumentationHolder.getInstrumentation();
ClassInjector.UsingInstrumentation.redefineModule(

View File

@ -10,7 +10,6 @@ import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import javax.annotation.Nullable;
@ -81,7 +80,7 @@ public final class MappingResolver {
if (matcher.match(path)) {
String mapping = matcher.getMapping();
// for jsp return servlet path
if (Objects.equals(mapping, "/*.jsp") || Objects.equals(mapping, "/*.jspx")) {
if ("/*.jsp".equals(mapping) || "/*.jspx".equals(mapping)) {
return servletPath;
}
return mapping;

View File

@ -106,8 +106,7 @@ public class SpringBootServiceNameDetector implements ConditionalResourceProvide
Map<String, String> resourceAttributes = config.getMap("otel.resource.attributes");
return serviceName == null
&& !resourceAttributes.containsKey(ResourceAttributes.SERVICE_NAME.getKey())
&& Objects.equals(
resource.getAttribute(ResourceAttributes.SERVICE_NAME), "unknown_service:java");
&& "unknown_service:java".equals(resource.getAttribute(ResourceAttributes.SERVICE_NAME));
}
@Override

View File

@ -15,7 +15,6 @@ import java.lang.invoke.MethodType;
import java.util.IdentityHashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import org.springframework.aop.framework.Advised;
import org.springframework.aop.support.AopUtils;
import org.springframework.messaging.Message;
@ -243,8 +242,7 @@ final class TracingChannelInterceptor implements ExecutorChannelInterceptor {
}
try {
String type = (String) channelGetAttributeMh.invoke(messageChannel, "type");
return Objects.equals(type, "output");
return "output".equals(channelGetAttributeMh.invoke(messageChannel, "type"));
} catch (Throwable throwable) {
return false;
}

View File

@ -117,7 +117,7 @@ class TestWebSpringBootApp {
return controller(
INDEXED_CHILD,
() -> {
INDEXED_CHILD.collectSpanAttributes(name -> name.equals("id") ? id : null);
INDEXED_CHILD.collectSpanAttributes(name -> "id".equals(name) ? id : null);
return INDEXED_CHILD.getBody();
});
}

View File

@ -13,7 +13,6 @@ import io.opentelemetry.instrumentation.api.instrumenter.code.CodeAttributesExtr
import io.opentelemetry.instrumentation.api.instrumenter.code.CodeSpanNameExtractor;
import io.opentelemetry.instrumentation.api.instrumenter.util.SpanNames;
import io.opentelemetry.javaagent.bootstrap.internal.ExperimentalConfig;
import java.util.Objects;
public class VaadinSingletons {
private static final String INSTRUMENTATION_NAME = "io.opentelemetry.vaadin-14.2";
@ -86,7 +85,7 @@ public class VaadinSingletons {
RpcInvocationHandler rpcInvocationHandler = rpcRequest.getRpcInvocationHandler();
String spanName =
SpanNames.fromMethod(rpcInvocationHandler.getClass(), rpcRequest.getMethodName());
if (Objects.equals(rpcInvocationHandler.getRpcType(), "event")) {
if ("event".equals(rpcInvocationHandler.getRpcType())) {
String eventType = rpcRequest.getJsonObject().getString("event");
if (eventType != null) {
// append event type to make span name more descriptive

View File

@ -20,7 +20,6 @@ import java.security.CodeSource;
import java.security.Permission;
import java.security.cert.Certificate;
import java.util.Enumeration;
import java.util.Objects;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import java.util.jar.Manifest;
@ -124,7 +123,7 @@ public class AgentClassLoader extends URLClassLoader {
private static int getJavaVersion() {
String javaSpecVersion = System.getProperty("java.specification.version");
if (Objects.equals(javaSpecVersion, "1.8")) {
if ("1.8".equals(javaSpecVersion)) {
return 8;
}
return Integer.parseInt(javaSpecVersion);
@ -134,7 +133,7 @@ public class AgentClassLoader extends URLClassLoader {
public Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException {
// ContextStorageOverride is meant for library instrumentation we don't want it to apply to our
// bundled grpc
if (Objects.equals(name, "io.grpc.override.ContextStorageOverride")) {
if ("io.grpc.override.ContextStorageOverride".equals(name)) {
throw new ClassNotFoundException(name);
}

View File

@ -29,7 +29,7 @@ public final class InstrumentedTaskClasses {
// to exclude them here too.
ClassLoader taskClassLoader = taskClass.getClassLoader();
if (taskClassLoader != null
&& taskClassLoader.getClass().getName().equals(AGENT_CLASSLOADER_NAME)) {
&& AGENT_CLASSLOADER_NAME.equals(taskClassLoader.getClass().getName())) {
return false;
}
return true;

View File

@ -109,7 +109,7 @@ public class AgentStarterImpl implements AgentStarter {
Class<?> classBeingRedefined,
ProtectionDomain protectionDomain,
byte[] classfileBuffer) {
if (!className.equals("sun/launcher/LauncherHelper")) {
if (!"sun/launcher/LauncherHelper".equals(className)) {
return null;
}
transformed = true;
@ -121,7 +121,7 @@ public class AgentStarterImpl implements AgentStarter {
public MethodVisitor visitMethod(
int access, String name, String descriptor, String signature, String[] exceptions) {
MethodVisitor mv = super.visitMethod(access, name, descriptor, signature, exceptions);
if (name.equals("checkAndLoadMain")) {
if ("checkAndLoadMain".equals(name)) {
return new MethodVisitor(api, mv) {
@Override
public void visitCode() {

View File

@ -31,7 +31,7 @@ class RemappingUrlStreamHandler extends URLStreamHandler {
@Override
protected URLConnection openConnection(URL url) throws IOException {
String file = url.getFile();
if (file.equals("/")) {
if ("/".equals(file)) {
// "/" is used as the default url of the jar
// This is called by the SecureClassLoader trying to obtain permissions
// nullInputStream() is not available until Java 11

View File

@ -119,10 +119,10 @@ final class VirtualFieldImplementationsGenerator {
@Override
public MethodVisitor visitMethod(
int access, String name, String descriptor, String signature, String[] exceptions) {
if (name.equals("realGet")) {
if ("realGet".equals(name)) {
generateRealGetMethod(name);
return null;
} else if (name.equals("realPut")) {
} else if ("realPut".equals(name)) {
generateRealPutMethod(name);
return null;
} else {

View File

@ -274,7 +274,7 @@ public class AgentCachingPoolStrategy implements AgentBuilder.PoolStrategy {
return existingResolution;
}
if (className.equals(OBJECT_NAME)) {
if (OBJECT_NAME.equals(className)) {
return OBJECT_RESOLUTION;
}
@ -283,7 +283,7 @@ public class AgentCachingPoolStrategy implements AgentBuilder.PoolStrategy {
@Override
public TypePool.Resolution register(String className, TypePool.Resolution resolution) {
if (className.equals(OBJECT_NAME)) {
if (OBJECT_NAME.equals(className)) {
return resolution;
}

View File

@ -230,7 +230,7 @@ interface HelperReferenceWrapper {
private boolean isOverrideable(MethodRef method) {
return !(method.getFlags().contains(OwnershipFlag.STATIC)
|| method.getFlags().contains(VisibilityFlag.PRIVATE)
|| method.getName().equals(CONSTRUCTOR_INTERNAL_NAME));
|| CONSTRUCTOR_INTERNAL_NAME.equals(method.getName()));
}
private Method toMethod(MethodRef method) {

View File

@ -20,7 +20,6 @@ import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.FieldVisitor;
@ -571,9 +570,8 @@ final class ReferenceCollectingClassVisitor extends ClassVisitor {
Type ownerType = Type.getType("L" + owner + ";");
// remember used context classes if this is an VirtualField.find() call
if (Objects.equals(
ownerType.getClassName(), "io.opentelemetry.instrumentation.api.util.VirtualField")
&& Objects.equals(name, "find")
if ("io.opentelemetry.instrumentation.api.util.VirtualField".equals(ownerType.getClassName())
&& "find".equals(name)
&& methodType.getDescriptor().equals(getVirtualFieldDescriptor)) {
// in case of invalid scenario (not using .class ref directly) don't store anything and
// clear the last LDC <class> stack

View File

@ -137,15 +137,15 @@ final class MuzzleCodeGenerator implements AsmVisitorWrapper {
@Override
public MethodVisitor visitMethod(
int access, String name, String descriptor, String signature, String[] exceptions) {
if (name.equals(MUZZLE_REFERENCES_METHOD_NAME)) {
if (MUZZLE_REFERENCES_METHOD_NAME.equals(name)) {
generateReferencesMethod = false;
logMethodAlreadyExistsMessage(MUZZLE_REFERENCES_METHOD_NAME);
}
if (name.equals(MUZZLE_HELPER_CLASSES_METHOD_NAME)) {
if (MUZZLE_HELPER_CLASSES_METHOD_NAME.equals(name)) {
generateHelperClassNamesMethod = false;
logMethodAlreadyExistsMessage(MUZZLE_HELPER_CLASSES_METHOD_NAME);
}
if (name.equals(MUZZLE_VIRTUAL_FIELDS_METHOD_NAME)) {
if (MUZZLE_VIRTUAL_FIELDS_METHOD_NAME.equals(name)) {
generateVirtualFieldsMethod = false;
logMethodAlreadyExistsMessage(MUZZLE_VIRTUAL_FIELDS_METHOD_NAME);
}

View File

@ -56,7 +56,7 @@ public final class MethodRef {
}
public boolean isConstructor() {
return name.equals("<init>");
return "<init>".equals(name);
}
MethodRef merge(MethodRef anotherMethod) {

View File

@ -7,7 +7,6 @@ package io.opentelemetry.smoketest;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.function.Consumer;
import org.testcontainers.containers.output.OutputFrame;
@ -32,7 +31,7 @@ public interface TestContainerManager {
void stopTarget();
static boolean useWindowsContainers() {
return !Objects.equals(System.getenv("USE_LINUX_CONTAINERS"), "1")
return !"1".equals(System.getenv("USE_LINUX_CONTAINERS"))
&& System.getProperty("os.name").toLowerCase().contains("windows");
}
}

View File

@ -30,7 +30,6 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutionException;
@ -589,7 +588,7 @@ public abstract class AbstractHttpClientTest<REQUEST> {
span.hasName("callback")
.hasKind(SpanKind.INTERNAL)
.hasParent(trace.getSpan(0)));
boolean jdk8 = Objects.equals(System.getProperty("java.specification.version"), "1.8");
boolean jdk8 = "1.8".equals(System.getProperty("java.specification.version"));
if (jdk8) {
// on some netty based http clients order of `CONNECT` and `callback` spans isn't
// guaranteed when running on jdk8
@ -968,9 +967,7 @@ public abstract class AbstractHttpClientTest<REQUEST> {
assertThat(attrs)
.containsEntry(
SemanticAttributes.NET_SOCK_PEER_PORT,
Objects.equals(uri.getScheme(), "https")
? server.httpsPort()
: server.httpPort());
"https".equals(uri.getScheme()) ? server.httpsPort() : server.httpPort());
}
}