Closed elena-bondareva closed 6 years ago
You have invalid parameter types in your listener method. Correct signature is:
(C, ProcessingStage<C, ? super T>):ProcessingStage<C, ? super T>
Your listener method's signature is:
(C, BaseLinearProcessingStage<SelectContext<ITEntity>, ITEntity>):BaseLinearProcessingStage<SelectContext<ITEntity>, ITEntity>
In runtime this is causing a narrowing type conversion:
ProcessingStage -> BaseLinearProcessingStage
(you may see what is really passed to the listener method in ListenerInvocation class)
This type of narrowing type conversions is forbidden in Java, so you're getting a ClassCastException.
General reasoning for this is that:
Oh, and in fact lambdas are probably more lenient with regards to runtime parameter types, so your method could work, if the object being passed had proper type (pure speculation, I haven't checked). But in your case the second argument has com.nhl.link.rest.runtime.listener.ListenerInvocation$$Lambda$103/887401986
type, so it's totally different type than BaseLinearProcessingStage
, hence ClassCastException.
Not to argue about the (in)correctness of the method signature, but this actually used to work in prior LR versions (This code is from Bootique integration tests). So while we have no plans of "fixing" anything here, this issue may be helpful in documenting this upgrade incompatibility.
I guess the mock stage used to be an instance of BaseLinearProcessingStage
in the past, and now it's a lambda
IIRC this was a placeholder to document the upgrade issue. We are well past 2.7 release, so I guess we can close this now.
Annotated listeners were deprecated in favor of the functional interceptor API since 2.7. Consider a use case for the deprecated listener.
Having added the listener into LinkRest request processor builder, like
do GET request on a server:
The exception is thrown: