Skip to content

Commit 78b4d7b

Browse files
committed
MLE-23593 Fixing compiler warnings
Knocks out all warnings, including warnings about build.gradle files. Big hat tip to Copilot.
1 parent b4b3ea0 commit 78b4d7b

File tree

29 files changed

+118
-89
lines changed

29 files changed

+118
-89
lines changed

build.gradle

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// Copyright (c) 2015-2025 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.
2+
13
// Defines common configuration for each of the 3 subprojects.
24
subprojects {
35
apply plugin: "java-library"
@@ -14,7 +16,7 @@ subprojects {
1416
mavenCentral()
1517
mavenLocal()
1618
maven {
17-
url "https://bed-artifactory.bedford.progress.com:443/artifactory/ml-maven-snapshots/"
19+
url = "https://bed-artifactory.bedford.progress.com:443/artifactory/ml-maven-snapshots/"
1820
}
1921
}
2022

@@ -32,15 +34,25 @@ subprojects {
3234
testImplementation 'org.slf4j:slf4j-api:2.0.17'
3335
}
3436

35-
javadoc.failOnError = false
37+
// Allows for quickly identifying compiler warnings.
38+
tasks.withType(JavaCompile) {
39+
options.compilerArgs += ["-Xlint:unchecked", "-Xlint:deprecation"]
40+
options.deprecation = true
41+
options.warnings = true
42+
}
43+
44+
javadoc {
45+
failOnError = false
46+
}
47+
3648
// Ignores warnings on params that don't have descriptions, which is a little too noisy
3749
javadoc.options.addStringOption('Xdoclint:none', '-quiet')
3850

3951
test {
4052
useJUnitPlatform()
4153
testLogging {
4254
events 'started','passed', 'skipped', 'failed'
43-
exceptionFormat 'full'
55+
exceptionFormat = 'full'
4456
}
4557
}
4658

@@ -89,17 +101,17 @@ subprojects {
89101
maven {
90102
if (project.hasProperty("mavenUser")) {
91103
credentials {
92-
username mavenUser
93-
password mavenPassword
104+
username = mavenUser
105+
password = mavenPassword
94106
}
95107
url publishUrl
96108
allowInsecureProtocol = true
97109
} else {
98110
name = "central"
99111
url = mavenCentralUrl
100112
credentials {
101-
username mavenCentralUsername
102-
password mavenCentralPassword
113+
username = mavenCentralUsername
114+
password = mavenCentralPassword
103115
}
104116
}
105117
}

examples/local-testing-project/build.gradle

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
// Copyright (c) 2015-2025 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.
2+
13
buildscript {
24
repositories {
35
mavenLocal()
46
maven {
5-
url "https://bed-artifactory.bedford.progress.com:443/artifactory/ml-maven-snapshots/"
7+
url = "https://bed-artifactory.bedford.progress.com:443/artifactory/ml-maven-snapshots/"
68
}
79
mavenCentral()
810
}

examples/marklogic-cloud-project/build.gradle

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
// Copyright (c) 2015-2025 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.
2+
13
buildscript {
24
repositories {
35
mavenLocal()
46
maven {
5-
url "https://bed-artifactory.bedford.progress.com:443/artifactory/ml-maven-snapshots/"
7+
url = "https://bed-artifactory.bedford.progress.com:443/artifactory/ml-maven-snapshots/"
68
}
79
mavenCentral()
810
}

ml-app-deployer/src/main/java/com/marklogic/appdeployer/command/AbstractCommand.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,13 @@ protected boolean resourceMergingIsSupported(CommandContext context) {
206206
*/
207207
protected void storeResourceInCommandContextMap(CommandContext context, File resourceFile, String payload) {
208208
final String contextKey = getContextKeyForResourcesToSave();
209-
List<ResourceReference> references = (List<ResourceReference>) context.getContextMap().get(contextKey);
210-
if (references == null) {
209+
Object referencesObj = context.getContextMap().get(contextKey);
210+
List<ResourceReference> references;
211+
if (referencesObj != null) {
212+
@SuppressWarnings("unchecked")
213+
List<ResourceReference> existingReferences = (List<ResourceReference>) referencesObj;
214+
references = existingReferences;
215+
} else {
211216
references = new ArrayList<>();
212217
context.getContextMap().put(contextKey, references);
213218
}

ml-app-deployer/src/main/java/com/marklogic/appdeployer/command/AbstractResourceCommand.java

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,17 @@ public void execute(CommandContext context) {
5151
}
5252

5353
if (mergeResourcesBeforeSaving) {
54-
List<ResourceReference> references = (List<ResourceReference>) context.getContextMap().get(getContextKeyForResourcesToSave());
55-
if (references != null && !references.isEmpty()) {
56-
List<ResourceReference> mergedReferences = mergeResources(references);
57-
if (useCmaForDeployingResources(context)) {
58-
saveMergedResourcesViaCma(context, mergedReferences);
59-
} else {
60-
saveMergedResources(context, getResourceManager(context), mergedReferences);
54+
Object referencesObj = context.getContextMap().get(getContextKeyForResourcesToSave());
55+
if (referencesObj != null) {
56+
@SuppressWarnings("unchecked")
57+
List<ResourceReference> references = (List<ResourceReference>) referencesObj;
58+
if (!references.isEmpty()) {
59+
List<ResourceReference> mergedReferences = mergeResources(references);
60+
if (useCmaForDeployingResources(context)) {
61+
saveMergedResourcesViaCma(context, mergedReferences);
62+
} else {
63+
saveMergedResources(context, getResourceManager(context), mergedReferences);
64+
}
6165
}
6266
}
6367
}

ml-app-deployer/src/main/java/com/marklogic/appdeployer/command/CommandContext.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,15 @@ public Map<String, List<Forest>> getMapOfPrimaryForests() {
6565
if (!appConfig.getCmaConfig().isDeployForests()) {
6666
return null;
6767
}
68+
6869
final String key = "ml-app-deployer-mapOfPrimaryForests";
69-
if (contextMap.containsKey(key)) {
70-
return (Map<String, List<Forest>>) contextMap.get(key);
70+
if (contextMap.containsKey(key) && contextMap.get(key) instanceof Map) {
71+
Object mapObj = contextMap.get(key);
72+
@SuppressWarnings("unchecked")
73+
Map<String, List<Forest>> forestMap = (Map<String, List<Forest>>) mapObj;
74+
return forestMap;
7175
}
76+
7277
Logger logger = LoggerFactory.getLogger(getClass());
7378
try {
7479
logger.info("Retrieving all forest details via CMA");

ml-app-deployer/src/main/java/com/marklogic/appdeployer/command/TestConnectionsCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ private TestResult testManageAppServer(ManageClient client) {
289289
String version = new ClusterManager(client).getVersion();
290290
return new TestResult(client.getManageConfig(), true, "MarkLogic version: " + version);
291291
} catch (Exception ex) {
292-
if (ex instanceof HttpClientErrorException && ((HttpClientErrorException) ex).getRawStatusCode() == 404) {
292+
if (ex instanceof HttpClientErrorException && ((HttpClientErrorException) ex).getStatusCode().value() == 404) {
293293
return new TestResult(client.getManageConfig(), false,
294294
"Unable to access /manage/v2; received 404; unexpected response: " + ex.getMessage());
295295
} else {

ml-app-deployer/src/main/java/com/marklogic/appdeployer/command/es/GenerateModelArtifactsCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public void execute(CommandContext context) {
6565

6666
protected DatabaseClient buildDatabaseClient(AppConfig appConfig) {
6767
String db = appConfig.getModelsDatabase();
68-
if (StringUtils.isEmpty(db)) {
68+
if (!StringUtils.hasText(db)) {
6969
db = appConfig.getContentDatabaseName();
7070
}
7171
if (logger.isInfoEnabled()) {

ml-app-deployer/src/main/java/com/marklogic/mgmt/ManageClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ private void delete(RestTemplate restTemplate, String path, String... headerName
218218
*/
219219
public HttpEntity<String> buildJsonEntity(String json) {
220220
HttpHeaders headers = new HttpHeaders();
221-
headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
221+
headers.setContentType(MediaType.APPLICATION_JSON);
222222
if (manageConfig != null && manageConfig.isCleanJsonPayloads()) {
223223
json = cleanJsonPayload(json);
224224
}

ml-app-deployer/src/main/java/com/marklogic/mgmt/api/security/RoleObjectNodesSorter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public List<ObjectNode> sortObjectNodes(List<ObjectNode> objectNodes) {
3232
// This is to resolve bug #441, where capability-query's are being dropped because the Role class doesn't
3333
// support them. It may be better to refactor this to not deserialize into Role instances so that ObjectNodes
3434
// are used the entire time, even though we'd lose some of the convenience methods provided by the Role class.
35-
final Map<String, ObjectNode> roleMap = new HashMap();
35+
final Map<String, ObjectNode> roleMap = new HashMap<>();
3636

3737
ObjectReader reader = ObjectMapperFactory.getObjectMapper().readerFor(Role.class);
3838
for (ObjectNode objectNode : objectNodes) {

0 commit comments

Comments
 (0)