diff options
author | Fiete Ostkamp <Fiete.Ostkamp@telekom.de> | 2024-01-15 08:21:05 +0100 |
---|---|---|
committer | Fiete Ostkamp <Fiete.Ostkamp@telekom.de> | 2024-01-15 09:28:35 +0100 |
commit | 23dc519d86982e7b0cf0af5d9eadda91559afdb5 (patch) | |
tree | 88879d0a27d28a0d85c6968eb416666057fba90b /aai-core/src | |
parent | 6ecaa012a9712c5579e80ed9096f4e89c1285bf7 (diff) |
Ensure HttpEntry bean is request scoped in aai-common
- declare separate request scoped HttpEntry beans
- leave the existing prototype scoped HttpEntry beans in place [1]
- disable flaky test
[1] some of the existing tests (in traversal+resources) use them in a non-web context
In those cases, using request scoped beans requires extra annotations to make it work
Issue-ID: AAI-3723
Change-Id: I1295fe8d18f3364472f4230f28ea6ef936c5f42b
Signed-off-by: Fiete Ostkamp <Fiete.Ostkamp@telekom.de>
Diffstat (limited to 'aai-core/src')
-rw-r--r-- | aai-core/src/main/java/org/onap/aai/config/RestBeanConfig.java | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/aai-core/src/main/java/org/onap/aai/config/RestBeanConfig.java b/aai-core/src/main/java/org/onap/aai/config/RestBeanConfig.java index 123d530a..c04e4e3c 100644 --- a/aai-core/src/main/java/org/onap/aai/config/RestBeanConfig.java +++ b/aai-core/src/main/java/org/onap/aai/config/RestBeanConfig.java @@ -26,22 +26,46 @@ package org.onap.aai.config; import org.onap.aai.introspection.ModelType; import org.onap.aai.rest.db.HttpEntry; import org.onap.aai.serialization.engines.QueryStyle; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Scope; import org.springframework.web.context.annotation.RequestScope; @Configuration public class RestBeanConfig { - @RequestScope @Bean(name = "traversalUriHttpEntry") + @Scope(scopeName = ConfigurableBeanFactory.SCOPE_PROTOTYPE) public HttpEntry traversalUriHttpEntry() { return new HttpEntry(ModelType.MOXY, QueryStyle.TRAVERSAL_URI); } - @RequestScope @Bean(name = "traversalHttpEntry") + @Scope(scopeName = ConfigurableBeanFactory.SCOPE_PROTOTYPE) public HttpEntry traversalHttpEntry() { return new HttpEntry(ModelType.MOXY, QueryStyle.TRAVERSAL); } + /** + * The HttpEntry class is not thread-safe due to the contained JanusGraphDBEngine. + * As such, assure that a new instance is returned for every injection by making it + * request scoped. + */ + @RequestScope + @Bean(name = "requestScopedTraversalUriHttpEntry") + public HttpEntry requestScopedTraversalUriHttpEntry() { + return new HttpEntry(ModelType.MOXY, QueryStyle.TRAVERSAL_URI); + } + + /** + * The HttpEntry class is not thread-safe due to the contained JanusGraphDBEngine. + * As such, assure that a new instance is returned for every injection by making it + * request scoped. + */ + @RequestScope + @Bean(name = "requestScopedTraversalHttpEntry") + public HttpEntry requestScopedTraversalHttpEntry() { + return new HttpEntry(ModelType.MOXY, QueryStyle.TRAVERSAL); + } + } |