You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by ma...@apache.org on 2024/04/22 15:17:20 UTC
(nifi) branch main updated: NIFI-13076: reduce enum array allocation (#8679)
This is an automated email from the ASF dual-hosted git repository.
markap14 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/nifi.git
The following commit(s) were added to refs/heads/main by this push:
new 31e1ce8f4c NIFI-13076: reduce enum array allocation (#8679)
31e1ce8f4c is described below
commit 31e1ce8f4cec10e291adeb31116194e6f445b751
Author: sullis <gi...@seansullivan.com>
AuthorDate: Mon Apr 22 10:17:15 2024 -0500
NIFI-13076: reduce enum array allocation (#8679)
---
.../processors/opentelemetry/server/HttpRequestHandler.java | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/nifi-nar-bundles/nifi-opentelemetry-bundle/nifi-opentelemetry-processors/src/main/java/org/apache/nifi/processors/opentelemetry/server/HttpRequestHandler.java b/nifi-nar-bundles/nifi-opentelemetry-bundle/nifi-opentelemetry-processors/src/main/java/org/apache/nifi/processors/opentelemetry/server/HttpRequestHandler.java
index ef0efd3bc2..740df36af3 100644
--- a/nifi-nar-bundles/nifi-opentelemetry-bundle/nifi-opentelemetry-processors/src/main/java/org/apache/nifi/processors/opentelemetry/server/HttpRequestHandler.java
+++ b/nifi-nar-bundles/nifi-opentelemetry-bundle/nifi-opentelemetry-processors/src/main/java/org/apache/nifi/processors/opentelemetry/server/HttpRequestHandler.java
@@ -55,6 +55,10 @@ import java.util.Objects;
* HTTP Handler for OTLP Export Service Requests over gGRPC or encoded as JSON or Protobuf over HTTP
*/
public class HttpRequestHandler extends SimpleChannelInboundHandler<FullHttpRequest> {
+ private static final TelemetryContentEncoding[] TELEMETRY_CONTENT_ENCODING_VALUES = TelemetryContentEncoding.values();
+ private static final TelemetryRequestType[] TELEMETRY_REQUEST_TYPE_VALUES = TelemetryRequestType.values();
+ private static final TelemetryContentType[] TELEMETRY_CONTENT_TYPE_VALUES = TelemetryContentType.values();
+
private final ResponseBodyWriter responseBodyWriter = new StandardResponseBodyWriter();
private final ComponentLog log;
@@ -138,7 +142,7 @@ public class HttpRequestHandler extends SimpleChannelInboundHandler<FullHttpRequ
TelemetryContentEncoding telemetryContentEncoding = TelemetryContentEncoding.NONE;
final String contentEncoding = requestContentEncoding == null ? StringUtils.EMPTY : requestContentEncoding;
- for (final TelemetryContentEncoding currentEncoding : TelemetryContentEncoding.values()) {
+ for (final TelemetryContentEncoding currentEncoding : TELEMETRY_CONTENT_ENCODING_VALUES) {
if (currentEncoding.getContentEncoding().contentEquals(contentEncoding)) {
telemetryContentEncoding = currentEncoding;
break;
@@ -151,7 +155,7 @@ public class HttpRequestHandler extends SimpleChannelInboundHandler<FullHttpRequ
private TelemetryRequestType getTelemetryRequestType(final String path, final TelemetryContentType telemetryContentType) {
TelemetryRequestType telemetryRequestType = null;
- for (final TelemetryRequestType currentType : TelemetryRequestType.values()) {
+ for (final TelemetryRequestType currentType : TELEMETRY_REQUEST_TYPE_VALUES) {
final String requestTypePath;
if (TelemetryContentType.APPLICATION_GRPC == telemetryContentType) {
requestTypePath = currentType.getGrpcPath();
@@ -171,7 +175,7 @@ public class HttpRequestHandler extends SimpleChannelInboundHandler<FullHttpRequ
private TelemetryContentType getTelemetryContentType(final String requestContentType) {
TelemetryContentType telemetryContentType = null;
- for (final TelemetryContentType currentType : TelemetryContentType.values()) {
+ for (final TelemetryContentType currentType : TELEMETRY_CONTENT_TYPE_VALUES) {
if (currentType.getContentType().equals(requestContentType)) {
telemetryContentType = currentType;
break;