Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion config/checkstyle/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@
<property name="illegalPkgs" value="org.apache.log4j"/>
<property name="illegalPkgs" value="org.apache.commons.lang"/>
<property name="illegalPkgs" value="org.apache.commons.collections"/>
<property name="illegalPkgs" value="org.apache.commons.lang3.tuple" />
<property name="illegalPkgs" value="org.apache.commons.lang3" />
</module>
</module>
</module>
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
import static org.apache.spark.k8s.operator.Constants.API_VERSION;

import java.io.File;
import java.lang.reflect.Field;
import java.util.Map;

import io.fabric8.kubernetes.api.model.ObjectMeta;
import org.apache.commons.lang3.reflect.FieldUtils;

import org.apache.spark.k8s.operator.Constants;
import org.apache.spark.k8s.operator.SparkApplication;
Expand Down Expand Up @@ -66,9 +66,15 @@ public static long calculateElapsedTimeInMills(long startTime) {
return System.currentTimeMillis() - startTime;
}

@SuppressWarnings("PMD.AvoidAccessibilityAlteration")
public static <T> void setConfigKey(ConfigOption<T> configKey, T newValue) {
try {
FieldUtils.writeField(configKey, "defaultValue", newValue, true);
Class<?> targetClass = configKey.getClass();
Field field = targetClass.getDeclaredField("defaultValue");
field.setAccessible(true);
field.set(configKey, newValue);
} catch (NoSuchFieldException e) {
throw new IllegalStateException(e);
} catch (IllegalAccessException e) {
throw new UnsupportedOperationException(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@

import scala.Option;

import org.apache.commons.lang3.RandomStringUtils;
import org.junit.jupiter.api.Test;

import org.apache.spark.SparkConf;
Expand Down Expand Up @@ -63,7 +62,7 @@ void testConfigMapNameDriver() {
SparkConf sparkConf = new SparkConf();
sparkConf.set("foo", "bar");
sparkConf.set("spark.executor.instances", "1");
String appId = RandomStringUtils.randomAlphabetic(1000);
String appId = "a".repeat(1000);
SparkAppDriverConf sparkAppDriverConf =
SparkAppDriverConf.create(
sparkConf, appId, mock(JavaMainAppResource.class), "foo", null, Option.empty());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@

import io.fabric8.kubernetes.api.model.ObjectMeta;
import io.fabric8.kubernetes.api.model.ObjectMetaBuilder;
import org.apache.commons.lang3.RandomStringUtils;
import org.junit.jupiter.api.Test;
import org.mockito.MockedConstruction;

Expand Down Expand Up @@ -209,8 +208,8 @@ void sparkAppIdShouldBeDeterministicPerAppPerAttempt() {

@Test
void generatedSparkAppIdShouldComplyLengthLimit() {
String namespaceName = RandomStringUtils.randomAlphabetic(253);
String appName = RandomStringUtils.randomAlphabetic(253);
String namespaceName = "n".repeat(253);
String appName = "a".repeat(253);

SparkApplication mockApp = mock(SparkApplication.class);
ObjectMeta appMeta =
Expand Down
Loading