Menu

#14 Exception when end_range is specified but start_range is not

open
Bug (17)
5
2011-10-09
2011-10-08
Michael
No

When specifying the attribute end_range for an integer generator, if start_range is missing then DG throws a NullPointerException. If this is expected behaviour (i.e. start_range and end_range must be specified together) then it should be noted in the documentation since it lists both of these fields as optional. Although the documentation says that if the start_range isn't specified it will be set as default to 1, so start_range shouldn't be required in order to use end_range based on this.

This will cause DG to throw the exception if it's in the xml:
<field>
<attr name="name" value="director_id"/>
<attr name="type" value="INTEGER"/>
<attr name="constraint" value="NOT NULL"/>
<data>
<attr name="type" value="integer"/>
<attr name="seq" value="false"/>
<attr name="end_range" value="7000"/>
</data>

Discussion

  • Nikita

    Nikita - 2011-10-08

    Log the exception in the comments too, please -- I am pretty sure I have a test case for that and it passes, so I might need another one.

     
  • Michael

    Michael - 2011-10-08

    Output from DG:
    db2inst1@ubuntu-school:~/myDG/DG_M/dist$ java -jar DG.jar -d ../data/data/schemas/movie-merged.xml
    0 [main] INFO com.ibm.dg.DataGenerator - Data Generator started. Version: 0.3 Revision: 4380dae05f14+ tip
    App config file:
    /home/db2inst1/myDG/DG_M/dist/config.xml
    DB config file:
    /home/db2inst1/myDG/DG_M/data/data/schemas/movie-merged.xml
    Exception in thread "main" java.lang.NullPointerException
    at com.ibm.dg.generators.IntegerGenerator.parse(IntegerGenerator.java:190)
    at com.ibm.dg.parsing.XMLParser.parseTables(XMLParser.java:545)
    at com.ibm.dg.parsing.XMLParser.parse(XMLParser.java:161)
    at com.ibm.dg.DataGenerator.generatorRun(DataGenerator.java:270)
    at com.ibm.dg.DataGeneratorCLI.main(DataGeneratorCLI.java:24)
    1241 [Thread-0] WARN com.ibm.dg.DataGenerator - Shutting down.

    When this field is in the first table in the XML file:
    <field>
    <attr name="name" value="director_id"/>
    <attr name="type" value="INTEGER"/>
    <attr name="constraint" value="NOT NULL"/>
    <data>
    <attr name="type" value="integer"/>
    <attr name="seq" value="false"/>
    <!--
    <attr name="start_range" value="1"/>
    -->
    <attr name="end_range" value="7000"/>
    </data>
    </field>

     
  • Nikita

    Nikita - 2011-10-09
    • assigned_to: nobody --> xueyuan0106