Skip to content
This repository has been archived by the owner on Aug 23, 2021. It is now read-only.

Commit

Permalink
Better safety checking for null Wikipedia config parameters #102
Browse files Browse the repository at this point in the history
  • Loading branch information
apavlo committed Sep 16, 2015
1 parent 8af56c8 commit 9ec650b
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/com/oltpbenchmark/benchmarks/wikipedia/WikipediaBenchmark.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,26 @@ public WikipediaBenchmark(WorkloadConfiguration workConf) {
super("wikipedia", workConf, true);

XMLConfiguration xml = workConf.getXmlConfig();
this.traceInput = (xml != null && xml.containsKey("tracefile") ? new File(xml.getString("tracefile")) : null);
if (xml != null && xml.containsKey("tracefile")) {
this.traceInput = new File(xml.getString("tracefile"));
} else {
this.traceInput = null;
}
if (xml != null && xml.containsKey("traceOut")) {
this.traceSize = xml.getInt("traceOut");
this.traceOutput = new File(xml.getString("tracefile"));
this.traceOutputDebug = new File(xml.getString("tracefiledebug"));
} else {
this.traceSize = 0;
}
if (xml != null && xml.containsKey("tracefile")) {
this.traceOutput = new File(xml.getString("tracefile"));
} else {
this.traceOutput = null;
this.traceOutputDebug = null;
}
if (xml != null && xml.containsKey("tracefiledebug")) {
this.traceOutputDebug = new File(xml.getString("tracefiledebug"));
} else {
this.traceOutputDebug = null;
}

this.commentLength = new FlatHistogram<Integer>(this.rng(), RevisionHistograms.COMMENT_LENGTH);
this.minorEdit = new FlatHistogram<Integer>(this.rng(), RevisionHistograms.MINOR_EDIT);
Expand Down

3 comments on commit 9ec650b

@ddossant
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still getting a null error. Here is what my config file for the trace file looks like:

C:\Users\IBM_ADMIN\Documents\GitHub\oltpbench\config\traces\wikipedia-100k.trace
10
<base_ip>10.1.</base_ip>

@apavlo
Copy link
Member Author

@apavlo apavlo commented on 9ec650b Sep 22, 2015 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ddossant
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

C:\Users\IBM_ADMIN\Documents\GitHub\oltpbench>oltpbenchmark.bat -b wikipedia -c
config/sample_wiki_config.xml --create=true --load=true
Exception in thread "main" java.lang.RuntimeException: Failed to create new inst
ance of WikipediaBenchmark
at com.oltpbenchmark.util.ClassUtil.newInstance(ClassUtil.java:182)
at com.oltpbenchmark.util.ClassUtil.newInstance(ClassUtil.java:166)
at com.oltpbenchmark.DBWorkload.main(DBWorkload.java:231)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)

    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Sou

rce)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.oltpbenchmark.util.ClassUtil.newInstance(ClassUtil.java:180)
... 2 more
Caused by: java.lang.NullPointerException
at java.io.File.(Unknown Source)
at com.oltpbenchmark.benchmarks.wikipedia.WikipediaBenchmark.(Wiki
pediaBenchmark.java:65)
... 7 more

Please sign in to comment.