Skip to content

Conversation

@vorburger
Copy link
Member

@vorburger vorburger commented Nov 23, 2025

Uses Switch Expressions and Pattern Matching for Switch.

Also introduces WebSocket utilities, and refactors JSON canonicalization.

@vorburger vorburger force-pushed the twilio4 branch 6 times, most recently from 724ca36 to 1896855 Compare November 29, 2025 12:22
@vorburger vorburger marked this pull request as ready for review November 29, 2025 12:22
@vorburger
Copy link
Member Author

/gemini review

@vorburger
Copy link
Member Author

@gemini-code-assist review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a handler for Twilio Conversation Relay, along with WebSocket utilities and a refactoring of JSON canonicalization. The use of modern Java features like switch expressions and records is well done. The new WebSocket utilities are a great addition, but have a couple of design and correctness issues that should be addressed. Specifically, the WebSocketClient leaks resources and the CloseableWebSocketServer has a potentially problematic shutdown hook in its constructor. I've also found a minor issue in the new JsonTester utility. My detailed comments are below.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a handler for Twilio's Conversation Relay feature, leveraging modern Java capabilities like switch expressions and pattern matching. It also adds several WebSocket utilities and refactors JSON handling to use Jackson and a new canonicalization helper. The changes are generally well-structured. My review includes feedback on some key design and correctness aspects, such as removing an automatic shutdown hook from a library class, improving thread safety in the new WebSocket client, and refining the JSON canonicalization logic to be more generic. I've also pointed out a couple of minor code cleanup opportunities.

@vorburger
Copy link
Member Author

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a handler for Twilio's Conversation Relay, including WebSocket server and client utilities. It makes good use of modern Java features like switch expressions and pattern matching. The PR also includes a significant and beneficial refactoring of JSON handling and testing infrastructure, moving from a GSON-based utility to a more robust Jackson-based approach with a new JsonTester helper. The code is well-structured and includes good test coverage. I have a couple of suggestions to improve the robustness of the new ShutdownCloser utility and to clarify the behavior of the new ObjectTreeSorter.

Comment on lines +60 to +74
private static void sortListByID(List<Object> list) {
Collections.sort(
list,
(o1, o2) -> {
// skipcq: JAVA-C1003
if (o1 instanceof Map m1 && o2 instanceof Map m2) {
var oid1 = m1.get("@id");
var oid2 = m2.get("@id");
// skipcq: JAVA-C1003
if (oid1 instanceof String id1 && oid2 instanceof String id2)
return id1.compareTo(id2);
return 0;
} else return 0;
});
}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The sortListByID method unconditionally sorts lists of objects if they contain a @id field. The previous implementation in JSON.java had a TODO comment indicating this should probably only be done for JSON-LD. By making this the default behavior for the new JsonTester, it might cause unexpected sorting in tests for plain JSON objects where list order is significant and items happen to have an @id field. This could lead to brittle tests. It might be better to make this sorting behavior optional or move it to a specific utility for JSON-LD testing.

Uses Switch Expressions and Pattern Matching for Switch.

Also introduces WebSocket utilities, and refactors JSON canonicalization.
@vorburger
Copy link
Member Author

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a handler for Twilio's Conversation Relay, leveraging modern Java features like switch expressions and pattern matching. It also brings in significant refactoring by introducing new WebSocket utilities, a graceful shutdown mechanism, and moving JSON test utilities to a new Jackson-based implementation. The changes are well-organized and improve the codebase. My review includes a few suggestions to enhance maintainability by replacing magic numbers with named constants and to improve clarity in the new ObjectTreeSorter utility.

@vorburger vorburger enabled auto-merge (rebase) November 29, 2025 16:43
@vorburger vorburger merged commit 1339120 into enola-dev:main Nov 29, 2025
18 of 19 checks passed
@vorburger vorburger deleted the twilio4 branch November 29, 2025 17:15
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.

1 participant