[ https://issues.apache.org/jira/browse/CASSANDRA-14426?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16457738#comment-16457738
]
Jeff Jirsa commented on CASSANDRA-14426:
----------------------------------------
Explicitly, this is what I propose (and I'm happy to do it on commit for you):
{code}
diff --git a/tools/stress/src/org/apache/cassandra/stress/StressProfile.java b/tools/stress/src/org/apache/cassandra/stress/StressProfile.java
index 6c44ff298a..2338873a8d 100644
--- a/tools/stress/src/org/apache/cassandra/stress/StressProfile.java
+++ b/tools/stress/src/org/apache/cassandra/stress/StressProfile.java
@@ -499,6 +499,10 @@ public class StressProfile implements Serializable
}
}
+ if (insert == null)
+ insert = new HashMap<>();
+ lowerCase(insert);
+
//Non PK Columns
StringBuilder sb = new StringBuilder();
if (!isKeyOnlyTable)
@@ -543,7 +547,7 @@ public class StressProfile implements Serializable
//Put PK predicates at the end
sb.append(pred);
- if (insert != null && insert.containsKey("condition"))
+ if (insert.containsKey("condition"))
{
sb.append(" " + insert.get("condition"));
insert.remove("condition");
@@ -563,10 +567,6 @@ public class StressProfile implements Serializable
sb.append(") ").append("values(").append(value).append(')');
}
- if (insert == null)
- insert = new HashMap<>();
- lowerCase(insert);
-
partitions = select(settings.insert.batchsize, "partitions", "fixed(1)",
insert, OptionDistribution.BUILDER);
selectchance = select(settings.insert.selectRatio, "select", "fixed(1)/1",
insert, OptionRatioDistribution.BUILDER);
rowPopulation = select(settings.insert.rowPopulationRatio, "row-population",
"fixed(1)/1", insert, OptionRatioDistribution.BUILDER);
{code}
> cassandra-stress throws NPE if insert section isn't specified in user profile
> -----------------------------------------------------------------------------
>
> Key: CASSANDRA-14426
> URL: https://issues.apache.org/jira/browse/CASSANDRA-14426
> Project: Cassandra
> Issue Type: Bug
> Components: Stress
> Reporter: Alex Ott
> Assignee: Alex Ott
> Priority: Trivial
> Fix For: 4.x
>
>
> When user profile file is used, and insert section isn't specified, then cassandra-stress
is using default values instead.
> Since support for LWTs was added, absence of the insert section lead to throwing of NullPointerException
when generating inserts:
> {noformat}
> java.lang.NullPointerException
> at org.apache.cassandra.stress.StressProfile.getInsert(StressProfile.java:546)
> at org.apache.cassandra.stress.StressProfile.printSettings(StressProfile.java:126)
> at org.apache.cassandra.stress.settings.StressSettings.lambda$printSettings$1(StressSettings.java:311)
> at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684)
> at org.apache.cassandra.stress.settings.StressSettings.printSettings(StressSettings.java:311)
> at org.apache.cassandra.stress.Stress.run(Stress.java:108)
> at org.apache.cassandra.stress.Stress.main(Stress.java:63)
> {noformat}
> Fix is trivial, and will be provided as PR
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org
|