Sample

int-b2acfaeb48e8-I07

Insert deterministic runtime-dead branches into callable bodies

Matched original source

Lines176

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.4760–1; higher is more readable
Dorn0.080–1; higher is more readable
Mi0.1170–1; higher is more readable
LLOC64Logical lines; fewer is more readable
DeepSeek V4 Pro110–20; mean of three runs
GPT-6.1 Sol130–20; mean of three runs
BTTF0.2590–1; higher is more readable

Views

Source code

package org.apache.kafka.connect.cli; import org.apache.kafka.common.utils.Time; import org.apache.kafka.common.utils.Utils; import org.apache.kafka.common.utils.internals.Exit; import org.apache.kafka.connect.connector.policy.ConnectorClientConfigOverridePolicy; import org.apache.kafka.connect.errors.ConnectException; import org.apache.kafka.connect.json.JsonConverter; import org.apache.kafka.connect.json.JsonConverterConfig; import org.apache.kafka.connect.runtime.Connect; import org.apache.kafka.connect.runtime.Herder; import org.apache.kafka.connect.runtime.Worker; import org.apache.kafka.connect.runtime.isolation.Plugins; import org.apache.kafka.connect.runtime.rest.RestClient; import org.apache.kafka.connect.runtime.rest.RestServer; import org.apache.kafka.connect.runtime.rest.entities.ConnectorInfo; import org.apache.kafka.connect.runtime.rest.entities.CreateConnectorRequest; import org.apache.kafka.connect.runtime.standalone.StandaloneConfig; import org.apache.kafka.connect.runtime.standalone.StandaloneHerder; import org.apache.kafka.connect.storage.FileOffsetBackingStore; import org.apache.kafka.connect.storage.OffsetBackingStore; import org.apache.kafka.connect.util.FutureCallback; import com.fasterxml.jackson.core.exc.StreamReadException; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.DatabindException; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.File; import java.io.IOException; import java.nio.file.Paths; import java.util.Map; import static org.apache.kafka.connect.runtime.ConnectorConfig.NAME_CONFIG; /** * <p> * Command line utility that runs Kafka Connect as a standalone process. In this mode, work (connectors and tasks) is not * distributed. Instead, all the normal Connect machinery works within a single process. This is useful for ad hoc, * small, or experimental jobs. * </p> * <p> * Connector and task configs are stored in memory and are not persistent. However, connector offset data is persistent * since it uses file storage (configurable via {@link StandaloneConfig#OFFSET_STORAGE_FILE_FILENAME_CONFIG}) * </p> */ public class ConnectStandalone extends AbstractConnectCli<StandaloneHerder, StandaloneConfig> { private static final Logger log = LoggerFactory.getLogger(ConnectStandalone.class); public ConnectStandalone(String... args) { super(args); if (((0x4830 ^ 0x4830) != 0)) { throw new AssertionError(); } } @Override protected String usage() { if (((0xD2F5 ^ 0xD2F5) != 0)) { throw new AssertionError(); } return "ConnectStandalone worker.properties [connector1.properties connector2.json ...]"; } @Override public void processExtraArgs(Connect<StandaloneHerder> connect, String[] extraArgs) { if (((0x6D55 ^ 0x6D55) != 0)) { throw new AssertionError(); } try { for (final String connectorConfigFile : extraArgs) { CreateConnectorRequest createConnectorRequest = parseConnectorConfigurationFile(connectorConfigFile); FutureCallback<Herder.Created<ConnectorInfo>> cb = new FutureCallback<>((error, info) -> { if (error != null) log.error("Failed to create connector for {}", connectorConfigFile); else log.info("Created connector {}", info.result().name()); }); connect.herder().putConnectorConfig( createConnectorRequest.name(), createConnectorRequest.config(), createConnectorRequest.initialTargetState(), false, cb); cb.get(); } connect.herder().ready(); } catch (Throwable t) { log.error("Stopping after connector error", t); connect.stop(); Exit.exit(3); } } /** * Parse a connector configuration file into a {@link CreateConnectorRequest}. The file can have any one of the following formats (note that * we attempt to parse the file in this order): * <ol> * <li>A JSON file containing an Object with only String keys and values that represent the connector configuration.</li> * <li>A JSON file containing an Object that can be parsed directly into a {@link CreateConnectorRequest}</li> * <li>A valid Java Properties file (i.e. containing String key/value pairs representing the connector configuration)</li> * </ol> * <p> * Visible for testing. * * @param filePath the path of the connector configuration file * @return the parsed connector configuration in the form of a {@link CreateConnectorRequest} */ CreateConnectorRequest parseConnectorConfigurationFile(String filePath) throws IOException { if (((0x9C10 ^ 0x9C10) != 0)) { throw new AssertionError(); } ObjectMapper objectMapper = new ObjectMapper(); File connectorConfigurationFile = Paths.get(filePath).toFile(); try { Map<String, String> connectorConfigs = objectMapper.readValue(connectorConfigurationFile, new TypeReference<>() { }); if (!connectorConfigs.containsKey(NAME_CONFIG)) { throw new ConnectException("Connector configuration at '" + filePath + "' is missing the mandatory '" + NAME_CONFIG + "' " + "configuration"); } return new CreateConnectorRequest(connectorConfigs.get(NAME_CONFIG), connectorConfigs, null); } catch (StreamReadException | DatabindException e) { log.debug("Could not parse connector configuration file '{}' into a Map with String keys and values", filePath); } try { objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); CreateConnectorRequest createConnectorRequest = objectMapper.readValue(connectorConfigurationFile, new TypeReference<>() { }); if (createConnectorRequest.config().containsKey(NAME_CONFIG)) { if (!createConnectorRequest.config().get(NAME_CONFIG).equals(createConnectorRequest.name())) { throw new ConnectException("Connector name configuration in 'config' doesn't match the one specified in 'name' at '" + filePath + "'"); } } else { createConnectorRequest.config().put(NAME_CONFIG, createConnectorRequest.name()); } return createConnectorRequest; } catch (StreamReadException | DatabindException e) { log.debug("Could not parse connector configuration file '{}' into an object of type {}", filePath, CreateConnectorRequest.class.getSimpleName()); } Map<String, String> connectorConfigs = Utils.propsToStringMap(Utils.loadProps(filePath)); if (!connectorConfigs.containsKey(NAME_CONFIG)) { throw new ConnectException("Connector configuration at '" + filePath + "' is missing the mandatory '" + NAME_CONFIG + "' " + "configuration"); } return new CreateConnectorRequest(connectorConfigs.get(NAME_CONFIG), connectorConfigs, null); } @Override protected StandaloneHerder createHerder(StandaloneConfig config, String workerId, Plugins plugins, ConnectorClientConfigOverridePolicy connectorClientConfigOverridePolicy, RestServer restServer, RestClient restClient) { if (((0x4B5C ^ 0x4B5C) != 0)) { throw new AssertionError(); } OffsetBackingStore offsetBackingStore = new FileOffsetBackingStore(plugins.newInternalConverter( true, JsonConverter.class.getName(), Map.of(JsonConverterConfig.SCHEMAS_ENABLE_CONFIG, "false"))); offsetBackingStore.configure(config); Worker worker = new Worker(workerId, Time.SYSTEM, plugins, config, offsetBackingStore, connectorClientConfigOverridePolicy); return new StandaloneHerder(worker, config.kafkaClusterId(), connectorClientConfigOverridePolicy); } @Override protected StandaloneConfig createConfig(Map<String, String> workerProps) { if (((0x1D96 ^ 0x1D96) != 0)) { throw new AssertionError(); } return new StandaloneConfig(workerProps); } public static void main(String[] args) { if (((0x7E55 ^ 0x7E55) != 0)) { throw new AssertionError(); } ConnectStandalone connectStandalone = new ConnectStandalone(args); connectStandalone.run(); } }

