Skip to content

Commit

Permalink
[functions] Fix typos in exceptions related to functions (apache#6910)
Browse files Browse the repository at this point in the history
### Modifications

Fix typos in exceptions related to functions. The tests were updated as well.
  • Loading branch information
vzhikserg authored May 8, 2020
1 parent 204f327 commit 20216d1
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,11 @@
import java.io.File;
import java.lang.reflect.Type;
import java.net.MalformedURLException;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

import static org.apache.commons.lang.StringUtils.isNotBlank;
import static org.apache.commons.lang.StringUtils.isNotEmpty;
Expand Down Expand Up @@ -431,7 +433,7 @@ private static void doJavaChecks(FunctionConfig functionConfig, ClassLoader clsL
// Need to make sure that one and only one of schema/serde is set
if (!isEmpty(conf.getSchemaType()) && !isEmpty(conf.getSerdeClassName())) {
throw new IllegalArgumentException(
String.format("Only one of schemaType or serdeClassName should be set in inputSpec"));
"Only one of schemaType or serdeClassName should be set in inputSpec");
}
if (!isEmpty(conf.getSerdeClassName())) {
ValidatorUtils.validateSerde(conf.getSerdeClassName(), typeArgs[0], clsLoader, true);
Expand All @@ -449,7 +451,7 @@ private static void doJavaChecks(FunctionConfig functionConfig, ClassLoader clsL
// One and only one of outputSchemaType and outputSerdeClassName should be set
if (!isEmpty(functionConfig.getOutputSerdeClassName()) && !isEmpty(functionConfig.getOutputSchemaType())) {
throw new IllegalArgumentException(
String.format("Only one of outputSchemaType or outputSerdeClassName should be set"));
"Only one of outputSchemaType or outputSerdeClassName should be set");
}

if (!isEmpty(functionConfig.getOutputSchemaType())) {
Expand Down Expand Up @@ -606,7 +608,7 @@ private static void doCommonChecks(FunctionConfig functionConfig) {
// receiver queue size should be >= 0
if (conf.getReceiverQueueSize() != null && conf.getReceiverQueueSize() < 0) {
throw new IllegalArgumentException(
String.format("Receiver queue size should be >= zero"));
"Receiver queue size should be >= zero");
}
});
}
Expand Down Expand Up @@ -743,10 +745,10 @@ public static FunctionConfig validateUpdate(FunctionConfig existingConfig, Funct
mergedConfig.setLogTopic(newConfig.getLogTopic());
}
if (newConfig.getProcessingGuarantees() != null && !newConfig.getProcessingGuarantees().equals(existingConfig.getProcessingGuarantees())) {
throw new IllegalArgumentException("Processing Guarantess cannot be altered");
throw new IllegalArgumentException("Processing Guarantees cannot be altered");
}
if (newConfig.getRetainOrdering() != null && !newConfig.getRetainOrdering().equals(existingConfig.getRetainOrdering())) {
throw new IllegalArgumentException("Retain Orderning cannot be altered");
throw new IllegalArgumentException("Retain Ordering cannot be altered");
}
if (!StringUtils.isEmpty(newConfig.getOutput())) {
mergedConfig.setOutput(newConfig.getOutput());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ public static SinkConfig validateUpdate(SinkConfig existingConfig, SinkConfig ne
});
}
if (newConfig.getProcessingGuarantees() != null && !newConfig.getProcessingGuarantees().equals(existingConfig.getProcessingGuarantees())) {
throw new IllegalArgumentException("Processing Guarantess cannot be altered");
throw new IllegalArgumentException("Processing Guarantees cannot be altered");
}
if (newConfig.getConfigs() != null) {
mergedConfig.setConfigs(newConfig.getConfigs());
Expand All @@ -558,7 +558,7 @@ public static SinkConfig validateUpdate(SinkConfig existingConfig, SinkConfig ne
mergedConfig.setParallelism(newConfig.getParallelism());
}
if (newConfig.getRetainOrdering() != null && !newConfig.getRetainOrdering().equals(existingConfig.getRetainOrdering())) {
throw new IllegalArgumentException("Retain Orderning cannot be altered");
throw new IllegalArgumentException("Retain Ordering cannot be altered");
}
if (newConfig.getAutoAck() != null && !newConfig.getAutoAck().equals(existingConfig.getAutoAck())) {
throw new IllegalArgumentException("AutoAck cannot be altered");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ public static FunctionDetails convert(SourceConfig sourceConfig, ExtractedSource
functionDetailsBuilder.setProcessingGuarantees(
convertProcessingGuarantee(sourceConfig.getProcessingGuarantees()));
}

// set source spec
Function.SourceSpec.Builder sourceSpecBuilder = Function.SourceSpec.newBuilder();
if (sourceDetails.getSourceClassName() != null) {
Expand Down Expand Up @@ -366,7 +365,7 @@ public static SourceConfig validateUpdate(SourceConfig existingConfig, SourceCon
mergedConfig.setSecrets(newConfig.getSecrets());
}
if (newConfig.getProcessingGuarantees() != null && !newConfig.getProcessingGuarantees().equals(existingConfig.getProcessingGuarantees())) {
throw new IllegalArgumentException("Processing Guarantess cannot be altered");
throw new IllegalArgumentException("Processing Guarantees cannot be altered");
}
if (newConfig.getParallelism() != null) {
mergedConfig.setParallelism(newConfig.getParallelism());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,18 +217,18 @@ public void testMergeCleanupSubscription() {
assertTrue(mergedConfig.getCleanupSubscription());
}

@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "Processing Guarantess cannot be altered")
@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "Processing Guarantees cannot be altered")
public void testMergeDifferentProcessingGuarantees() {
FunctionConfig functionConfig = createFunctionConfig();
FunctionConfig newFunctionConfig = createUpdatedFunctionConfig("processingGuarantees", EFFECTIVELY_ONCE);
FunctionConfig mergedConfig = FunctionConfigUtils.validateUpdate(functionConfig, newFunctionConfig);
FunctionConfigUtils.validateUpdate(functionConfig, newFunctionConfig);
}

@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "Retain Orderning cannot be altered")
@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "Retain Ordering cannot be altered")
public void testMergeDifferentRetainOrdering() {
FunctionConfig functionConfig = createFunctionConfig();
FunctionConfig newFunctionConfig = createUpdatedFunctionConfig("retainOrdering", true);
FunctionConfig mergedConfig = FunctionConfigUtils.validateUpdate(functionConfig, newFunctionConfig);
FunctionConfigUtils.validateUpdate(functionConfig, newFunctionConfig);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,18 +148,18 @@ public void testMergeDifferentInputSpec() {
assertEquals(mergedConfig.getInputSpecs().get("test-input"), newSinkConfig.getInputSpecs().get("test-input"));
}

@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "Processing Guarantess cannot be altered")
@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "Processing Guarantees cannot be altered")
public void testMergeDifferentProcessingGuarantees() {
SinkConfig sinkConfig = createSinkConfig();
SinkConfig newSinkConfig = createUpdatedSinkConfig("processingGuarantees", EFFECTIVELY_ONCE);
SinkConfig mergedConfig = SinkConfigUtils.validateUpdate(sinkConfig, newSinkConfig);
SinkConfigUtils.validateUpdate(sinkConfig, newSinkConfig);
}

@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "Retain Orderning cannot be altered")
@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "Retain Ordering cannot be altered")
public void testMergeDifferentRetainOrdering() {
SinkConfig sinkConfig = createSinkConfig();
SinkConfig newSinkConfig = createUpdatedSinkConfig("retainOrdering", true);
SinkConfig mergedConfig = SinkConfigUtils.validateUpdate(sinkConfig, newSinkConfig);
SinkConfigUtils.validateUpdate(sinkConfig, newSinkConfig);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,11 @@ public void testMergeDifferentClassName() {
);
}

@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "Processing Guarantess cannot be altered")
@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "Processing Guarantees cannot be altered")
public void testMergeDifferentProcessingGuarantees() {
SourceConfig sourceConfig = createSourceConfig();
SourceConfig newSourceConfig = createUpdatedSourceConfig("processingGuarantees", EFFECTIVELY_ONCE);
SourceConfig mergedConfig = SourceConfigUtils.validateUpdate(sourceConfig, newSourceConfig);
SourceConfigUtils.validateUpdate(sourceConfig, newSourceConfig);
}

@Test
Expand Down

0 comments on commit 20216d1

Please sign in to comment.