Skip to content

Update styx messages in Java#40

Merged
vshcryabets merged 2 commits into
masterfrom
fix/update-styx-messages
Aug 4, 2025
Merged

Update styx messages in Java#40
vshcryabets merged 2 commits into
masterfrom
fix/update-styx-messages

Conversation

@vshcryabets
Copy link
Copy Markdown
Owner

No description provided.

@vshcryabets vshcryabets requested a review from Copilot August 4, 2025 18:04
@vshcryabets vshcryabets self-assigned this Aug 4, 2025
Copy link
Copy Markdown
Contributor

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 refactors the Styx message system in Java by moving message classes to the v9p2000 package and implementing a factory pattern for message creation. The changes improve code organization and encapsulation by centralizing message instantiation through factory methods.

  • Move StyxTWalkMessage and StyxTWStatMessage classes to the v9p2000 package structure
  • Implement factory methods for creating these message types instead of direct constructor calls
  • Update all references throughout the codebase to use the new factory pattern and package locations

Reviewed Changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
StyxTWalkMessage.java Moved from messages package to v9p2000 package and made constructor protected
StyxTWStatMessage.java Moved to v9p2000 package and made constructor protected
Factory.java Added factory methods for TWalk and TWStat message creation
FactoryImpl.java Implemented new factory methods
StyxFile.java Updated to use factory methods instead of direct constructors
StyxSerializerImpl.java Updated field access and removed unused imports
StyxDeserializerImpl.java Updated to use factory methods for message creation
StringSerializerImpl.java Added serialization support for new message types
Multiple test files Updated imports and added comprehensive test coverage

final var feature = mTransmitter.sendMessage(tWalk, mClientId);
final StyxMessage rWalk = feature.getResult(mTimeout);
if (rWalk.getType() == MessageType.Rerror)
throw StyxErrorMessageException.newInstance(((StyxRErrorMessage) rWalk).mError + " at " + mPath);
Copy link

Copilot AI Aug 4, 2025

Choose a reason for hiding this comment

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

The removal of the path validation check could cause silent failures. The original code verified that ((StyxRWalkMessage) rWalk).qidList.size() != tWalk.getPathLength() and threw an exception if the path wasn't fully traversed. Without this check, partial path walks may be incorrectly treated as successful.

Suggested change
throw StyxErrorMessageException.newInstance(((StyxRErrorMessage) rWalk).mError + " at " + mPath);
throw StyxErrorMessageException.newInstance(((StyxRErrorMessage) rWalk).mError + " at " + mPath);
// Path validation check: ensure full walk
int requestedPathLength = StyxSerializerImpl.splitPath(path).size();
if (rWalk instanceof com.v2soft.styxlib.l5.messages.v9p2000.StyxRWalkMessage) {
var rWalkMsg = (com.v2soft.styxlib.l5.messages.v9p2000.StyxRWalkMessage) rWalk;
if (rWalkMsg.qidList.size() != requestedPathLength) {
throw new StyxException("Walk failed: only " + rWalkMsg.qidList.size() +
" of " + requestedPathLength + " path elements traversed for path '" + path + "'");
}
}

Copilot uses AI. Check for mistakes.
var walkMessage = (StyxTWalkMessage)message;
size += 4 + 2;
for (var pathElement : walkMessage.getPathElements())
for (var pathElement : walkMessage.mPathElements)
Copy link

Copilot AI Aug 4, 2025

Choose a reason for hiding this comment

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

[nitpick] Direct field access to mPathElements bypasses potential null checks or validation that might exist in getter methods. Consider maintaining the getter method approach for better encapsulation.

Suggested change
for (var pathElement : walkMessage.mPathElements)
for (var pathElement : walkMessage.getPathElements())

Copilot uses AI. Check for mistakes.
@vshcryabets vshcryabets merged commit b0d8192 into master Aug 4, 2025
2 checks passed
@vshcryabets vshcryabets deleted the fix/update-styx-messages branch August 4, 2025 18:08
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.

2 participants