Skip to content

Commit

Permalink
fix more checkstyle errors
Browse files Browse the repository at this point in the history
  • Loading branch information
snehashisp committed Dec 7, 2024
1 parent 24c95ea commit 757caba
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
*/
package org.apache.kafka.connect.runtime.isolation;

import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
import org.apache.maven.artifact.versioning.VersionRange;
import org.reflections.util.ClasspathHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -453,4 +455,20 @@ private static class DirectoryEntry {
}
}

public static VersionRange connectorVersionRequirement(String version) throws InvalidVersionSpecificationException {
if (version == null || version.equals("latest")) {
return null;
}
version = version.trim();

// check first if the given version is valid
VersionRange.createFromVersionSpec(version);

// now if the version is not enclosed we consider it as a hard requirement and enclose it in []
if (!version.startsWith("[") && !version.startsWith("(")) {
version = "[" + version + "]";
}
return VersionRange.createFromVersionSpec(version);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import org.apache.kafka.connect.storage.HeaderConverter;
import org.apache.kafka.connect.transforms.Transformation;
import org.apache.kafka.connect.transforms.predicates.Predicate;
import org.apache.kafka.connect.util.PluginVersionUtils;

import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
import org.apache.maven.artifact.versioning.VersionRange;
import org.slf4j.Logger;
Expand Down Expand Up @@ -564,7 +564,7 @@ private <U> U newVersionedPlugin(
VersionRange range = null;
if (version != null) {
try {
range = PluginVersionUtils.connectorVersionRequirement(version);
range = PluginUtils.connectorVersionRequirement(version);
} catch (InvalidVersionSpecificationException e) {
throw new ConnectException(String.format("Invalid version range for %s: %s", classPropertyName, version), e);
}
Expand Down

This file was deleted.

0 comments on commit 757caba

Please sign in to comment.