0

Sometimes we have an error at startup, and some messages are lost. Sometimes it works well, so the error seems to be random.

exception [Request processing failed; nested exception is java.util.ConcurrentModificationException] with root cause

java.util.ConcurrentModificationException: null
    at java.base/java.util.HashMap$KeySpliterator.tryAdvance(Unknown Source) ~[na:na]
    at java.base/java.util.stream.ReferencePipeline.forEachWithCancel(Unknown Source) ~[na:na]
    at java.base/java.util.stream.AbstractPipeline.copyIntoWithCancel(Unknown Source) ~[na:na]
    at java.base/java.util.stream.AbstractPipeline.copyInto(Unknown Source) ~[na:na]
    at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source) ~[na:na]
    at java.base/java.util.stream.FindOps$FindOp.evaluateSequential(Unknown Source) ~[na:na]
    at java.base/java.util.stream.AbstractPipeline.evaluate(Unknown Source) ~[na:na]
    at java.base/java.util.stream.ReferencePipeline.findFirst(Unknown Source) ~[na:na]
    at org.springframework.cloud.function.context.catalog.SimpleFunctionRegistry.findFunctionInFunctionRegistrations(SimpleFunctionRegistry.java:258) ~[spring-cloud-function-context-3.1.3.jar!/:3.1.3]
    at org.springframework.cloud.function.context.catalog.SimpleFunctionRegistry.compose(SimpleFunctionRegistry.java:274) ~[spring-cloud-function-context-3.1.3.jar!/:3.1.3]
    at org.springframework.cloud.function.context.catalog.SimpleFunctionRegistry.doLookup(SimpleFunctionRegistry.java:187) ~[spring-cloud-function-context-3.1.3.jar!/:3.1.3]
    at org.springframework.cloud.function.context.catalog.BeanFactoryAwareFunctionRegistry.lookup(BeanFactoryAwareFunctionRegistry.java:156) ~[spring-cloud-function-context-3.1.3.jar!/:3.1.3]
    at org.springframework.cloud.function.context.FunctionCatalog.lookup(FunctionCatalog.java:87) ~[spring-cloud-function-context-3.1.3.jar!/:3.1.3]
    at org.springframework.cloud.function.web.util.FunctionWebUtils.doFindFunction(FunctionWebUtils.java:91) ~[spring-cloud-function-web-3.1.3.jar!/:3.1.3]
    at org.springframework.cloud.function.web.util.FunctionWebUtils.findFunction(FunctionWebUtils.java:49) ~[spring-cloud-function-web-3.1.3.jar!/:3.1.3]
    at org.springframework.cloud.function.web.mvc.FunctionHandlerMapping.getHandlerInternal(FunctionHandlerMapping.java:94) ~[spring-cloud-function-web-3.1.3.jar!/:3.1.3]
    at org.springframework.cloud.function.web.mvc.FunctionHandlerMapping.getHandlerInternal(FunctionHandlerMapping.java:41) ~[spring-cloud-function-web-3.1.3.jar!/:3.1.3]
    at org.springframework.web.servlet.handler.AbstractHandlerMapping.getHandler(AbstractHandlerMapping.java:498) ~[spring-webmvc-5.3.9.jar!/:5.3.9]

The method :

  @Bean
  public Function<Claim, Claim> saveClaim() {
      return data -> injectionService.saveClaim(data);
  }

Our dependencies in build.gradle

id 'org.springframework.boot' version '2.5.4'
org.springframework.cloud:spring-cloud-starter-function-web:3.1.3

Can we do something to fix this problem ?

Thanks in advance

  • Is this your actual code? It doesn't actually _throw_ the `InjectionException` that's created but just returns `null`. – Thomas Sep 13 '21 at 09:46
  • I think the error happens before the call to the method – Mathias CARVILLE Sep 13 '21 at 09:57
  • Why did you include that method then? So far the stacktrace you've posted doesn't contain any reference to custom code so it's hard to tell what's causing this. – Thomas Sep 13 '21 at 10:03
  • Most of the time this method is called, but sometimes at starttup we have the exception and the message is not processed – Mathias CARVILLE Sep 13 '21 at 12:05

2 Answers2

0

So this looks like a bug on our end, regardless. . . so, I raised an issue - https://github.com/spring-cloud/spring-cloud-function/issues/741

Basically lookup in function catalog should never result in concurrent modification exception.

That said, what is it that you are doing that results in concurrent lookups? It would be nice if you were to provide a small project that reproduces it and push it to github somewhere so we can tae a look

Oleg Zhurakousky
  • 5,820
  • 16
  • 17
  • Hello Oleg, thanks for your response. The application is integrated in a KNative sequence flow and a pod executing the Java code is started in Kubernetes, when messages are pushed in a Kafka topic, then it stops. We have several messages coming and the processing is parallel, so I think this is why there's a concurrent exception possibility. Our sequence is composed of 2 applications based on spring-cloud-function and both can have the error, but not every time, it is random. So the strategy for us to fix the issue is to upgrade to the next version when it will be ready ? – Mathias CARVILLE Sep 14 '21 at 08:16
  • The issue is addressed and back-ported and the fix will be available with the next 3.1.4 release next week – Oleg Zhurakousky Sep 14 '21 at 12:24
  • Ok thanks, we will upgrade and give you feedback ! – Mathias CARVILLE Sep 14 '21 at 13:29
  • Hello Oleg, I think you have managed to move forward on this issue in repo. Do you know when you will release the 3.1.4, so we can fix the problem on our side ? – Mathias CARVILLE Sep 23 '21 at 09:26
0

The problem is fixed using version 3.1.4 => thanks