karaf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Anton Johansson (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (KARAF-5177) Mismatching interface and implementation return type causes generic type loss
Date Fri, 02 Jun 2017 13:15:04 GMT

     [ https://issues.apache.org/jira/browse/KARAF-5177?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Anton Johansson updated KARAF-5177:
-----------------------------------
    Description: 
Hey!

We're running a quite old Karaf now, and we have plans on upgrading. We're running 2.4.2.

We just noticed a very strange and dangerous thing in our environment.

Say I have an interface:

{code}
public interface ITest {
    Collection<MyType> getTypes();
}
{code}

... and an implementation:
{code}
public class Test implements ITest {
    List<MyType> getTypes() {
        return emptyList();
    }
}
{code}

Notice the mismatching return types. We do some reflection based scanning when we create our
services. So if we analyze the class Test, and get the method #getTypes(), and then get the
generic return type (#getGenericReturnType()), it will give us the following declaration:
java.util.Collection

We should really get this declaration:
java.util.List<com.mypackage.MyType>

If I change so the return types match, I do get the correct declaration. As you can see, we
lose the generic information about the return type, which is devastation for us. It's also
very hard to notice this issue, because the generic return type is only used in some cases,
in a clustered environment.

Do you know why this happens?

  was:
Hey!

We're running a quite old Karaf now, and we have plans on upgrading. We're running 2.4.2.

We just noticed a very strange and dangerous thing in our environment.

Say I have an interface:

public interface ITest {
    Collection<MyType> getTypes();
}

... and an implementation:
public class Test implements ITest {
    List<MyType> getTypes() {
        return emptyList();
    }
}

Notice the mismatching return types. We do some reflection based scanning when we create our
services. So if we analyze the class Test, and get the method #getTypes(), and then get the
generic return type (#getGenericReturnType()), it will give us the following declaration:
java.util.Collection

We should really get this declaration:
java.util.List<com.mypackage.MyType>

If I change so the return types match, I do get the correct declaration. As you can see, we
lose the generic information about the return type, which is devastation for us. It's also
very hard to notice this issue, because the generic return type is only used in some cases,
in a clustered environment.

Do you know why this happens?


> Mismatching interface and implementation return type causes generic type loss
> -----------------------------------------------------------------------------
>
>                 Key: KARAF-5177
>                 URL: https://issues.apache.org/jira/browse/KARAF-5177
>             Project: Karaf
>          Issue Type: Bug
>          Components: karaf-core
>            Reporter: Anton Johansson
>
> Hey!
> We're running a quite old Karaf now, and we have plans on upgrading. We're running 2.4.2.
> We just noticed a very strange and dangerous thing in our environment.
> Say I have an interface:
> {code}
> public interface ITest {
>     Collection<MyType> getTypes();
> }
> {code}
> ... and an implementation:
> {code}
> public class Test implements ITest {
>     List<MyType> getTypes() {
>         return emptyList();
>     }
> }
> {code}
> Notice the mismatching return types. We do some reflection based scanning when we create
our services. So if we analyze the class Test, and get the method #getTypes(), and then get
the generic return type (#getGenericReturnType()), it will give us the following declaration:
> java.util.Collection
> We should really get this declaration:
> java.util.List<com.mypackage.MyType>
> If I change so the return types match, I do get the correct declaration. As you can see,
we lose the generic information about the return type, which is devastation for us. It's also
very hard to notice this issue, because the generic return type is only used in some cases,
in a clustered environment.
> Do you know why this happens?



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Mime
View raw message