About Question enthuware.oce-ejbd.v6.2.395 :
Moderators: Site Manager, fjwalraven
-
- Posts: 16
- Joined: Tue Nov 08, 2016 9:39 pm
- Contact:
About Question enthuware.oce-ejbd.v6.2.395 :
Hi,
I have the following doubt:
¿Can the result be "1000"? if the @AroundInvoke code were:
@AroundInvoke
public Object iaM1(InvocationContext ic) throws Exception {
return "1000";
}
Thanks in advance
I have the following doubt:
¿Can the result be "1000"? if the @AroundInvoke code were:
@AroundInvoke
public Object iaM1(InvocationContext ic) throws Exception {
return "1000";
}
Thanks in advance
-
- Posts: 16
- Joined: Tue Nov 08, 2016 9:39 pm
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.395 :
According to "enthuware.oce-ejbd.v6.2.519" now I understand that the result of my example code will be correctly "1000".
-
- Posts: 9
- Joined: Wed Feb 22, 2017 4:32 am
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.395 :
I compare this question with question no. 13 in Test 1. In both questions the actual bean method returns a String. Neither of the interceptors in the questions return Object or call ic.proceed. So the explanation is somewhat confusing: "Further, the return value of the interceptor method must be Object otherwise a ClassCastException will be thrown at Runtime". It rather seems that the return type could be the same as in the bean method without ClassCastException. Could you clarify whats going on for me? Can the explanation be a Little more clear? Maybe the explanation in question 13 test 1 should be the exact same as in this question too?
-
- Site Admin
- Posts: 10062
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.395 :
The return type as declared in the declaration of interceptor method must be Object. This is required by the specification.
The actual type of the object returned by the interceptor must be compatible with the return type of the bean's method.
In case of 2.395, the return type of the bean method is String, but the interceptor is returning an Integer object. Thus, when the container tries to cast an Integer object to String, a CCE will be thrown. In case of 2.394, the value returned by the interceptor method is String, which is same as that of the type of the return value of the bean's method, so there is no problem.
HTH,
Paul.
The actual type of the object returned by the interceptor must be compatible with the return type of the bean's method.
In case of 2.395, the return type of the bean method is String, but the interceptor is returning an Integer object. Thus, when the container tries to cast an Integer object to String, a CCE will be thrown. In case of 2.394, the value returned by the interceptor method is String, which is same as that of the type of the return value of the bean's method, so there is no problem.
HTH,
Paul.
If you like our products and services, please help us by posting your review here.
-
- Posts: 9
- Joined: Wed Feb 22, 2017 4:32 am
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.395 :
I understand. But maybe the explanation in enthuware.oce-ejbd.v6.2.394 (wich I got in test 1 question 13) should explain a Little about it's being OK to return String in the interceptor as it's compatible with the business method return value? I had no problem with enthuware.oce-ejbd.v6.2.394 and thought I knew Everything about that question, but then I took test 2 and got enthuware.oce-ejbd.v6.2.395 and answered wrong =/
-
- Posts: 9
- Joined: Wed Feb 22, 2017 4:32 am
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.395 :
I Think a more general explanation that is exactly the same for enthuware.oce-ejbd.v6.2.394 and enthuware.oce-ejbd.v6.2.395 could help us Learning this concept =)
-
- Site Admin
- Posts: 10062
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.395 :
Good point. Will update.
thank you for your feedback!
Paul.
thank you for your feedback!
Paul.
If you like our products and services, please help us by posting your review here.
-
- Posts: 9
- Joined: Wed Feb 22, 2017 4:32 am
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.395 :
Now I see that question enthuware.oce-ejbd.v6.2.519 is quite similar. Here the business method return type is "double" but the Interceptor returns "Double" (without Calling proceed). The explanation for 2.394 and 2.395 should cover this example to. How come that the "Integer instead of String" return generates ClassCastException at runtime when the "Double instead of double" does not? I Think I've forgotten some basic Java type conversion here! Anyway keeping a red line in the explanation by giving enthuware.oce-ejbd.v6.2.519 the same explanation as 2.394 and 2.395 might be a good idea!
-
- Site Admin
- Posts: 10062
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.395 :
Double instead of double (and vice-versa) is ok because of auto-unboxing/boxing.
Will update 2.519 as well.
Paul.
Will update 2.519 as well.
Paul.
If you like our products and services, please help us by posting your review here.
Who is online
Users browsing this forum: No registered users and 55 guests