From 9ec650bcf0518de44d780c575bbf7a41264b6991 Mon Sep 17 00:00:00 2001 From: Andy Pavlo Date: Wed, 16 Sep 2015 15:51:32 -0400 Subject: [PATCH] Better safety checking for null Wikipedia config parameters #102 --- .../wikipedia/WikipediaBenchmark.java | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/com/oltpbenchmark/benchmarks/wikipedia/WikipediaBenchmark.java b/src/com/oltpbenchmark/benchmarks/wikipedia/WikipediaBenchmark.java index 3f8e183c5..a5079345c 100644 --- a/src/com/oltpbenchmark/benchmarks/wikipedia/WikipediaBenchmark.java +++ b/src/com/oltpbenchmark/benchmarks/wikipedia/WikipediaBenchmark.java @@ -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(this.rng(), RevisionHistograms.COMMENT_LENGTH); this.minorEdit = new FlatHistogram(this.rng(), RevisionHistograms.MINOR_EDIT);