Source:
<code>public AsyncFuture<Void> consume(final byte[] message) throws ConsumerSchemaException { final JsonNode tree; final Span span = tracer.spanBuilder("ConsumerSchema.consume").startSpan(); span.putAttribute("schema", stringAttributeValue("Spotify100")); try (Scope ws = tracer.withSpan(span)) { try { tree = mapper.readTree(message); } catch (final Exception e) { span.setStatus(Status.INVALID_ARGUMENT.withDescription(e.toString())); span.end(); throw new ConsumerSchemaValidationException("Invalid metric", e); } if (tree.getNodeType() != JsonNodeType.OBJECT) { span.setStatus( Status.INVALID_ARGUMENT.withDescription("Metric is not an object")); span.end(); throw new ConsumerSchemaValidationException( "Expected object, but got: " + tree.getNodeType()); } final ObjectNode object = (ObjectNode) tree; final JsonNode versionNode = object.remove("version"); if (versionNode == null) { span.setStatus(Status.INVALID_ARGUMENT.withDescription("Missing version")); span.end(); throw new ConsumerSchemaValidationException( "Missing version in received object"); } final Version version; try { version = Version.parse(versionNode.asText()); } catch (final Exception e) { span.setStatus(Status.INVALID_ARGUMENT.withDescription("Bad version")); span.end(); throw new ConsumerSchemaValidationException("Bad version: " + versionNode); } if (version.getMajor() == 1) { return handleVersion1(tree).onFinished(span::end); <START> } else if (version.getMajor() == 2) { <END> return handleVersion2(tree).onFinished(span::end); } span.setStatus(Status.INVALID_ARGUMENT.withDescription("Unsupported version")); span.end(); throw new ConsumerSchemaValidationException("Unsupported version: " + version); } }</code><technical_language>put version.getMajor() a local variable called (I this method is called extremely frequently)</technical_language>

Target:
public AsyncFuture<Void> consume(final byte[] message) throws ConsumerSchemaException { final JsonNode tree; final Span span = tracer.spanBuilder("ConsumerSchema.consume").startSpan(); span.putAttribute("schema", stringAttributeValue("Spotify100")); try (Scope ws = tracer.withSpan(span)) { try { tree = mapper.readTree(message); } catch (final Exception e) { span.setStatus(Status.INVALID_ARGUMENT.withDescription(e.toString())); span.end(); throw new ConsumerSchemaValidationException("Invalid metric", e); } if (tree.getNodeType() != JsonNodeType.OBJECT) { span.setStatus( Status.INVALID_ARGUMENT.withDescription("Metric is not an object")); span.end(); throw new ConsumerSchemaValidationException( "Expected object, but got: " + tree.getNodeType()); } final ObjectNode object = (ObjectNode) tree; final JsonNode versionNode = object.remove("version"); if (versionNode == null) { span.setStatus(Status.INVALID_ARGUMENT.withDescription("Missing version")); span.end(); throw new ConsumerSchemaValidationException( "Missing version in received object"); } final Version version; try { version = Version.parse(versionNode.asText()); } catch (final Exception e) { span.setStatus(Status.INVALID_ARGUMENT.withDescription("Bad version")); span.end(); throw new ConsumerSchemaValidationException("Bad version: " + versionNode); } int major = version.getMajor(); if (major == 1) { return handleVersion1(tree).onFinished(span::end); } else if (major == 2) { return handleVersion2(tree).onFinished(span::end); } span.setStatus(Status.INVALID_ARGUMENT.withDescription("Unsupported version")); span.end(); throw new ConsumerSchemaValidationException("Unsupported version: " + version); } }