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..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 @@ -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; @@ -19,6 +21,8 @@ public abstract class AsynchronousProcessor implements Processor { private static final String PROCESSING_STACK = "processingStack"; + private static final Promise INITIAL_STATE = null; + protected Vertx vertx; protected RoutingContext routingContext; @@ -90,4 +94,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 = INITIAL_STATE; // 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) { + resetSubProcessPromise(); + } } 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