harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ruth Cao (JIRA)" <j...@apache.org>
Subject [jira] Created: (HARMONY-4205) [classlib][sql] java.sql.DriverManager cannot deregister a driver as many times a registering it
Date Mon, 18 Jun 2007 07:03:51 GMT
[classlib][sql] java.sql.DriverManager cannot deregister a driver as many times a registering
it
------------------------------------------------------------------------------------------------

                 Key: HARMONY-4205
                 URL: https://issues.apache.org/jira/browse/HARMONY-4205
             Project: Harmony
          Issue Type: Bug
          Components: Classlib
         Environment: Windows XP / Linux
            Reporter: Ruth Cao


The following test case shows the bug:

 public void test_registerDriver_MultiTimes() throws SQLException {
        int register_count = 10;
        int deregister_count = 1;

        Driver dummy = new DummyDriver();
        DriverManager.registerDriver(new BadDummyDriver());
        for (int i = 0; i < register_count; i++) {
            DriverManager.registerDriver(dummy);
        }
        DriverManager.registerDriver(new BadDummyDriver());
        for (int i = 0; i < deregister_count; i++) {
            DriverManager.deregisterDriver(dummy);
        }
        Driver d = DriverManager.getDriver("jdbc:dummy_protocol:dummy_subname");
        assertNotNull(d);
    }
    
    private static class BadDummyDriver extends DummyDriver {
        public boolean acceptsURL(String url) {
            return false;
        }
    }

    private static class DummyDriver implements Driver {

        String goodurl = "jdbc:dummy_protocol:dummy_subname";

        public boolean acceptsURL(String url) {
            return url.equals(goodurl);
        }

        public Connection connect(String url, Properties info) {
            return null;
        }

        public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) {
            return null;
        }

        public int getMajorVersion() {
            return 0;
        }

        public int getMinorVersion() {
            return 0;
        }

        public boolean jdbcCompliant() {
            return true;
        }

    }

It seems that this happens due to Harmony uses HashSet as the data structure to store the
driver list, which does not allow duplications. 

I'll create a patch for this soon, thanks.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message