From b1aa75a1cbef4a8e1f9155b5d6a51d3c6bf279e8 Mon Sep 17 00:00:00 2001 From: seran <7030273+seran@users.noreply.github.com> Date: Thu, 12 Oct 2023 10:42:58 +0200 Subject: [PATCH] clean-up --- .../methodreplacement/ExternalServiceInfoUtils.java | 7 +------ .../classes/InetAddressClassReplacement.java | 4 ++-- .../methodreplacement/classes/SocketClassReplacement.java | 2 +- .../java/instrumentation/staticstate/ExecutionTracer.java | 4 ++-- 4 files changed, 6 insertions(+), 11 deletions(-) diff --git a/client-java/instrumentation/src/main/java/org/evomaster/client/java/instrumentation/coverage/methodreplacement/ExternalServiceInfoUtils.java b/client-java/instrumentation/src/main/java/org/evomaster/client/java/instrumentation/coverage/methodreplacement/ExternalServiceInfoUtils.java index 832b421bd2..de5cb4e8d5 100644 --- a/client-java/instrumentation/src/main/java/org/evomaster/client/java/instrumentation/coverage/methodreplacement/ExternalServiceInfoUtils.java +++ b/client-java/instrumentation/src/main/java/org/evomaster/client/java/instrumentation/coverage/methodreplacement/ExternalServiceInfoUtils.java @@ -22,10 +22,6 @@ public static String[] collectExternalServiceInfo(ExternalServiceInfo remoteHost // of time the same info gets added again and again. To do this, have to change the // data structure of the external service mapping inside ExecutionTracer - // TODO: Experiment -// ExecutionTracer.addHostnameInfo(new HostnameInfo(remoteHostInfo.getHostname(), true)); - - if (!ExecutionTracer.hasExternalMapping(remoteHostInfo.signature())) { String signature = remoteHostInfo.signature(); int connectPort = remotePort; @@ -38,7 +34,6 @@ public static String[] collectExternalServiceInfo(ExternalServiceInfo remoteHost connectPort = ExternalServiceSharedUtils.getDefaultWMPort(signature); } -// return new String[]{remoteHostInfo.getHostname(), "" + remotePort}; return new String[]{ExecutionTracer.getExternalMapping(signature), "" + connectPort}; } else { return new String[]{ExecutionTracer.getExternalMapping(remoteHostInfo.signature()), "" + remotePort}; @@ -57,7 +52,7 @@ public static boolean skipHostnameOrIp(String hostname) { || hostname.startsWith("0.0.0") || hostname.startsWith("10.") || hostname.startsWith("docker.socket") - || (hostname.startsWith("127.") && !ExecutionTracer.hasLocalAddressReplacement(hostname))) { + || (hostname.startsWith("127.") && !ExecutionTracer.hasMappingForLocalAddress(hostname))) { return true; } diff --git a/client-java/instrumentation/src/main/java/org/evomaster/client/java/instrumentation/coverage/methodreplacement/classes/InetAddressClassReplacement.java b/client-java/instrumentation/src/main/java/org/evomaster/client/java/instrumentation/coverage/methodreplacement/classes/InetAddressClassReplacement.java index f669f0d578..c4f24c5d29 100644 --- a/client-java/instrumentation/src/main/java/org/evomaster/client/java/instrumentation/coverage/methodreplacement/classes/InetAddressClassReplacement.java +++ b/client-java/instrumentation/src/main/java/org/evomaster/client/java/instrumentation/coverage/methodreplacement/classes/InetAddressClassReplacement.java @@ -40,7 +40,7 @@ public static InetAddress getByName(String host) throws UnknownHostException { return InetAddress.getByName(host); try { - if (ExecutionTracer.hasLocalAddress(host)) { + if (ExecutionTracer.hasLocalAddressForHost(host)) { String ip = ExecutionTracer.getLocalAddress(host); return InetAddress.getByName(ip); } @@ -71,7 +71,7 @@ public static InetAddress[] getAllByName(String host) throws UnknownHostExceptio return InetAddress.getAllByName(host); try { - if (ExecutionTracer.hasLocalAddress(host)) { + if (ExecutionTracer.hasLocalAddressForHost(host)) { String ip = ExecutionTracer.getLocalAddress(host); return new InetAddress[]{InetAddress.getByName(ip)}; } diff --git a/client-java/instrumentation/src/main/java/org/evomaster/client/java/instrumentation/coverage/methodreplacement/classes/SocketClassReplacement.java b/client-java/instrumentation/src/main/java/org/evomaster/client/java/instrumentation/coverage/methodreplacement/classes/SocketClassReplacement.java index 6162661626..49d39e0b5b 100644 --- a/client-java/instrumentation/src/main/java/org/evomaster/client/java/instrumentation/coverage/methodreplacement/classes/SocketClassReplacement.java +++ b/client-java/instrumentation/src/main/java/org/evomaster/client/java/instrumentation/coverage/methodreplacement/classes/SocketClassReplacement.java @@ -58,7 +58,7 @@ We MUST NOT call getHostName() anywhere in EM. and if there is a mapping available then Socket will use that value to connect. Otherwise, nothing will happen. */ - if (ExecutionTracer.hasLocalAddressReplacement(socketAddress.getHostString())) { + if (ExecutionTracer.hasMappingForLocalAddress(socketAddress.getHostString())) { String newHostname = ExecutionTracer.getRemoteHostname(socketAddress.getHostString()); ExternalServiceInfo remoteHostInfo = new ExternalServiceInfo( ExternalServiceSharedUtils.DEFAULT_SOCKET_CONNECT_PROTOCOL, diff --git a/client-java/instrumentation/src/main/java/org/evomaster/client/java/instrumentation/staticstate/ExecutionTracer.java b/client-java/instrumentation/src/main/java/org/evomaster/client/java/instrumentation/staticstate/ExecutionTracer.java index 0a921f05e0..68c28b1db8 100644 --- a/client-java/instrumentation/src/main/java/org/evomaster/client/java/instrumentation/staticstate/ExecutionTracer.java +++ b/client-java/instrumentation/src/main/java/org/evomaster/client/java/instrumentation/staticstate/ExecutionTracer.java @@ -709,14 +709,14 @@ public static boolean hasExternalMapping(String signature) { * Check whether there is a local IP address available for the given * remote hostname. */ - public static boolean hasLocalAddress(String hostname) { + public static boolean hasLocalAddressForHost(String hostname) { return localAddressMapping.containsKey(hostname); } /** * Checks for any replacement available to given local IP address. */ - public static boolean hasLocalAddressReplacement(String localAddress) { + public static boolean hasMappingForLocalAddress(String localAddress) { return localAddressMapping.containsValue(localAddress); }