From 669bb0abaa1f4ffb382b678130bcf5d98ebb5dba Mon Sep 17 00:00:00 2001 From: Ivan Kalachyev Date: Wed, 20 Nov 2024 13:09:08 +0200 Subject: [PATCH 1/5] fix: #565 batch requests issue --- .../internal/olingo/processor/AsynchronousProcessor.java | 8 ++++++++ .../odatav4/internal/olingo/processor/BatchProcessor.java | 1 + .../olingo/processor/CountEntityCollectionProcessor.java | 1 + .../internal/olingo/processor/EntityProcessor.java | 1 + .../internal/olingo/processor/PrimitiveProcessor.java | 1 + 5 files changed, 12 insertions(+) diff --git a/src/main/java/io/neonbee/endpoint/odatav4/internal/olingo/processor/AsynchronousProcessor.java b/src/main/java/io/neonbee/endpoint/odatav4/internal/olingo/processor/AsynchronousProcessor.java index 4c468122..f2e41fc7 100644 --- a/src/main/java/io/neonbee/endpoint/odatav4/internal/olingo/processor/AsynchronousProcessor.java +++ b/src/main/java/io/neonbee/endpoint/odatav4/internal/olingo/processor/AsynchronousProcessor.java @@ -8,6 +8,8 @@ import java.util.List; import java.util.Objects; +import org.apache.olingo.server.api.OData; +import org.apache.olingo.server.api.ServiceMetadata; import org.apache.olingo.server.api.processor.Processor; import io.vertx.core.Context; @@ -90,4 +92,10 @@ private static Deque>> processingStack() { } return processingStack; } + + @Override + public void init(OData odata, ServiceMetadata serviceMetadata) { + // reset subpromise + subProcessPromise = null; + } } diff --git a/src/main/java/io/neonbee/endpoint/odatav4/internal/olingo/processor/BatchProcessor.java b/src/main/java/io/neonbee/endpoint/odatav4/internal/olingo/processor/BatchProcessor.java index a1bd69b8..d5cdba9f 100644 --- a/src/main/java/io/neonbee/endpoint/odatav4/internal/olingo/processor/BatchProcessor.java +++ b/src/main/java/io/neonbee/endpoint/odatav4/internal/olingo/processor/BatchProcessor.java @@ -46,6 +46,7 @@ public BatchProcessor(Vertx vertx, RoutingContext routingContext, Promise @Override public void init(OData odata, ServiceMetadata serviceMetadata) { + super.init(odata, serviceMetadata); this.odata = odata; } diff --git a/src/main/java/io/neonbee/endpoint/odatav4/internal/olingo/processor/CountEntityCollectionProcessor.java b/src/main/java/io/neonbee/endpoint/odatav4/internal/olingo/processor/CountEntityCollectionProcessor.java index 54ce520d..8e6f321b 100644 --- a/src/main/java/io/neonbee/endpoint/odatav4/internal/olingo/processor/CountEntityCollectionProcessor.java +++ b/src/main/java/io/neonbee/endpoint/odatav4/internal/olingo/processor/CountEntityCollectionProcessor.java @@ -88,6 +88,7 @@ public CountEntityCollectionProcessor(Vertx vertx, RoutingContext routingContext @Override public void init(OData odata, ServiceMetadata serviceMetadata) { + super.init(odata, serviceMetadata); this.odata = odata; this.serviceMetadata = serviceMetadata; } diff --git a/src/main/java/io/neonbee/endpoint/odatav4/internal/olingo/processor/EntityProcessor.java b/src/main/java/io/neonbee/endpoint/odatav4/internal/olingo/processor/EntityProcessor.java index a8f1aff6..09eb0766 100644 --- a/src/main/java/io/neonbee/endpoint/odatav4/internal/olingo/processor/EntityProcessor.java +++ b/src/main/java/io/neonbee/endpoint/odatav4/internal/olingo/processor/EntityProcessor.java @@ -151,6 +151,7 @@ static Entity findEntityByKeyPredicates(RoutingContext routingContext, UriResour @Override public void init(OData odata, ServiceMetadata serviceMetadata) { + super.init(odata, serviceMetadata); this.odata = odata; this.serviceMetadata = serviceMetadata; } diff --git a/src/main/java/io/neonbee/endpoint/odatav4/internal/olingo/processor/PrimitiveProcessor.java b/src/main/java/io/neonbee/endpoint/odatav4/internal/olingo/processor/PrimitiveProcessor.java index 52de2f89..edc61041 100644 --- a/src/main/java/io/neonbee/endpoint/odatav4/internal/olingo/processor/PrimitiveProcessor.java +++ b/src/main/java/io/neonbee/endpoint/odatav4/internal/olingo/processor/PrimitiveProcessor.java @@ -54,6 +54,7 @@ public PrimitiveProcessor(Vertx vertx, RoutingContext routingContext, Promise Date: Wed, 20 Nov 2024 13:33:24 +0200 Subject: [PATCH 2/5] fix: #565 fix PMD --- .../processor/AsynchronousProcessor.java | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/main/java/io/neonbee/endpoint/odatav4/internal/olingo/processor/AsynchronousProcessor.java b/src/main/java/io/neonbee/endpoint/odatav4/internal/olingo/processor/AsynchronousProcessor.java index f2e41fc7..8614b59e 100644 --- a/src/main/java/io/neonbee/endpoint/odatav4/internal/olingo/processor/AsynchronousProcessor.java +++ b/src/main/java/io/neonbee/endpoint/odatav4/internal/olingo/processor/AsynchronousProcessor.java @@ -93,9 +93,29 @@ private static Deque>> processingStack() { return processingStack; } + /** + * Resets the {@code subProcessPromise} to {@code null}. + *