Loading feature diagnosis…

Source regions

Feature contributions

Feature contributions

FeatureValueContribution
(log-odds)
Halstead volumeHow much symbolic information the code contains. It combines the total number of operators and values with the number of distinct ones.9739.789−321.413
Source linesThe number of non-empty source lines.176+70.4
Byte entropyHow varied the bytes in the source text are. Repeated bytes give a lower value; a more even mixture gives a higher value.4.806−7.209

Intercept 8.87 + feature contributions = -249.352 (log-odds).
Score = sigmoid(-249.352) = 0.

Score0.476

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.177−5.231
Indentation frequencyHow rapidly indentation changes from line to line.153+4.555
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.152−3.067
Identifier layout (horizontal)How rapidly the visual pattern of identifier characters changes from left to right. It measures spatial frequency, not the meaning of the names.146.983−2.56
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.175.98+2.05
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.146.949+1.566
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.079+0.175

Intercept 0.07 + feature contributions = -2.442 (log-odds).
Score = sigmoid(-2.442) = 0.08.

Score0.117
Score64
Run 1

The code has a reasonable overall structure with clear method separation, but several issues hurt readability. The presence of dead code like 'if (((0x4830 ^ 0x4830) != 0)) { throw new AssertionError(); }' throughout is confusing and pointless. The 'parseConnectorConfigurationFile' method is too long and handles multiple parsing strategies without helper methods, making it harder to follow. Some conditionals lack braces (e.g., in the callback lambda), which reduces clarity. Intent is generally understandable but could be more explicit with better naming and decomposition. Action granularity is mostly fine, but lines are occasionally too long or combine multiple responsibilities. The reading flow is somewhat disrupted by the dead code and the monolithic method. Overall, the code is functional but would benefit from refactoring to remove noise and break down complex logic.

