[
https://issues.apache.org/jira/browse/CAMEL-7448?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14017359#comment-14017359
]
Ben O'Day edited comment on CAMEL-7448 at 6/9/14 4:14 AM:
----------------------------------------------------------
why not just throw the exception if the expression is null AND
maximumRequestsPerPeriod hasn't been set otherwise (by a previous message,
etc). That would prevent NULL expression evaluations for the first message and
allow for subsequent ones, etc...
something like this in Throttler calculateDelay()...
{code:title=Throttler.java|borderStyle=solid}
Object result = maxRequestsPerPeriodExpression.evaluate(exchange,
Object.class);
//if (result == null) {
if (maximumRequestsPerPeriod == 0 && result == null) {
throw new RuntimeExchangeException("The max requests per period
expression was evaluated as null: " + maxRequestsPerPeriodExpression, exchange);
}
{code}
was (Author: boday):
why not just throw the exception if the expression is null AND
maximumRequestsPerPeriod hasn't been set otherwise (by a previous message,
etc). That would prevent NULL expression evaluations for the first message and
allow for subsequent ones, etc...
something like this in Throttler calculateDelay()...
Object result = maxRequestsPerPeriodExpression.evaluate(exchange,
Object.class);
//if (result == null) {
if (maximumRequestsPerPeriod == 0 && result == null) {
throw new RuntimeExchangeException("The max requests per period
expression was evaluated as null: " + maxRequestsPerPeriodExpression, exchange);
}
> throttle EIP - unchanged value
> ------------------------------
>
> Key: CAMEL-7448
> URL: https://issues.apache.org/jira/browse/CAMEL-7448
> Project: Camel
> Issue Type: Bug
> Components: camel-core, eip
> Affects Versions: 2.13.1
> Reporter: Elvio Caruana
> Assignee: Ben O'Day
> Priority: Minor
> Fix For: 2.13.2, 2.14.0
>
>
> Throttler Documentation [1] states "If the header is absent, then the
> Throttler uses the old value. So that allows you to only provide a header if
> the value is to be changed".
> however if the expression evaluates to null (header missing from message) the
> Throttler throws an exception (Throttler.java:108).
> The workaround is to ensure that all messages carry the value (if the value
> is the same no changes will take affect). Adding an option to turn this on
> and off (e.g. allowNullException) would make it much easier to use (as per
> camel-users thread [2]).
> [1] http://camel.apache.org/throttler.html
> [2]
> http://camel.465427.n5.nabble.com/throttle-EIP-unchanged-value-td5751300.html
--
This message was sent by Atlassian JIRA
(v6.2#6252)