Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.2.0
    • Fix Version/s: 2.3.0
    • Component/s: None
    • Labels:
      None

      Description

      Starting at line 113 in SQLResources.java
      Elements with tagname "sqlDefs" are scanned for the name of the class we want the sql-strings for.
      At line 125 if this element isnt found, by assuming "sectionElement==null", an exception is thrown.
      So the question is, how can sectionElement be ever null if the "sqlDef" we are looking for isnt in the xml-file?

      For your convenience:
      " ...
      // Now get the section defining sql for the repository required.
      113 NodeList sections = sqlDoc.getElementsByTagName("sqlDefs");
      114 int sectionsCount = sections.getLength();
      Element sectionElement = null;
      for (int i = 0; i < sectionsCount; i++ ) {
      sectionElement = (Element)(sections.item);
      String sectionName = sectionElement.getAttribute("name");
      if ( sectionName != null && sectionName.equals(sqlDefsSection) )

      { break; }

      }
      125 if ( sectionElement == null )

      { StringBuffer exceptionBuffer = new StringBuffer(64) .append("Error loading sql definition file. ") .append("The element named \'") .append(sqlDefsSection) .append("\' does not exist."); throw new RuntimeException(exceptionBuffer.toString()); }

      ... "

        Activity

        Hide
        bago Stefano Bagnara added a comment -

        I don't understand the problem.

        Isn't the exception thrown when you remove all the sqldef from your sqlResources.xml?

        Show
        bago Stefano Bagnara added a comment - I don't understand the problem. Isn't the exception thrown when you remove all the sqldef from your sqlResources.xml?
        Hide
        mark_daring Mark Daring added a comment -

        This logic doesnt detect missing sqldef, it only throws an exception if theres no sqldef at all.
        This will fix it:

        Element sectionElement = null;
        boolean found = false;
        for (int i = 0; i < sectionsCount; i++ ) {
        sectionElement = (Element)(sections.item);
        String sectionName = sectionElement.getAttribute("name");
        if ( sectionName != null && sectionName.equals(sqlDefsSection) )

        { found = true; break; }

        }
        if ( !found )

        { StringBuffer exceptionBuffer = new StringBuffer(64) .append("Error loading sql definition file. ") .append("The element named \'") .append(sqlDefsSection) .append("\' does not exist."); throw new RuntimeException(exceptionBuffer.toString()); }
        Show
        mark_daring Mark Daring added a comment - This logic doesnt detect missing sqldef, it only throws an exception if theres no sqldef at all. This will fix it: Element sectionElement = null; boolean found = false; for (int i = 0; i < sectionsCount; i++ ) { sectionElement = (Element)(sections.item ); String sectionName = sectionElement.getAttribute("name"); if ( sectionName != null && sectionName.equals(sqlDefsSection) ) { found = true; break; } } if ( !found ) { StringBuffer exceptionBuffer = new StringBuffer(64) .append("Error loading sql definition file. ") .append("The element named \'") .append(sqlDefsSection) .append("\' does not exist."); throw new RuntimeException(exceptionBuffer.toString()); }
        Hide
        bago Stefano Bagnara added a comment -

        Thanx Mark, fixed!

        Show
        bago Stefano Bagnara added a comment - Thanx Mark, fixed!
        Hide
        danny@apache.org Danny Angus added a comment -

        Closing issue fixed in released version.

        Show
        danny@apache.org Danny Angus added a comment - Closing issue fixed in released version.

          People

          • Assignee:
            bago Stefano Bagnara
            Reporter:
            cogens Mark Daring
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development