Derby
  1. Derby
  2. DERBY-4888

ClassCastException when calling boolean meta-data functions with 10.7 client against 10.6 server

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 10.7.1.1
    • Fix Version/s: 10.7.1.1
    • Component/s: JDBC, Network Client
    • Labels:
      None
    • Bug behavior facts:
      Regression

      Description

      I noticed that DESCRIBE didn't work when I tried to connect to a 10.6 server with ij/client driver at version 10.7.

      ij> describe t;
      JAVA ERROR: java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Boolean
      java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Boolean
      at org.apache.derby.client.am.DatabaseMetaData.getMetaDataInfoBoolean(DatabaseMetaData.java:2401)
      at org.apache.derby.client.am.DatabaseMetaData.storesLowerCaseIdentifiers(DatabaseMetaData.java:191)
      at org.apache.derby.impl.tools.ij.ij.caIdentifier(ij.java:3040)
      at org.apache.derby.impl.tools.ij.ij.DescTableStatement(ij.java:1624)
      at org.apache.derby.impl.tools.ij.ij.ijStatement(ij.java:1121)
      at org.apache.derby.impl.tools.ij.utilMain.runScriptGuts(utilMain.java:341)
      at org.apache.derby.impl.tools.ij.utilMain.go(utilMain.java:261)
      at org.apache.derby.impl.tools.ij.Main.go(Main.java:229)
      at org.apache.derby.impl.tools.ij.Main.mainCore(Main.java:184)
      at org.apache.derby.impl.tools.ij.Main.main(Main.java:75)
      at org.apache.derby.tools.ij.main(ij.java:59)
      at org.apache.derby.iapi.tools.run.main(run.java:53)

      1. boolean.diff
        0.6 kB
        Knut Anders Hatlen
      2. test.diff
        1 kB
        Knut Anders Hatlen

        Activity

        Hide
        Knut Anders Hatlen added a comment -

        The problem appears to be that the client thinks 10.6 sends boolean meta-data values as java.lang.Boolean objects because of a typo in this method in client.am.DatabaseMetaData:

        final public boolean serverSupportsBooleanValues()

        { return supportsUDTs_; }

        It should return supportsBooleanValues_ (true for server >= 10.7) instead of supportsUDTs_ (true for server >= 10.6). The attached patch makes the ClassCastException go away for me.

        Show
        Knut Anders Hatlen added a comment - The problem appears to be that the client thinks 10.6 sends boolean meta-data values as java.lang.Boolean objects because of a typo in this method in client.am.DatabaseMetaData: final public boolean serverSupportsBooleanValues() { return supportsUDTs_; } It should return supportsBooleanValues_ (true for server >= 10.7) instead of supportsUDTs_ (true for server >= 10.6). The attached patch makes the ClassCastException go away for me.
        Hide
        Knut Anders Hatlen added a comment -

        Attaching a test case that exposes the bug. When running the compatibility test with 10.6.1.0 server and 10.7 client, I get this error:

        There was 1 error:
        1) testJDBCDriver(org.apache.derbyTesting.functionTests.tests.junitTests.compatibility.JDBCDriverTest)java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Boolean
        at org.apache.derby.client.am.DatabaseMetaData.getMetaDataInfoBoolean(DatabaseMetaData.java:2401)
        at org.apache.derby.client.am.DatabaseMetaData.storesLowerCaseIdentifiers(DatabaseMetaData.java:191)
        at org.apache.derbyTesting.functionTests.tests.junitTests.compatibility.JDBCDriverTest.derby_4888_test(JDBCDriverTest.java:383)
        at org.apache.derbyTesting.functionTests.tests.junitTests.compatibility.JDBCDriverTest.testJDBCDriver(JDBCDriverTest.java:257)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at org.apache.derbyTesting.functionTests.tests.junitTests.compatibility.CompatibilitySuite.main(CompatibilitySuite.java:147)

        The test case passes with the suggested fix.

        Show
        Knut Anders Hatlen added a comment - Attaching a test case that exposes the bug. When running the compatibility test with 10.6.1.0 server and 10.7 client, I get this error: There was 1 error: 1) testJDBCDriver(org.apache.derbyTesting.functionTests.tests.junitTests.compatibility.JDBCDriverTest)java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Boolean at org.apache.derby.client.am.DatabaseMetaData.getMetaDataInfoBoolean(DatabaseMetaData.java:2401) at org.apache.derby.client.am.DatabaseMetaData.storesLowerCaseIdentifiers(DatabaseMetaData.java:191) at org.apache.derbyTesting.functionTests.tests.junitTests.compatibility.JDBCDriverTest.derby_4888_test(JDBCDriverTest.java:383) at org.apache.derbyTesting.functionTests.tests.junitTests.compatibility.JDBCDriverTest.testJDBCDriver(JDBCDriverTest.java:257) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at org.apache.derbyTesting.functionTests.tests.junitTests.compatibility.CompatibilitySuite.main(CompatibilitySuite.java:147) The test case passes with the suggested fix.
        Hide
        Bryan Pendleton added a comment -

        Both the test and the fix look clear and straightforward. Thanks for catching this problem!

        +1.

        Show
        Bryan Pendleton added a comment - Both the test and the fix look clear and straightforward. Thanks for catching this problem! +1.
        Hide
        Knut Anders Hatlen added a comment -

        Thanks for taking a look at the patch, Bryan!

        Committed revision 1031973.

        Show
        Knut Anders Hatlen added a comment - Thanks for taking a look at the patch, Bryan! Committed revision 1031973.

          People

          • Assignee:
            Knut Anders Hatlen
            Reporter:
            Knut Anders Hatlen
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development