Skip to content

Commit 2c735d2

Browse files
committed
Merge branch 'sonar-again' into 'main'
Another pass to clean up Sonar and compiler warnings for maintainability See merge request weblogic-cloud/weblogic-kubernetes-operator!4949
2 parents c314d89 + 6a17fd4 commit 2c735d2

File tree

136 files changed

+643
-1067
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

136 files changed

+643
-1067
lines changed

common/src/test/java/oracle/kubernetes/common/utils/SchemaConversionUtilsTest.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2022, 2023, Oracle and/or its affiliates.
1+
// Copyright (c) 2022, 2025, Oracle and/or its affiliates.
22
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
33

44
package oracle.kubernetes.common.utils;
@@ -57,7 +57,7 @@ private static String getMD5Hash(String s) throws NoSuchAlgorithmException {
5757
}
5858

5959
@BeforeEach
60-
void setUp() throws Exception {
60+
void setUp() {
6161
mementos.add(CommonTestUtils.silenceLogger());
6262
mementos.add(BaseTestUtils.silenceJsonPathLogger());
6363
v8Domain = readAsYaml(DOMAIN_V8_AUX_IMAGE30_YAML);
@@ -78,7 +78,7 @@ private static InputStream inputStreamFromClasspath(String path) {
7878
}
7979

8080
@AfterEach
81-
void tearDown() throws Exception {
81+
void tearDown() {
8282
mementos.forEach(Memento::revert);
8383
}
8484

@@ -156,9 +156,9 @@ void testV9DomainDowngrade() {
156156

157157
converterv8.convert(domain, clusters);
158158

159-
Map<String, Object> v8Domain = readAsYaml(DOMAIN_V8_AUX_IMAGE30_YAML);
159+
Map<String, Object> v8DomainAux = readAsYaml(DOMAIN_V8_AUX_IMAGE30_YAML);
160160
List<Object> convertedClusters = (List<Object>) getDomainSpec(converterv8.getDomain()).get("clusters");
161-
List<Object> origClusters = (List<Object>) getDomainSpec(v8Domain).get("clusters");
161+
List<Object> origClusters = (List<Object>) getDomainSpec(v8DomainAux).get("clusters");
162162
assertThat(convertedClusters, notNullValue());
163163
assertThat(convertedClusters, equalTo(origClusters));
164164
}
@@ -171,8 +171,7 @@ void testV8DomainUpgradeWithServerScopedLegacyAuxImagesToV9DomainWithInitContain
171171
List<Map<String, Object>> clusters = new ArrayList<>();
172172
yamlDocuments.forEachRemaining(doc -> clusters.add((Map<String, Object>) doc));
173173

174-
Map<String, Object> v8Domain = readAsYaml(DOMAIN_V8_SERVER_SCOPED_AUX_IMAGE30_YAML);
175-
converter.convert(v8Domain);
174+
converter.convert(readAsYaml(DOMAIN_V8_SERVER_SCOPED_AUX_IMAGE30_YAML));
176175

177176
assertThat(converter.getDomain(), equalTo(expectedDomain));
178177

integration-tests/src/test/java/oracle/weblogic/domain/AdminServer.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2020, 2021, Oracle and/or its affiliates.
1+
// Copyright (c) 2020, 2025, Oracle and/or its affiliates.
22
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
33

44
package oracle.weblogic.domain;
@@ -37,11 +37,12 @@ public class AdminServer {
3737
private String restartVersion;
3838

3939
@ApiModelProperty(
40-
"When this flag is enabled, the operator updates the domain's WebLogic\n"
41-
+ " configuration for its Administration Server to have an admin protocol\n"
42-
+ " NetworkAccessPoint with a 'localhost' address for each existing admin\n"
43-
+ " protocol capable port. This allows external Administration Console and WLST\n"
44-
+ " 'T3' access when using the 'kubectl port-forward' pattern. Defaults to true.")
40+
"""
41+
When this flag is enabled, the operator updates the domain's WebLogic
42+
configuration for its Administration Server to have an admin protocol
43+
NetworkAccessPoint with a 'localhost' address for each existing admin
44+
protocol capable port. This allows external Administration Console and WLST
45+
'T3' access when using the 'kubectl port-forward' pattern. Defaults to true.""")
4546
private boolean adminChannelPortForwardingEnabled = true;
4647

4748
public AdminServer adminService(AdminService adminService) {

integration-tests/src/test/java/oracle/weblogic/domain/Channel.java

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2020, 2021, Oracle and/or its affiliates.
1+
// Copyright (c) 2020, 2025, Oracle and/or its affiliates.
22
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
33

44
package oracle.weblogic.domain;
@@ -12,14 +12,19 @@
1212
@ApiModel(description = "Describes a single channel used by the Administration Server.")
1313
public class Channel {
1414
@ApiModelProperty(
15-
"Name of channel.\n'default' refers to the Administration Server's default channel (configured "
16-
+ "via the ServerMBean's ListenPort) "
17-
+ "\n'default-secure' refers to the Administration Server's default secure channel "
18-
+ "(configured via the ServerMBean's SSLMBean's ListenPort) "
19-
+ "\n'default-admin' refers to the Administration Server's default administrative channel "
20-
+ "(configured via the DomainMBean's AdministrationPort) "
21-
+ "\nOtherwise, the name is the name of one of the Administration Server's network access points "
22-
+ "(configured via the ServerMBean's NetworkAccessMBeans).")
15+
"""
16+
Name of channel.
17+
'default' refers to the Administration Server's default channel (configured \
18+
via the ServerMBean's ListenPort) \
19+
20+
'default-secure' refers to the Administration Server's default secure channel \
21+
(configured via the ServerMBean's SSLMBean's ListenPort) \
22+
23+
'default-admin' refers to the Administration Server's default administrative channel \
24+
(configured via the DomainMBean's AdministrationPort) \
25+
26+
Otherwise, the name is the name of one of the Administration Server's network access points \
27+
(configured via the ServerMBean's NetworkAccessMBeans).""")
2328
private String channelName;
2429

2530
@ApiModelProperty(

integration-tests/src/test/java/oracle/weblogic/domain/PersistentVolumeSpec.java

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2023, Oracle and/or its affiliates.
1+
// Copyright (c) 2023, 2025, Oracle and/or its affiliates.
22
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
33

44
package oracle.weblogic.domain;
@@ -19,18 +19,20 @@ public class PersistentVolumeSpec {
1919
+ "More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#capacity")
2020
private Map<String, Quantity> capacity;
2121

22-
@ApiModelProperty("HostPath represents a directory on the host. Provisioned by a developer or tester."
23-
+ " This is useful for single-node development and testing only! On-host storage is not supported in any way"
24-
+ " and WILL NOT WORK in a multi-node cluster. More info:\n"
25-
+ " https://kubernetes.io/docs/concepts/storage/volumes#hostpath\n"
26-
+ "Represents a host path mapped into a pod. Host path volumes do not support ownership management"
27-
+ " or SELinux relabeling.")
22+
@ApiModelProperty("""
23+
HostPath represents a directory on the host. Provisioned by a developer or tester.\
24+
This is useful for single-node development and testing only! On-host storage is not supported in any way\
25+
and WILL NOT WORK in a multi-node cluster. More info:
26+
https://kubernetes.io/docs/concepts/storage/volumes#hostpath
27+
Represents a host path mapped into a pod. Host path volumes do not support ownership management\
28+
or SELinux relabeling.""")
2829
private V1HostPathVolumeSource hostPath;
2930

30-
@ApiModelProperty("nfs represents an NFS mount on the host. Provisioned by an admin. More info:\n"
31-
+ "https://kubernetes.io/docs/concepts/storage/volumes#nfs\n"
32-
+ "Represents an NFS mount that lasts the lifetime of a pod. NFS volumes do"
33-
+ " not support ownership management or SELinux relabeling.")
31+
@ApiModelProperty("""
32+
nfs represents an NFS mount on the host. Provisioned by an admin. More info:
33+
https://kubernetes.io/docs/concepts/storage/volumes#nfs
34+
Represents an NFS mount that lasts the lifetime of a pod. NFS volumes do\
35+
not support ownership management or SELinux relabeling.""")
3436
private V1NFSVolumeSource nfs;
3537

3638
@ApiModelProperty("PersistentVolumeReclaimPolicy defines what happens to a persistent volume when released from"

integration-tests/src/test/java/oracle/weblogic/kubernetes/ItConfigDistributionStrategy.java

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -244,9 +244,9 @@ void initAll(@Namespaces(3) List<String> namespaces) throws ApiException, IOExce
244244
String ingressClassName = nginxHelmParams.getIngressClassName();
245245
String serviceName = domainUid + "-admin-server";
246246
final int ADMIN_SERVER_PORT = 7001;
247-
String hostAndPort = getHostAndPortOKE();
247+
String hostAndPortOKE = getHostAndPortOKE();
248248
createNginxIngressPathRoutingRules(domainNamespace, ingressClassName,
249-
serviceName, ADMIN_SERVER_PORT, hostAndPort);
249+
serviceName, ADMIN_SERVER_PORT, hostAndPortOKE);
250250
}
251251

252252
// Expose the admin service external node port as a route for OKD
@@ -500,7 +500,6 @@ void testDynamicOverride() {
500500
assertTrue(patchDomainCustomResource(domainUid, domainNamespace, patch, V1Patch.PATCH_FORMAT_JSON_PATCH),
501501
"Failed to patch domain");
502502

503-
//TODO: - does changing overrideDistributionStrategy needs restart of server pods?
504503
restartDomain(); // if above is a bug, remove this after the above bug is fixed
505504

506505
//store the pod creation timestamps
@@ -574,7 +573,6 @@ void testOnRestartOverride() {
574573
assertTrue(patchDomainCustomResource(domainUid, domainNamespace, patch, V1Patch.PATCH_FORMAT_JSON_PATCH),
575574
"Failed to patch domain");
576575

577-
//TODO: - does changing overrideDistributionStrategy needs restart of server pods?
578576
restartDomain(); // if above is a bug, remove this after the above bug is fixed
579577

580578
//store the pod creation timestamps
@@ -694,8 +692,8 @@ private Callable<Boolean> configUpdated(String maxMessageSize) {
694692

695693
return (()
696694
-> {
697-
String hostAndPort = getHostAndPort(adminSvcExtHost, serviceNodePort);
698-
logger.info("hostAndPort = {0} ", hostAndPort);
695+
String hostAndPortLocal = getHostAndPort(adminSvcExtHost, serviceNodePort);
696+
logger.info("hostAndPort = {0} ", hostAndPortLocal);
699697

700698
//verify server attribute MaxMessageSize
701699
String appURI = "/clusterview/ConfigServlet?"
@@ -705,14 +703,14 @@ private Callable<Boolean> configUpdated(String maxMessageSize) {
705703
Map<String, String> headers = null;
706704
if (TestConstants.KIND_CLUSTER
707705
&& !TestConstants.WLSIMG_BUILDER.equals(TestConstants.WLSIMG_BUILDER_DEFAULT)) {
708-
hostAndPort = "localhost:" + TRAEFIK_INGRESS_HTTP_HOSTPORT;
706+
hostAndPortLocal = "localhost:" + TRAEFIK_INGRESS_HTTP_HOSTPORT;
709707
headers = new HashMap<>();
710708
headers.put("host", hostHeader);
711709
}
712710
if (OKE_CLUSTER_PRIVATEIP) {
713-
hostAndPort = ingressIP;
711+
hostAndPortLocal = ingressIP;
714712
}
715-
String url = "http://" + hostAndPort + appURI;
713+
String url = "http://" + hostAndPortLocal + appURI;
716714
HttpResponse<String> response = OracleHttpClient.get(url, headers, true);
717715
assertEquals(200, response.statusCode(), "Status code not equals to 200");
718716
return response.body().contains("MaxMessageSize=".concat(maxMessageSize));
@@ -860,20 +858,20 @@ private void verifyResourceJDBC1Override(boolean configUpdated) {
860858

861859
testUntil(
862860
() -> {
863-
String hostAndPort = getHostAndPort(adminSvcExtHost, port);
864-
logger.info("hostAndPort = {0} ", hostAndPort);
861+
String hostAndPortLocal = getHostAndPort(adminSvcExtHost, port);
862+
logger.info("hostAndPort = {0} ", hostAndPortLocal);
865863

866864
Map<String, String> headers = null;
867865
if (TestConstants.KIND_CLUSTER
868866
&& !TestConstants.WLSIMG_BUILDER.equals(TestConstants.WLSIMG_BUILDER_DEFAULT)) {
869-
hostAndPort = "localhost:" + TRAEFIK_INGRESS_HTTP_HOSTPORT;
867+
hostAndPortLocal = "localhost:" + TRAEFIK_INGRESS_HTTP_HOSTPORT;
870868
headers = new HashMap<>();
871869
headers.put("host", hostHeader);
872870
}
873871
if (OKE_CLUSTER_PRIVATEIP) {
874-
hostAndPort = getHostAndPortOKE();
872+
hostAndPortLocal = getHostAndPortOKE();
875873
}
876-
String baseUri = "http://" + hostAndPort + "/clusterview/ConfigServlet?";
874+
String baseUri = "http://" + hostAndPortLocal + "/clusterview/ConfigServlet?";
877875

878876
//verify datasource attributes of JdbcTestDataSource-0
879877
String appURI = "resTest=true&resName=" + dsName1;
@@ -930,7 +928,6 @@ private void verifyResourceJDBC1Override(boolean configUpdated) {
930928
if (OKE_CLUSTER_PRIVATEIP) {
931929
hostAndPort = getHostAndPortOKE();
932930
}
933-
String baseUri = "http://" + hostAndPort + "/clusterview/ConfigServlet?";
934931
String appURI = "dsTest=true&dsName=" + dsName1 + "&" + "serverName=" + managedServerNameBase + i;
935932
testDatasource(appURI);
936933
}
@@ -1215,20 +1212,20 @@ private void getDomainHealth() {
12151212
int serviceNodePort = assertDoesNotThrow(()
12161213
-> getServiceNodePort(domainNamespace, getExternalServicePodName(adminServerPodName), "default"),
12171214
"Getting admin server node port failed");
1218-
String hostAndPort = getHostAndPort(adminSvcExtHost, serviceNodePort);
1215+
String hostAndPortLocal = getHostAndPort(adminSvcExtHost, serviceNodePort);
12191216
boolean ipv6 = K8S_NODEPORT_HOST.contains(":");
12201217
Map<String, String> headers = null;
12211218
if (TestConstants.KIND_CLUSTER
12221219
&& !TestConstants.WLSIMG_BUILDER.equals(TestConstants.WLSIMG_BUILDER_DEFAULT)) {
1223-
hostAndPort = formatIPv6Host(InetAddress.getLocalHost().getHostAddress())
1220+
hostAndPortLocal = formatIPv6Host(InetAddress.getLocalHost().getHostAddress())
12241221
+ ":" + TRAEFIK_INGRESS_HTTP_HOSTPORT;
12251222
headers = new HashMap<>();
12261223
headers.put("host", hostHeader);
12271224
}
12281225
if (OKE_CLUSTER_PRIVATEIP) {
1229-
hostAndPort = getHostAndPortOKE();
1226+
hostAndPortLocal = getHostAndPortOKE();
12301227
}
1231-
String url = "http://" + hostAndPort
1228+
String url = "http://" + hostAndPortLocal
12321229
+ "/clusterview/ClusterViewServlet?user=" + ADMIN_USERNAME_DEFAULT
12331230
+ "&password=" + ADMIN_PASSWORD_DEFAULT + "&ipv6=" + ipv6;
12341231

integration-tests/src/test/java/oracle/weblogic/kubernetes/ItDiagnosticsFailedCondition.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -831,7 +831,7 @@ void testMSBootFailureStatus() {
831831
String managedServerName = managedServerPrefix + i + "-c1";
832832
logger.info("Checking managed server {0} has been shutdown in namespace {1}",
833833
managedServerName, domainNamespace);
834-
checkServerStatusPodPhaseAndPodReady(domainName, domainNamespace, managedServerName, "Running", "False");
834+
checkServerStatusPodPhaseAndPodReady(domainName, domainNamespace, "Running", "False");
835835
}
836836
testPassed = true;
837837
} finally {

integration-tests/src/test/java/oracle/weblogic/kubernetes/ItEvictedPodsCycling.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import java.util.Map;
99
import java.util.concurrent.Callable;
1010

11-
import io.kubernetes.client.openapi.ApiException;
1211
import io.kubernetes.client.openapi.models.CoreV1Event;
1312
import io.kubernetes.client.openapi.models.V1ResourceRequirements;
1413
import io.kubernetes.client.util.Yaml;
@@ -109,7 +108,7 @@ static void init(@Namespaces(2) List<String> namespaces) {
109108
*/
110109
@Test
111110
@DisplayName("Use Operator log to verify that WLS server pods were evicted and replaced")
112-
void testEvictedPodReplaced() throws ApiException {
111+
void testEvictedPodReplaced() {
113112
resourceLimit.put("ephemeral-storage", ephemeralStorage);
114113
resourceRequest.put("cpu", "250m");
115114
resourceRequest.put("memory", "768Mi");

integration-tests/src/test/java/oracle/weblogic/kubernetes/ItExternalLbTunneling.java

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -573,15 +573,11 @@ private static Callable<Boolean> runJmsClient(String javaCmd) {
573573

574574
@AfterAll
575575
void tearDownAll() {
576-
if (!SKIP_CLEANUP) {
577-
578-
// uninstall Traefik loadbalancer
579-
if (traefikHelmParams != null) {
580-
assertThat(uninstallTraefik(traefikHelmParams))
581-
.as("Test uninstallTraefik returns true")
582-
.withFailMessage("uninstallTraefik() did not return true")
583-
.isTrue();
584-
}
576+
if (!SKIP_CLEANUP && traefikHelmParams != null) {
577+
assertThat(uninstallTraefik(traefikHelmParams))
578+
.as("Test uninstallTraefik returns true")
579+
.withFailMessage("uninstallTraefik() did not return true")
580+
.isTrue();
585581
}
586582
}
587583

integration-tests/src/test/java/oracle/weblogic/kubernetes/ItFmwDomainOnPV.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ class ItFmwDomainOnPV {
104104
private static String dbNamespace = null;
105105

106106
private static final String ORACLEDBURLPREFIX = "oracledb.";
107-
private static String ORACLEDBSUFFIX = null;
108107
private static final String RCUSCHEMAPREFIX = "fmwdomainpv";
109108
private static final String RCUSYSPASSWORD = "Oradoc_db1";
110109
private static final String RCUSCHEMAPASSWORD = "Oradoc_db1";

integration-tests/src/test/java/oracle/weblogic/kubernetes/ItFmwDomainOnPVSample.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2023, 2024, Oracle and/or its affiliates.
1+
// Copyright (c) 2023, 2025, Oracle and/or its affiliates.
22
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
33

44
package oracle.weblogic.kubernetes;
@@ -176,7 +176,7 @@ static void initAll(@Namespaces(4) List<String> namespaces) {
176176
*/
177177
@Test
178178
@Order(1)
179-
public void testInstallOperator() {
179+
void testInstallOperator() {
180180
String backupReports = backupReports(UniqueName.uniqueName(this.getClass().getSimpleName()));
181181
execTestScriptAndAssertSuccess("-oper", "Failed to run -oper");
182182
restoreReports(backupReports);
@@ -187,7 +187,7 @@ public void testInstallOperator() {
187187
*/
188188
@Test
189189
@Order(2)
190-
public void testInstallTraefik() {
190+
void testInstallTraefik() {
191191
execTestScriptAndAssertSuccess("-traefik", "Failed to run -traefik");
192192
}
193193

@@ -196,7 +196,7 @@ public void testInstallTraefik() {
196196
*/
197197
@Test
198198
@Order(3)
199-
public void testPrecleandb() {
199+
void testPrecleandb() {
200200
execTestScriptAndAssertSuccess("-precleandb", "Failed to run -precleandb");
201201
}
202202

@@ -205,7 +205,7 @@ public void testPrecleandb() {
205205
*/
206206
@Test
207207
@Order(4)
208-
public void testCreatedb() {
208+
void testCreatedb() {
209209
logger.info("test case for creating a db");
210210
if (KIND_REPO != null) {
211211
String dbimage = DB_IMAGE_NAME + ":" + DB_IMAGE_TAG;
@@ -220,7 +220,7 @@ public void testCreatedb() {
220220
*/
221221
@Test
222222
@Order(5)
223-
public void testInitialImage() {
223+
void testInitialImage() {
224224
logger.info("test case for building image");
225225
imagePull(BUSYBOX_IMAGE + ":" + BUSYBOX_TAG);
226226
imageTag(BUSYBOX_IMAGE + ":" + BUSYBOX_TAG, "busybox");
@@ -238,7 +238,7 @@ public void testInitialImage() {
238238
*/
239239
@Test
240240
@Order(6)
241-
public void testInitialMain() {
241+
void testInitialMain() {
242242
logger.info("test case for creating a FMW domain");
243243

244244
// load the base image to kind if using kind cluster

0 commit comments

Comments
 (0)