Skip to content

MLE-23004 - Addresses compiler warnings in the Java Client #1795

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 22, 2025
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ private static void registerHandlers() {
} catch (JAXBException e) {
throw new IllegalStateException(e);
}
ObjectMapper mapper = new JacksonDatabindHandle(null).getMapper();

@SuppressWarnings("unchecked")
ObjectMapper mapper = new JacksonDatabindHandle(null).getMapper();
// we do the next three lines so dates are written in xs:dateTime format
// which makes them ready for range indexes in MarkLogic Server
String ISO_8601_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSSXXX";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ public String getUri() {
}

public long getRowNum() {
return new Long(rowNum).longValue();
try {
return Long.valueOf(rowNum).longValue();
} catch (NumberFormatException e) {
throw new IllegalArgumentException("Invalid rowNum value: " + rowNum, e);
}
}

public XsAnyAtomicTypeVal put(String name, XsAnyAtomicTypeVal val) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public BasicPage<T> setTotalSize(long totalSize) {
}

public BasicPage<T> setSize(long size) {
this.size = new Long(size);
this.size = Long.valueOf(size);
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3580,10 +3580,10 @@ public Number getNumber() {
String value = getString();
if (value == null) return null;
if (getType() == EvalResult.Type.DECIMAL) return new BigDecimal(value);
else if (getType() == EvalResult.Type.DOUBLE) return new Double(value);
else if (getType() == EvalResult.Type.FLOAT) return new Float(value);
else if (getType() == EvalResult.Type.DOUBLE) return Double.valueOf(value);
else if (getType() == EvalResult.Type.FLOAT) return Float.valueOf(value);
// MarkLogic integers can be much larger than Java integers, so we'll use Long instead
else if (getType() == EvalResult.Type.INTEGER) return new Long(value);
else if (getType() == EvalResult.Type.INTEGER) return Long.valueOf(value);
else return new BigDecimal(value);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,15 @@ public void testBuiltinReadWrite()
String binDocId = "/test/testAs1.bin";
BinaryDocumentManager binMgr = Common.client.newBinaryDocumentManager();

byte[] beforeBytes = beforeText.getBytes("UTF-8");
byte[] beforeBytes = beforeText.getBytes(java.nio.charset.StandardCharsets.UTF_8);

binMgr.writeAs(binDocId, beforeBytes);
afterText = new String(binMgr.readAs(binDocId, byte[].class), "UTF-8");
afterText = new String(binMgr.readAs(binDocId, byte[].class), java.nio.charset.StandardCharsets.UTF_8);
binMgr.delete(binDocId);
assertEquals(beforeText, afterText);

binMgr.writeAs(binDocId, new ByteArrayInputStream(beforeBytes));
try ( Reader reader = new InputStreamReader( binMgr.readAs(binDocId, InputStream.class), "UTF-8") ) {
try ( Reader reader = new InputStreamReader( binMgr.readAs(binDocId, InputStream.class), java.nio.charset.StandardCharsets.UTF_8) ) {
cnum = reader.read(cbuf);
binMgr.delete(binDocId);
assertEquals(beforeText.length(), cnum);
Expand Down Expand Up @@ -341,7 +341,7 @@ private void verifyHandleRegistry(DatabaseClientFactory.Bean clientFactoryBean)

boolean threwError = false;
try {
textMgr.writeAs(textDocId, new Integer(5));
textMgr.writeAs(textDocId, 5);
} catch(Exception e) {
threwError = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,10 @@ public void testHostnameVerifier() throws SSLException, CertificateParsingExcept
// if the entry is 2 it's a DNS or 7 then it's an IP address
// according to https://docs.oracle.com/javase/8/docs/api/java/security/cert/X509Certificate.html#getSubjectAlternativeNames--
Collection<List<?>> listSas = new ArrayList<>();
listSas.add(Arrays.asList(new Object[] {new Integer(type_dnsName), passedSas[0]}));
listSas.add(Arrays.asList(new Object[] {new Integer(type_ipAddress), passedSas[1]}));
listSas.add(Arrays.asList(new Object[] {new Integer(type_dnsName), passedSas[2]}));
listSas.add(Arrays.asList(new Object[] {new Integer(type_dnsName), passedSas[3]}));
listSas.add(Arrays.asList(new Object[] { type_dnsName, passedSas[0] }));
listSas.add(Arrays.asList(new Object[] { type_ipAddress, passedSas[1] }));
listSas.add(Arrays.asList(new Object[] { type_dnsName, passedSas[2] }));
listSas.add(Arrays.asList(new Object[] { type_dnsName, passedSas[3] }));
when(cert.getSubjectAlternativeNames()).thenReturn(listSas);

// now that we have the cert all mocked with common names and subject alts, call the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ open class ToolsPlugin : Plugin<Project> {

project.extensions.add("endpointProxiesConfig", EndpointProxiesConfig())

project.tasks.create("generateEndpointProxies", EndpointProxiesGenTask::class.java)
project.tasks.create("initializeModule", ModuleInitTask::class.java)
project.tasks.create("checkCustomService", ServiceCompareTask::class.java)
project.tasks.register("generateEndpointProxies", EndpointProxiesGenTask::class.java)
project.tasks.register("initializeModule", ModuleInitTask::class.java)
project.tasks.register("checkCustomService", ServiceCompareTask::class.java)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -667,9 +667,9 @@ ${funcDecls}
} else {
"""return BaseProxy.${typeConverter(returnType)}.to${
if (returnMapped.contains("."))
returnMapped.substringAfterLast(".").capitalize()
returnMapped.substringAfterLast(".").replaceFirstChar { it.uppercase() }
else
returnMapped.capitalize()
returnMapped.replaceFirstChar { it.uppercase() }
}(
${callImpl}
);"""
Expand Down Expand Up @@ -757,7 +757,7 @@ ${funcDecls}
private ${className}(${paramSig}) {${
paramNames.map{paramName ->
"""
set${paramName.capitalize()}(${paramName});"""
set${paramName.replaceFirstChar { it.uppercase() }}(${paramName});"""
}.joinToString("")}
}"""
return constructor
Expand Down Expand Up @@ -795,10 +795,10 @@ ${funcDecls}
val mappedType = getJavaDataType(paramType, paramMapping, paramKind, isMultiple)
val sigType = getSigDataType(mappedType, isMultiple)
"""
${getterAccess}${sigType} get${paramName.capitalize()}(){
${getterAccess}${sigType} get${paramName.replaceFirstChar { it.uppercase() }}(){
return arg_${paramName};
}
private void set${paramName.capitalize()}(${sigType} value){
private void set${paramName.replaceFirstChar { it.uppercase() }}(${sigType} value){
this.arg_${paramName} = value;
}"""
}.joinToString("")
Expand All @@ -809,9 +809,9 @@ ${funcDecls}
if (paramType == "anyDocument") paramName
else """BaseProxy.${typeConverter(paramType)}.from${
if (mappedType.contains("."))
mappedType.substringAfterLast(".").capitalize()
mappedType.substringAfterLast(".").replaceFirstChar { it.uppercase() }
else
mappedType.capitalize()
mappedType.replaceFirstChar { it.uppercase() }
}(${paramName})"""
val converter =
"""BaseProxy.${paramKind}Param("${paramName}", ${isNullable}, ${convertExpr})"""
Expand All @@ -821,14 +821,14 @@ ${funcDecls}
val converter =
if (datatype == "int") "Integer"
else if (datatype == "unsignedInt") "UnsignedInteger"
else datatype.capitalize()
else datatype.replaceFirstChar { it.uppercase() }
return converter+"Type"
}
fun typeFormat(documentType: String) : String {
val format =
if (documentType == "array" || documentType == "object") "Format.JSON"
else if (documentType == "anyDocument") "Format.UNKNOWN"
else "Format."+documentType.substringBefore("Document").toUpperCase()
else "Format."+documentType.substringBefore("Document").uppercase()
return format
}
fun paramKindCardinality(currCardinality: ValueCardinality, param: ObjectNode): ValueCardinality {
Expand Down Expand Up @@ -953,7 +953,7 @@ declare option xdmp:mapping "false";
when (paramType) {
"array","object" ->
if (moduleExtension == "mjs" || moduleExtension == "sjs")
paramType.capitalize()+"Node"
paramType.replaceFirstChar { it.uppercase() }+"Node"
else
paramType+"-node()"
else ->
Expand Down Expand Up @@ -1104,15 +1104,16 @@ ${errorReport}"""
return rootPath+appendSuffix
}
fun checkObjectsEqual(errors: MutableList<String>, parentKey: String, customObj: ObjectNode, baseObj: ObjectNode) {
customObj.fields().forEach{(key, customVal) ->
customObj.fieldNames().forEach { key ->
val customVal = customObj.get(key)
if (key.startsWith("$")) {
} else if (!baseObj.has(key)) {
errors.add("${key} property of ${parentKey} exists in custom service but not base service")
} else {
checkValuesEqual(errors, key, customVal, baseObj.get(key))
}
}
baseObj.fields().forEach{(key, _) ->
baseObj.fieldNames().forEach { key ->
if (!customObj.has(key)) {
errors.add("${key} property of ${parentKey} exists in base service but not custom service")
}
Expand Down