Skip to content

refactor SseClientTransport #142

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 3 commits into from
Jul 8, 2025
Merged

refactor SseClientTransport #142

merged 3 commits into from
Jul 8, 2025

Conversation

devcrocod
Copy link
Contributor

  • cancellation exception
  • clean up code

How Has This Been Tested?

locally

Breaking Changes

no

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

@devcrocod devcrocod requested review from e5l and Copilot July 7, 2025 13:33
Copy link
Contributor

@Copilot 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 SSE client transport implementation—improving cancellation handling and cleaning up connection logic—and updates integration and unit tests to use dynamic ports and ensure resources are closed.

  • Tests now capture and close the client, use port 0 with actualPort(), and wrap cleanup in try/finally.
  • SseClientTransport was reorganized: message collection extracted, added handleEndpoint/handleMessage, and consolidated resource cleanup.

Reviewed Changes

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

File Description
SseIntegrationTest.kt Introduced client variable, catch/fail wrapper, and ensured client/server closures
SseTransportTest.kt Switched to dynamic ports via actualPort(), added try/finally around server stop
SSEClientTransport.kt Rewrote start, extracted collectMessages, handleEndpoint, handleMessage, and unified cleanup in closeResources

e5l
e5l previously approved these changes Jul 8, 2025
Copy link
Contributor

@e5l e5l left a comment

Choose a reason for hiding this comment

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

lgtm, please check if we need to handle more general exception type

…ndling and try/catch `cancel` in closeResources
Copy link
Contributor

@e5l e5l left a comment

Choose a reason for hiding this comment

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

lgtm

@e5l e5l enabled auto-merge (squash) July 8, 2025 13:22
@e5l e5l merged commit bd3cc4e into main Jul 8, 2025
2 of 3 checks passed
@e5l e5l deleted the devcrocod/refactor-sse-client branch July 8, 2025 13:27
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