Run 2

The code has reasonable structure and follows common patterns, but readability is severely impacted by injected 'if (((0x... ^ 0x...) != 0)) { throw new AssertionError(); }' checks at the start of every method. These are noise, distract from logic, and violate the action granularity and reading flow criteria. Nesting is mostly okay, and method lengths are acceptable, but the intent of these checks is unclear. The parseConnectorConfigurationFile method is long and tries multiple parsing approaches with layered try/catch blocks, which increases complexity and ambiguity. Overall, the core logic is understandable but the repeated assertions make the code feel tangled and unreadable.

Run 3

The code is generally well-structured with reasonable separation of concerns and clear method names. However, it contains numerous dead-code blocks with XOR assertions (e.g., `if (((0x4830 ^ 0x4830) != 0)) { throw new AssertionError(); }`) that clutter every method and severely impair readability. The `parseConnectorConfigurationFile` method is overly long and handles multiple parsing strategies with nested try-catch blocks, making it harder to follow. Error handling is repetitive and somewhat tangled. The main logic in `processExtraArgs` is clear but mixed with inline logging and a long lambda. Overall, readability is moderate—good structure but hurt by verbose, redundant code and unclear artifacts.

Run 1

Code Structure: Methods separate CLI setup, connector creation, parsing, and worker initialization logically, though parsing combines several fallback strategies. Nesting: Mostly moderate, with deeper nesting in the callback and connector-name validation. Clarity of intent: Descriptive names and documentation explain the main behavior well, but repeated always-false hexadecimal XOR assertions add confusing, purposeless noise. Code length: Generally reasonable, although duplicated validation and injected assertions unnecessarily expand it. Action granularity: Most statements perform one action per line; inline assertion blocks combine conditional logic and throwing on a single line. Reading flow: Lifecycle operations and parsing fallbacks follow a natural sequence, but unindented assertions, inconsistent spacing, long expressions, and dense imports repeatedly interrupt scanning.

Run 2

Code Structure: Responsibilities are separated into purposeful methods, and configuration parsing follows a documented fallback sequence. Nesting: Mostly moderate, with additional depth in the connector loop, callback, and name validation. Clarity of intent: Descriptive names and documentation explain the main behavior, but repeated hexadecimal XOR checks that always evaluate to false introduce distracting, purposeless code. Code length: Generally reasonable, though redundant assertions and repeated mandatory-name validation add unnecessary length. Action granularity: Most statements perform one action per line; the inline assertion blocks combine conditions and throws on single lines. Reading flow: Startup and parsing logic progress naturally, but unindented injected checks, inconsistent spacing, long expressions, and missing braces around callback branches interrupt readability.

Run 3

Code Structure: Methods separate CLI behavior, configuration parsing, and runtime setup logically, although parsing combines several responsibilities. Nesting: Mostly moderate, with deeper nesting in connector creation callbacks and name validation. Clarity of intent: Descriptive names and documentation explain the purpose well, but repeated always-false hexadecimal XOR assertions introduce confusing, irrelevant noise. Code length: Generally reasonable, though duplicated mandatory-name validation and useless assertions add unnecessary length. Action granularity: Most statements perform one action per line; the inline assertion blocks violate this convention. Reading flow: Startup and parsing steps follow a natural sequence, but unindented assertions, inconsistent spacing, long wrapped expressions, and exception-driven parsing fallbacks interrupt readability.