Rob Ratcliffe created CAMEL-20841:
-------------------------------------
Summary: DataSonnet expressions are removed under memory load
Key: CAMEL-20841
URL: https://issues.apache.org/jira/browse/CAMEL-20841
Project: Camel
Issue Type: Bug
Affects Versions: 4.6.0, 4.0-M1
Reporter: Rob Ratcliffe
Fix For: 4.6.0
*Scenario:*
When there is a Camel/Spring Boot API project where there are a large amount of
DataSonnet (DS) scripts
And when the application is under memory load or runs for a long time, some or
ALL DS scripts are removed from the mapperCache
And once they are removed from the mapperCache, then a call to an API endpoint
that contains that DS script will be unable to be evaluated and the API call
will continue to fail because the expression isn't re-added to the mapperCache
*What I expect to happen instead:*
The API is able to recover and re-add missing DS scripts.
*The error returned is:*
{code:java}
Caused by: java.lang.IllegalStateException: Datasonnet expression not
initialized at
org.apache.camel.language.datasonnet.DatasonnetExpression.lambda$doEvaluate$0(DatasonnetExpression.java:138)
at java.base/java.util.Optional.orElseThrow(Optional.java:403) at
org.apache.camel.language.datasonnet.DatasonnetExpression.doEvaluate(DatasonnetExpression.java:138)
at
org.apache.camel.language.datasonnet.DatasonnetExpression.evaluate(DatasonnetExpression.java:92){code}
>From what I can tell, Camel 3.7 didn't have this issue. It looks like the DS
>scripts have been stored in an LRUSoftCache for a long time and is designed
>this way so that expressions are removed to prevent OutOfMemoryError. However,
>in Camel 4 the mapper became pre-initialized and .lookup() was used instead of
>.computeIfMiss().
Camel 3.7:
[https://github.com/apache/camel/blob/camel-3.7.x/components/camel-datasonnet/src/main/java/org/apache/camel/language/datasonnet/DatasonnetExpression.java#L143]
Camel 4:
[https://github.com/apache/camel/blob/main/components/camel-datasonnet/src/main/java/org/apache/camel/language/datasonnet/DatasonnetExpression.java#L137]
*Project that replicates this error:*
[https://github.com/rlratcliffe/replicate-ds-error]
--
This message was sent by Atlassian Jira
(v8.20.10#820010)