Skip to content

Commit 372ffa8

Browse files
authored
handle null cluster in isAllowReplicasBelowDynClusterSizeFor (#1630)
1 parent 35d9940 commit 372ffa8

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

operator/src/main/java/oracle/kubernetes/weblogic/domain/model/DomainSpec.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
import org.apache.commons.lang3.builder.HashCodeBuilder;
3030
import org.apache.commons.lang3.builder.ToStringBuilder;
3131

32+
import static oracle.kubernetes.operator.KubernetesConstants.DEFAULT_ALLOW_REPLICAS_BELOW_MIN_DYN_CLUSTER_SIZE;
33+
3234
/** DomainSpec is a description of a domain. */
3335
@Description("DomainSpec is a description of a domain.")
3436
public class DomainSpec extends BaseConfiguration {
@@ -843,7 +845,8 @@ private boolean hasMaxUnavailable(Cluster cluster) {
843845
}
844846

845847
private boolean isAllowReplicasBelowDynClusterSizeFor(Cluster cluster) {
846-
return cluster.isAllowReplicasBelowMinDynClusterSize();
848+
return cluster == null ? DEFAULT_ALLOW_REPLICAS_BELOW_MIN_DYN_CLUSTER_SIZE :
849+
cluster.isAllowReplicasBelowMinDynClusterSize();
847850
}
848851

849852
public AdminServer getAdminServer() {

operator/src/test/java/oracle/kubernetes/weblogic/domain/DomainTestBase.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,12 @@ public void whenNotSpecified_allowReplicasBelowMinDynamicClusterSizeHasDefault()
334334
equalTo(DEFAULT_ALLOW_REPLICAS_BELOW_MIN_DYN_CLUSTER_SIZE));
335335
}
336336

337+
@Test
338+
public void whenNoClusterSpec_allowReplicasBelowMinDynamicClusterSizeHasDefault() {
339+
assertThat(domain.isAllowReplicasBelowMinDynClusterSize("cluster-with-no-spec"),
340+
equalTo(DEFAULT_ALLOW_REPLICAS_BELOW_MIN_DYN_CLUSTER_SIZE));
341+
}
342+
337343
@Test
338344
public void whenBothClusterAndServerStateSpecified_managedServerUsesServerState() {
339345
configureServer(SERVER1).withDesiredState("STAND-BY");

0 commit comments

Comments
 (0)