+ * This method is used to release any references held by the {@code subProcessPromise}, + * ensuring that the processor starts with a clean state. It is intentionally set to + * {@code null} as part of the processor's lifecycle management. + */ + private void resetSubProcessPromise() { + subProcessPromise = null; // Intentional reset to null + } + + /** + * Initializes the processor by resetting its internal state. + *

+ * This method is called during the processor's initialization phase. It uses + * {@link #resetSubProcessPromise()} to ensure the {@code subProcessPromise} is cleared, + * preparing the processor for a new lifecycle. + * + * @param odata the OData instance for this processor + * @param serviceMetadata the metadata for the OData service + */ @Override public void init(OData odata, ServiceMetadata serviceMetadata) { - // reset subpromise - subProcessPromise = null; + resetSubProcessPromise(); } } From 0c9568a8cab750b43550cbe5b1139fe76d9fbddd Mon Sep 17 00:00:00 2001 From: Ivan Kalachyev Date: Wed, 20 Nov 2024 13:44:55 +0200 Subject: [PATCH 3/5] fix: #565 formatting --- .../olingo/processor/AsynchronousProcessor.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/main/java/io/neonbee/endpoint/odatav4/internal/olingo/processor/AsynchronousProcessor.java b/src/main/java/io/neonbee/endpoint/odatav4/internal/olingo/processor/AsynchronousProcessor.java index 8614b59e..858156d8 100644 --- a/src/main/java/io/neonbee/endpoint/odatav4/internal/olingo/processor/AsynchronousProcessor.java +++ b/src/main/java/io/neonbee/endpoint/odatav4/internal/olingo/processor/AsynchronousProcessor.java @@ -96,9 +96,9 @@ private static Deque>> processingStack() { /** * Resets the {@code subProcessPromise} to {@code null}. *

- * This method is used to release any references held by the {@code subProcessPromise}, - * ensuring that the processor starts with a clean state. It is intentionally set to - * {@code null} as part of the processor's lifecycle management. + * This method is used to release any references held by the {@code subProcessPromise}, ensuring that the processor + * starts with a clean state. It is intentionally set to {@code null} as part of the processor's lifecycle + * management. */ private void resetSubProcessPromise() { subProcessPromise = null; // Intentional reset to null @@ -107,11 +107,10 @@ private void resetSubProcessPromise() { /** * Initializes the processor by resetting its internal state. *

- * This method is called during the processor's initialization phase. It uses - * {@link #resetSubProcessPromise()} to ensure the {@code subProcessPromise} is cleared, - * preparing the processor for a new lifecycle. + * This method is called during the processor's initialization phase. It uses {@link #resetSubProcessPromise()} to + * ensure the {@code subProcessPromise} is cleared, preparing the processor for a new lifecycle. * - * @param odata the OData instance for this processor + * @param odata the OData instance for this processor * @param serviceMetadata the metadata for the OData service */ @Override From 19bc1bcffded29f35a0dec19ac209da764bc891d Mon Sep 17 00:00:00 2001 From: Ivan Kalachyev Date: Wed, 20 Nov 2024 14:14:17 +0200 Subject: [PATCH 4/5] fix: #565 PMD --- .../internal/olingo/processor/AsynchronousProcessor.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/io/neonbee/endpoint/odatav4/internal/olingo/processor/AsynchronousProcessor.java b/src/main/java/io/neonbee/endpoint/odatav4/internal/olingo/processor/AsynchronousProcessor.java index 858156d8..c727bf53 100644 --- a/src/main/java/io/neonbee/endpoint/odatav4/internal/olingo/processor/AsynchronousProcessor.java +++ b/src/main/java/io/neonbee/endpoint/odatav4/internal/olingo/processor/AsynchronousProcessor.java @@ -20,6 +20,7 @@ public abstract class AsynchronousProcessor implements Processor { private static final String PROCESSING_STACK = "processingStack"; + private static final Promise INITIAL_STATE = null; protected Vertx vertx; @@ -101,7 +102,7 @@ private static Deque>> processingStack() { * management. */ private void resetSubProcessPromise() { - subProcessPromise = null; // Intentional reset to null + subProcessPromise = INITIAL_STATE; // Intentional reset to null } /** From 582c8531a43ccc3f2d52a5938954802ec026a864 Mon Sep 17 00:00:00 2001 From: Ivan Kalachyev Date: Wed, 20 Nov 2024 14:18:12 +0200 Subject: [PATCH 5/5] fix: #565 PMD --- .../odatav4/internal/olingo/processor/AsynchronousProcessor.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/io/neonbee/endpoint/odatav4/internal/olingo/processor/AsynchronousProcessor.java b/src/main/java/io/neonbee/endpoint/odatav4/internal/olingo/processor/AsynchronousProcessor.java index c727bf53..bf891bab 100644 --- a/src/main/java/io/neonbee/endpoint/odatav4/internal/olingo/processor/AsynchronousProcessor.java +++ b/src/main/java/io/neonbee/endpoint/odatav4/internal/olingo/processor/AsynchronousProcessor.java @@ -20,6 +20,7 @@ public abstract class AsynchronousProcessor implements Processor { private static final String PROCESSING_STACK = "processingStack"; + private static final Promise INITIAL_STATE = null; protected Vertx vertx;