Github user neykov commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/663#discussion_r31215310
  
    --- Diff: 
usage/rest-server/src/main/java/brooklyn/rest/security/provider/DelegatingSecurityProvider.java
 ---
    @@ -94,10 +97,16 @@ private synchronized SecurityProvider loadDelegate() {
                     delegate = constructor.newInstance(mgmt);
                 } catch (Exception e) {
                     constructor = clazz.getConstructor();
    -                delegate = constructor.newInstance();
    +                Object delegateO = constructor.newInstance();
    +                if (!(delegateO instanceof SecurityProvider)) {
    +                    // if classloaders get mangled it will be a different 
CL's SecurityProvider
    +                    throw new ClassCastException("Delegate is either not a 
security provider or has an incompatible classloader: "+delegateO);
    --- End diff --
    
    The reason for the different class loaders is that 
`BrooklynApiRestClientTest` [configures the `WebAppContext` with 
`.setExtraClasspath("./target/test-rest-server/");`](https://github.com/apache/incubator-brooklyn/blob/317b69e17338bb541bc903b5ed97e30e58a929a6/usage/rest-client/src/test/java/brooklyn/rest/client/BrooklynApiRestClientTest.java#L70).
 The additional path contains the server classes, but not the test classes. 
This causes the test classes to be loaded through the app class loader, while 
the web app class loader sees the non-test classes.
    Why the extra classpath? If there's not a particular reason, then better 
let the app classloader handle the server classes. This will also help when 
changing them and running the tests in the client project in Eclipse - 
currently both projects need to be rebuild for the changes to take effect.
    If there's a good reason to keep the extra classpath, then in pom.xml 
install the `<classifier>tests</classifier>` of `brooklyn-rest-server`.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to