Skip to content

Commit

Permalink
Check multiple actions only valid for WRITEREAD and UPDOWN
Browse files Browse the repository at this point in the history
  • Loading branch information
rayokota committed Nov 23, 2023
1 parent 354b5a3 commit 02a996b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion checkstyle/suppressions.xml
Expand Up @@ -40,7 +40,7 @@
files="(KafkaSchemaRegistry|SchemaRegistryConfig|ProtobufData|JsonSchemaData).java"/>

<suppress checks="BooleanExpressionComplexity"
files="(AvroData|JsonSchema|KafkaSchemaRegistry|ProtobufData|ProtobufSchema|CelExecutor|FieldRuleExecutor|MetadataEncoderService|MockDekRegistryClient|DataEncryptionKey|KeyEncryptionKey).java"/>
files="(AvroData|JsonSchema|KafkaSchemaRegistry|ProtobufData|ProtobufSchema|CelExecutor|FieldRuleExecutor|MetadataEncoderService|MockDekRegistryClient|DataEncryptionKey|KeyEncryptionKey|Rule).java"/>

<suppress checks="MemberName"
files="(DynamicSchema|EnumDefinition|MessageDefinition|ServiceDefinition).java"/>
Expand Down
Expand Up @@ -253,6 +253,8 @@ public void validate() throws RuleException {
if (type == null) {
throw new RuleException("Missing rule type");
}
validateAction(mode, onSuccess);
validateAction(mode, onFailure);
}

private static void validateName(String name) throws RuleException {
Expand All @@ -277,4 +279,14 @@ private static void validateName(String name) throws RuleException {
}
}
}

private static void validateAction(RuleMode mode, String action) throws RuleException {
if (mode != null
&& mode != RuleMode.WRITEREAD
&& mode != RuleMode.UPDOWN
&& action != null
&& action.indexOf(',') >= 0) {
throw new RuleException("Multiple actions only valid with WRITEREAD and UPDOWN");
}
}
}

0 comments on commit 02a996b

Please sign in to comment.