Uploaded image for project: 'Solr'
  1. Solr
  2. SOLR-4446

exception swallowed, NPE created upon trouble getting JNDI connection

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Won't Fix
    • 4.1
    • None
    • None

    Description

      I am trying to use a JNDI connection, but an error occurs getting the connection. The error is swallowed and obscured by a NullPointerException. See comments inline below.

      JdbcDataSource.java
        protected Callable<Connection> createConnectionFactory(final Context context,
                                             final Properties initProps) {
      ...
          final String jndiName = initProps.getProperty(JNDI_NAME);
          final String url = initProps.getProperty(URL); /* is null */
          final String driver = initProps.getProperty(DRIVER); /* is null */
      ...
          return factory = new Callable<Connection>() {
            @Override
            public Connection call() throws Exception {
      ...
              try {
                if(url != null){
                  c = DriverManager.getConnection(url, initProps);
                } else if(jndiName != null){
      ...
      /* error occurs */
      ...
                }
              } catch (SQLException e) {
      /* exception handler assumes that try block followed "url != null" path; in the JNDI case, driver is null, and DocBuilder.loadClass(..) throws a NPE */
                Driver d = (Driver) DocBuilder.loadClass(driver, context.getSolrCore()).newInstance();
                c = d.connect(url, initProps);
              }
      ...
            }
          };
        }
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              kgeis Ken Geis
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: