Skip to content
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 @@ -83,8 +83,11 @@ private static void removeNodeAtPointer(String uri, JsonNode rootNode, String js
JsonNode parentNode = rootNode.at(parentPointer);

if (parentNode.isObject()) {
String fieldName = pointer.last().getMatchingProperty();
((ObjectNode) parentNode).remove(fieldName);
JsonPointer lastSegment = pointer.last();
if (lastSegment != null) {
String fieldName = lastSegment.getMatchingProperty();
((ObjectNode) parentNode).remove(fieldName);
}
} else if (parentNode.isArray()) {
logger.warn("Array element exclusion not supported for JSONPointer '{}'. " +
"Consider excluding the entire array property instead.", jsonPointer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,15 @@ protected final DocumentWriteSet filterDocuments(Context context, Function<Strin
continue;
}

final String contentHash = computeHash(serializeContent(doc));
final String serializedContent = serializeContent(doc);
if (serializedContent == null) {
// Not sure if the doc can have null content - possibly for a naked properties document? - but if it
// does, just include it in the write set.
Comment on lines +157 to +158
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment expresses uncertainty about when serializedContent can be null ('Not sure if the doc can have null content'). This uncertainty should be resolved through code analysis or documentation review. Update the comment to either explain the specific scenarios where null content occurs or remove the speculative language if the behavior is now understood.

Suggested change
// Not sure if the doc can have null content - possibly for a naked properties document? - but if it
// does, just include it in the write set.
// If the content cannot be serialized (serializeContent returned null), include the document in the write set unchanged.

Copilot uses AI. Check for mistakes.
newWriteSet.add(doc);
continue;
}

final String contentHash = computeHash(serializedContent);
final String existingHash = hashRetriever.apply(doc.getUri());
if (logger.isTraceEnabled()) {
logger.trace("URI: {}, existing Hash: {}, new Hash: {}", doc.getUri(), existingHash, contentHash);
Expand All @@ -171,7 +179,7 @@ protected final DocumentWriteSet filterDocuments(Context context, Function<Strin
}
}

if (!skippedDocuments.isEmpty()) {
if (!skippedDocuments.isEmpty() && skippedDocumentsConsumer != null) {
skippedDocumentsConsumer.accept(skippedDocuments.toArray(new DocumentWriteOperation[0]));
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2025 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.
* Copyright (c) 2010-2026 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.
*/
package com.marklogic.client.impl;

Expand Down Expand Up @@ -618,6 +618,7 @@ public Response apply(Request.Builder funcBuilder) {
}
};
Response response = sendRequestWithRetry(requestBldr, (transaction == null), doGetFunction, null);
Objects.requireNonNull(response);

int status = response.code();
if (status == STATUS_NOT_FOUND) {
Expand Down Expand Up @@ -895,6 +896,7 @@ public Response apply(Request.Builder funcBuilder) {
}
};
Response response = sendRequestWithRetry(requestBldr, (transaction == null), doGetFunction, null);
Objects.requireNonNull(response);
int status = response.code();
if (status == STATUS_NOT_FOUND) {
throw new ResourceNotFoundException(
Expand Down Expand Up @@ -1501,6 +1503,7 @@ public Response apply(Request.Builder funcBuilder) {
}
};
Response response = sendRequestWithRetry(requestBldr, doPostFunction, null);
Objects.requireNonNull(response);
int status = response.code();
if (status == STATUS_FORBIDDEN) {
throw new ForbiddenUserException("User is not allowed to open transactions", extractErrorFields(response));
Expand All @@ -1510,12 +1513,14 @@ public Response apply(Request.Builder funcBuilder) {
getReasonPhrase(response), extractErrorFields(response));
}

String location = response.headers().get("Location");
List<ClientCookie> cookies = new ArrayList<>();
final String location = response.headers().get("Location");

final List<ClientCookie> cookies = new ArrayList<>();
for (String setCookie : response.headers(HEADER_SET_COOKIE)) {
ClientCookie cookie = parseClientCookie(requestBldr.build().url(), setCookie);
cookies.add(cookie);
}

closeResponse(response);
if (location == null) throw new MarkLogicInternalException("transaction open failed to provide location");
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When response is null, location will be null (line 1517), leading to this exception being thrown. However, the error message 'transaction open failed to provide location' is misleading when the actual issue is a null response. Consider checking for null response explicitly before this line and providing a more accurate error message.

Copilot uses AI. Check for mistakes.
if (!location.contains("/")) {
Expand Down Expand Up @@ -2562,6 +2567,7 @@ public Response apply(Request.Builder funcBuilder) {
}
};
Response response = sendRequestWithRetry(requestBldr, doGetFunction, null);
Objects.requireNonNull(response);
int status = response.code();
if (status == STATUS_FORBIDDEN) {
throw new ForbiddenUserException("User is not allowed to read "
Expand Down Expand Up @@ -2749,6 +2755,7 @@ public Response apply(Request.Builder funcBuilder) {
}
};
Response response = sendRequestWithRetry(requestBldr, doDeleteFunction, null);
Objects.requireNonNull(response);
int status = response.code();
if (status == STATUS_FORBIDDEN) {
throw new ForbiddenUserException("User is not allowed to delete "
Expand Down Expand Up @@ -3181,6 +3188,7 @@ public Response apply(Request.Builder funcBuilder) {
};

Response response = sendRequestWithRetry(requestBldr, (transaction == null), doPostFunction, resendableConsumer);
Objects.requireNonNull(response);
int status = response.code();
checkStatus(response, status, operation, "resource", path,
ResponseStatus.OK_OR_CREATED_OR_NO_CONTENT);
Expand Down Expand Up @@ -3712,6 +3720,7 @@ public RESTServiceResultIterator postMultipartForm(
Consumer<Boolean> resendableConsumer = null;

Response response = sendRequestWithRetry(requestBldr, (transaction == null), doPostFunction, resendableConsumer);
Objects.requireNonNull(response);
int status = response.code();
checkStatus(response, status, "apply", "resource", path, ResponseStatus.OK_OR_CREATED_OR_NO_CONTENT);
return makeResults(OkHttpServiceResultIterator::new, reqlog, "apply", "resource", response);
Expand Down Expand Up @@ -3782,6 +3791,7 @@ private <U extends OkHttpResultIterator> U postIteratedResourceImpl(
);

Response response = sendRequestWithRetry(requestBldr, (transaction == null), doPostFunction, resendableConsumer);
Objects.requireNonNull(response);
checkStatus(response, response.code(), "apply", "resource", path, ResponseStatus.OK_OR_CREATED_OR_NO_CONTENT);

boolean shouldStreamResults = "eval".equalsIgnoreCase(path) || "invoke".equalsIgnoreCase(path);
Expand Down Expand Up @@ -4820,6 +4830,7 @@ public Response apply(Request.Builder funcBuilder) {
}
};
Response response = sendRequestWithRetry(requestBldr, doGetFunction, null);
Objects.requireNonNull(response);
int status = response.code();
if (status == STATUS_FORBIDDEN) {
throw new ForbiddenUserException(
Expand Down Expand Up @@ -5040,7 +5051,8 @@ public Response apply(Request.Builder funcBuilder) {
}
};
Response response = sendRequestWithRetry(requestBldr, doGetFunction, null);
int status = response.code();
Objects.requireNonNull(response);
final int status = response.code();
if (status == STATUS_FORBIDDEN) {
throw new ForbiddenUserException("User is not allowed to match",
extractErrorFields(response));
Expand Down Expand Up @@ -5618,9 +5630,11 @@ private void executeRequest(CallResponseImpl responseImpl) {

if (session != null) {
List<ClientCookie> cookies = new ArrayList<>();
for (String setCookie : response.headers(HEADER_SET_COOKIE)) {
ClientCookie cookie = parseClientCookie(requestBldr.build().url(), setCookie);
cookies.add(cookie);
if (response != null) {
for (String setCookie : response.headers(HEADER_SET_COOKIE)) {
ClientCookie cookie = parseClientCookie(requestBldr.build().url(), setCookie);
cookies.add(cookie);
}
}
((SessionStateImpl) session).setCookies(cookies);
}
Expand Down