1010import lombok .Data ;
1111import lombok .RequiredArgsConstructor ;
1212import org .apache .flink .util .Preconditions ;
13- import org .apache .flink .util .StringUtils ;
13+ import static org .apache .flink .util .StringUtils . isNullOrWhitespaceOnly ;
1414
1515import com .getindata .connectors .http .internal .config .HttpConnectorConfigConstants ;
1616
@@ -35,8 +35,7 @@ public class ComposeHttpStatusCodeChecker implements HttpStatusCodeChecker {
3535
3636 public ComposeHttpStatusCodeChecker (ComposeHttpStatusCodeCheckerConfig config ) {
3737 // Handle deprecated configuration for backward compatibility.
38- if (!StringUtils .isNullOrWhitespaceOnly (config .getDeprecatedCodePrefix ()) ||
39- !StringUtils .isNullOrWhitespaceOnly (config .getDeprecatedErrorWhiteListPrefix ())) {
38+ if (areDeprecatedPropertiesUsed (config )) {
4039 notRetryableErrorStatusCodes = buildPredicate (config , config .getDeprecatedCodePrefix (),
4140 config .getDeprecatedErrorWhiteListPrefix (), DEFAULT_DEPRECATED_ERROR_CODES );
4241 retryableErrorStatusCodes = integer -> false ;
@@ -48,15 +47,28 @@ public ComposeHttpStatusCodeChecker(ComposeHttpStatusCodeCheckerConfig config) {
4847 }
4948 }
5049
50+ private boolean areDeprecatedPropertiesUsed (ComposeHttpStatusCodeCheckerConfig config ) {
51+ boolean whiteListDefined =
52+ !isNullOrWhitespaceOnly (config .getDeprecatedErrorWhiteListPrefix ());
53+ boolean codeListDefined = !isNullOrWhitespaceOnly (config .getDeprecatedCodePrefix ());
54+
55+ return (whiteListDefined && !isNullOrWhitespaceOnly (
56+ config .getProperties ().getProperty (config .getDeprecatedErrorWhiteListPrefix ())))
57+ || (codeListDefined && !isNullOrWhitespaceOnly (
58+ config .getProperties ().getProperty (config .getDeprecatedCodePrefix ())));
59+ }
60+
5161 private Predicate <Integer > buildPredicate (
5262 ComposeHttpStatusCodeCheckerConfig config ,
5363 String errorCodePrefix ,
5464 String whiteListPrefix ,
5565 Predicate <Integer > defaultErrorCodes ) {
5666 Properties properties = config .getProperties ();
5767
58- String errorCodes = properties .getProperty (errorCodePrefix , "" );
59- String whitelistCodes = properties .getProperty (whiteListPrefix , "" );
68+ String errorCodes =
69+ errorCodePrefix == null ? "" : properties .getProperty (errorCodePrefix , "" );
70+ String whitelistCodes =
71+ whiteListPrefix == null ? "" : properties .getProperty (whiteListPrefix , "" );
6072
6173 Predicate <Integer > errorPredicate =
6274 prepareErrorCodes (errorCodes ).orElse (defaultErrorCodes );
@@ -74,7 +86,7 @@ private Predicate<Integer> buildPredicate(
7486 */
7587 private Optional <Predicate <Integer >> prepareErrorCodes (String statusCodesStr ) {
7688 return Arrays .stream (statusCodesStr .split (HttpConnectorConfigConstants .PROP_DELIM ))
77- .filter (code -> !StringUtils . isNullOrWhitespaceOnly (code ))
89+ .filter (code -> !isNullOrWhitespaceOnly (code ))
7890 .map (code -> code .toUpperCase ().trim ())
7991 .map (codeStr -> {
8092 Preconditions .checkArgument (
0 commit comments