Skip to content

Fix #1175: Change IndexInputStream to throw NotSupportedException for…#1231

Merged
NightOwl888 merged 1 commit intoapache:masterfrom
sauravk58:fix-issue-1175
Jan 10, 2026
Merged

Fix #1175: Change IndexInputStream to throw NotSupportedException for…#1231
NightOwl888 merged 1 commit intoapache:masterfrom
sauravk58:fix-issue-1175

Conversation

@sauravk58
Copy link
Contributor

@sauravk58 sauravk58 commented Jan 6, 2026

  • You've read the Contributor Guide and Code of Conduct.
  • You've included unit or integration tests for your change, where applicable.
  • You've included inline docs for your change, where applicable.
  • There's an open issue for the PR that you are making. If you'd like to propose a change, please open an issue to discuss the change or find an existing issue.

Summary of the changes (Less than 80 chars)

Fixes #1175

Description

Change IndexInputStream to throw NotSupportedException for writable members

Changed Flush(), SetLength(), and Write() methods to throw NotSupportedException instead of IllegalStateException/InvalidCastException to be consistent with .NET conventions for read-only streams.

Added unit tests to verify the correct exception types are thrown.

…on for writable members

Changed Flush(), SetLength(), and Write() methods to throw NotSupportedException instead of IllegalStateException/InvalidCastException to be consistent with .NET conventions for read-only streams.

Added unit tests to verify the correct exception types are thrown.
Copilot AI review requested due to automatic review settings January 6, 2026 19:43
Copy link
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 fixes issue #1175 by updating IndexInputStream to throw NotSupportedException instead of IllegalStateException or InvalidCastException for unsupported write operations on the read-only stream, aligning with .NET Stream conventions.

  • Changed exception types in Flush(), SetLength(), and Write() methods from Lucene-specific exceptions to .NET's standard NotSupportedException
  • Added comprehensive unit tests to verify correct exception behavior
  • Removed TODO comments that questioned whether to use NotSupportedException

Reviewed changes

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

File Description
src/Lucene.Net.Replicator/IndexInputInputStream.cs Updated three methods (Flush, SetLength, Write) to throw NotSupportedException instead of IllegalStateException/InvalidCastException, conforming to .NET Stream conventions for read-only streams
src/Lucene.Net.Tests.Replicator/IndexInputStreamTest.cs Added three unit tests to verify that Flush, SetLength, and Write methods correctly throw NotSupportedException

The changes in this PR are well-structured and appropriate. The use of NotSupportedException is the correct .NET convention for Stream methods that are not supported (as indicated by CanWrite => false). The tests properly validate the expected behavior, and the implementation is clean and consistent.


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

@NightOwl888 NightOwl888 added the notes:improvement An enhancement to an existing feature label Jan 10, 2026
Copy link
Contributor

@NightOwl888 NightOwl888 left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!

@NightOwl888 NightOwl888 merged commit 9a9de82 into apache:master Jan 10, 2026
18 of 19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

notes:improvement An enhancement to an existing feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Change IndexInputStream to throw NotSupportedExcpetion for writable members

3 participants