Prevent stack overflow in BluePrintProcessingGRPCHandler 34/128534/2
authorJozsef Csongvai <jozsef.csongvai@bell.ca>
Wed, 13 Apr 2022 00:25:18 +0000 (20:25 -0400)
committerJozsef Csongvai <jozsef.csongvai@bell.ca>
Wed, 13 Apr 2022 02:41:20 +0000 (22:41 -0400)
The overridden onError is called when a terminating error occurs in
the stream, for example when the calling client crashes. It should not
be handled the same way as CBA processing errors.

Issue-ID: CCSDK-3496
Signed-off-by: Jozsef Csongvai <jozsef.csongvai@bell.ca>
Change-Id: Ib0aa416325a5b9708615e0ef9d9c602df24518b9

ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/BluePrintProcessingGRPCHandler.kt

index 79106c2..a210185 100644 (file)
@@ -61,18 +61,17 @@ open class BluePrintProcessingGRPCHandler(
                         executionServiceHandler.process(executionServiceInput.toJava(), responseObserver)
                     }
                 } catch (e: Exception) {
-                    onError(e)
+                    if (e is BluePrintProcessorException) handleWithErrorCatalog(e) else handleError(e)
                 } finally {
                     ph.arriveAndDeregister()
                 }
             }
 
             override fun onError(error: Throwable) {
-                log.debug("Fail to process message", error)
-                if (error is BluePrintProcessorException) onErrorCatalog(error) else onError(error)
+                log.error("Terminating stream error:", error)
             }
 
-            fun onError(error: Exception) {
+            fun handleError(error: Exception) {
                 responseObserver.onError(
                     Status.INTERNAL
                         .withDescription(error.errorMessageOrDefault())
@@ -81,7 +80,7 @@ open class BluePrintProcessingGRPCHandler(
                 )
             }
 
-            fun onErrorCatalog(error: BluePrintProcessorException) {
+            fun handleWithErrorCatalog(error: BluePrintProcessorException) {
                 if (error.protocol == "") {
                     error.grpc(ErrorCatalogCodes.GENERIC_FAILURE)
                 }