Skip to content

Fix NullPointerException when writing json result if not using --output parameter #9

@jingerbread

Description

@jingerbread

When user doesn't specify --output file parameter, json file won't be written because of java.lang.NullPointerException:

bin/benchmark --drivers driver-kafka/kafka-0.yaml workloads/100-partitions-1000K-rate-4-producer.yaml 2>&1 | tee test3.log && grep Aggregated test3.log
...
10:54:22.257 [main] ERROR - Failed to run the workload '100 partitions 1000K rate 4 producer' for driver 'driver-kafka/kafka-0.yaml'
java.lang.NullPointerException: null
        at io.openmessaging.benchmark.Benchmark.lambda$null$0(Benchmark.java:155) [io.openmessaging.benchmark-benchmark-framework-0.0.1-SNAPSHOT.jar:?]
        at java.util.ArrayList.forEach(ArrayList.java:1541) [?:?]
        at io.openmessaging.benchmark.Benchmark.lambda$main$1(Benchmark.java:138) [io.openmessaging.benchmark-benchmark-framework-0.0.1-SNAPSHOT.jar:?]
        at java.util.TreeMap.forEach(TreeMap.java:1002) [?:?]
        at io.openmessaging.benchmark.Benchmark.main(Benchmark.java:129) [io.openmessaging.benchmark-benchmark-framework-0.0.1-SNAPSHOT.jar:?]

Need to fix followig line:

String fileName = arguments.output.length() > 0 ? arguments.output

F.e for

boolean useOutput = (arguments.output != null) && (arguments.output.length() > 0);
String fileName = useOutput? arguments.output: String.format("%s-%s-%s.json", workloadName, driverConfiguration.name,
                                    dateFormat.format(new Date()));

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions