Skip to content

MLE-27481 Polaris fixes#1920

Merged
rjrudin merged 1 commit intodevelopfrom
feature/27481-polaris
Mar 11, 2026
Merged

MLE-27481 Polaris fixes#1920
rjrudin merged 1 commit intodevelopfrom
feature/27481-polaris

Conversation

@rjrudin
Copy link
Contributor

@rjrudin rjrudin commented Mar 11, 2026

No description provided.

Copilot AI review requested due to automatic review settings March 11, 2026 19:43
@github-actions
Copy link

github-actions bot commented Mar 11, 2026

Copyright Validation Results
Total: 1 | Passed: 1 | Failed: 0 | Skipped: 0 | at: 2026-03-11 20:04:46 UTC | commit: 2192229

✅ Valid Files

  • marklogic-client-api/src/main/java/com/marklogic/client/impl/OkHttpServices.java

✅ All files have valid copyright headers!

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses “Polaris” (static analysis) findings in the OkHttp-based REST services implementation by tightening request-body handling and guarding against passing null results into handle deserialization.

Changes:

  • Simplifies PUT/POST request sending by removing dead sentValue == null branches and always using a non-null RequestBody.
  • Avoids calling receiveContent(...) with a null result from makeResult(...) in several resource operations (GET/PUT/DELETE).
  • Refactors result handling to store the makeResult(...) output in a local variable before use.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +2950 to +2952
if (result != null) {
outputBase.receiveContent(result);
}
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

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

The behavior around empty/no-content responses changed here (now skipping receiveContent when makeResult returns null). Since some handles (e.g., BytesHandle) can throw on empty content, it would be good to add a unit test that simulates a 204/empty-body response for getResource and verifies it does not throw and that the output handle is in a predictable state (e.g., cleared via set(null) if you adopt that approach).

Suggested change
if (result != null) {
outputBase.receiveContent(result);
}
outputBase.receiveContent(result);

Copilot uses AI. Check for mistakes.
outputBase.receiveContent(makeResult(reqlog, "read", "resource", response, as));
Object result = makeResult(reqlog, "read", "resource", response, as);
if (result != null) {
outputBase.receiveContent(result);
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

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

When makeResult(...) returns null (e.g., response body length is 0), skipping receiveContent means the provided output handle is left unchanged. If callers reuse the same handle instance across calls, it can retain stale content from a previous response. Consider explicitly clearing the handle in the null case (e.g., when output implements ContentHandle, call set(null)), so the output consistently reflects an empty response while still avoiding handle implementations that throw on receiveContent(null)/empty content (e.g., BytesHandle).

Suggested change
outputBase.receiveContent(result);
outputBase.receiveContent(result);
} else if (output instanceof ContentHandle) {
((ContentHandle<?>) output).set(null);

Copilot uses AI. Check for mistakes.
outputBase.receiveContent(makeResult(reqlog, "write", "resource", response, as));
Object result = makeResult(reqlog, "write", "resource", response, as);
if (result != null) {
outputBase.receiveContent(result);
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

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

When makeResult(...) returns null for an empty response body, the new null-guard prevents receiveContent(null) (good for handles that throw on empty content), but it also means outputBase is not updated/cleared. To avoid returning an output handle with stale content, consider clearing the output via ContentHandle.set(null) (when applicable) in the null-result case.

Suggested change
outputBase.receiveContent(result);
outputBase.receiveContent(result);
} else if (output instanceof ContentHandle) {
((ContentHandle<?>) output).set(null);

Copilot uses AI. Check for mistakes.
outputBase.receiveContent(makeResult(reqlog, "delete", "resource", response, as));
Object result = makeResult(reqlog, "delete", "resource", response, as);
if (result != null) {
outputBase.receiveContent(result);
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

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

As with the other call sites, if makeResult(...) returns null for a 204/empty-body response, the output handle isn't updated. If the same handle instance is reused, it can keep old content. Consider clearing the output in the null-result case (e.g., if (output instanceof ContentHandle) ((ContentHandle<?>) output).set(null);) so callers don't observe stale data.

Suggested change
outputBase.receiveContent(result);
outputBase.receiveContent(result);
} else if (output instanceof ContentHandle) {
((ContentHandle<?>) output).set(null);

Copilot uses AI. Check for mistakes.
BillFarber
BillFarber previously approved these changes Mar 11, 2026
@rjrudin rjrudin force-pushed the feature/27481-polaris branch from 1bf5958 to 2192229 Compare March 11, 2026 20:04
@rjrudin rjrudin merged commit bdca776 into develop Mar 11, 2026
5 checks passed
@rjrudin rjrudin deleted the feature/27481-polaris branch March 11, 2026 20:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants