harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Paulex Yang (JIRA)" <j...@apache.org>
Subject [jira] Updated: (HARMONY-618) [classlib][nio]java.nio.channels.nio.SelectorProvider should not use thread's context classloader to load provider class defined in property file
Date Mon, 19 Jun 2006 08:43:30 GMT
     [ http://issues.apache.org/jira/browse/HARMONY-618?page=all ]

Paulex Yang updated HARMONY-618:
--------------------------------

    Attachment: Harmony-618.diff

Please try this patch, thank you. 

The patch doesn't include the regression test, because the test is not applicable to run as
API test by JUnit, the method under test(SelectProvider.provider()) is static, and the provider
it returns will keep constant, so it is impossible to separate the effect of mock with other
API unit tests in same JVM process, maybe it is a good candidate as bootclasspath implementation
test if changing the this test against package private method SelectorProvider.loadProviderByProperty()),
but which needs to relayout the NIO module tests, and I think it worths a separated JIRA.


> [classlib][nio]java.nio.channels.nio.SelectorProvider should not use thread's context
classloader to load provider class defined in property file
> -------------------------------------------------------------------------------------------------------------------------------------------------
>
>          Key: HARMONY-618
>          URL: http://issues.apache.org/jira/browse/HARMONY-618
>      Project: Harmony
>         Type: Bug

>   Components: Classlib
>     Reporter: Paulex Yang
>     Priority: Minor
>  Attachments: Harmony-618.diff
>
> SelectorProvider.provider() should not use the Thread.currentThread().getContextClassLoader()
to load the provider class defined in property file, test shows RI doesn't uses it.
> Run the test below, and 
> RI prints: pass
> while Harmony prints: fail
> public class SelectorProviderTest {
>     private static final Class CLASS1 = MockSelectorProvider1.class;
>     private static final Class CLASS2 = MockSelectorProvider2.class;
>     private static final String KEY = "java.nio.channels.spi.SelectorProvider";
>     public static void main(String[] args) {
>         System.setProperty(KEY, CLASS1.getName());
>         Thread.currentThread().setContextClassLoader(new MockClassLoader());
>         SelectorProvider provider = SelectorProvider.provider();
>         if (provider.getClass() == CLASS1) {
>             System.out.println("pass");
>         } else {
>             System.out.println("fail");
>         }
>     }
>     private static class MockClassLoader extends ClassLoader {
>         public Class<?> loadClass(String name) throws ClassNotFoundException {
>             return CLASS2;
>         }
>     }
>     
>     public static class MockSelectorProvider2 extends SelectorProvider{
>         public DatagramChannel openDatagramChannel() throws IOException {
>             return null;
>         }
>         public Pipe openPipe() throws IOException {
>             return null;
>         }
>         public AbstractSelector openSelector() throws IOException {
>             return null;
>         }
>         public ServerSocketChannel openServerSocketChannel() throws IOException {
>             return null;
>         }
>         public SocketChannel openSocketChannel() throws IOException {
>             return null;
>         }
>     }
>     public static class MockSelectorProvider1 extends SelectorProvider{
>         public DatagramChannel openDatagramChannel() throws IOException {
>             return null;
>         }
>         public Pipe openPipe() throws IOException {
>             return null;
>         }
>         public AbstractSelector openSelector() throws IOException {
>             return null;
>         }
>         public ServerSocketChannel openServerSocketChannel() throws IOException {
>             return null;
>         }
>         public SocketChannel openSocketChannel() throws IOException {
>             return null;
>         }
>     }
> }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


Mime
View raw message