Fixes #27256

This PR fixes a bug that renders read-only UrlPathHelpers unusable, because shouldRemoveSemicolonContent() throws an exception. For example, when using UrlPathHelper#rawPathInstance, which is read-only.

The checkReadOnly() method should only be called from methods that modify properties to prevent modification of read-only instances.

Comment From: sbrannen

Hi @evpaassen,

Can you please introduce a unit test that fails prior to the change and passes after the change?

Comment From: evpaassen

Hi @sbrannen,

I added a test now. I'm not sure it really has added value, because nothing regarding the readOnly property in this class was tested before, and the new test is effectively testing a getter method. But on the other hand, it will prevent a regression, I guess.

Please let me know if you're happy with it, or that I should make any changes.

Comment From: sbrannen

I added a test now. I'm not sure it really has added value, because nothing regarding the readOnly property in this class was tested before, and the new test is effectively testing a getter method. But on the other hand, it will prevent a regression, I guess.

Yes, my intent was to make sure the problem is fixed and does not return (i.e., to serve as a regression test).

Please let me know if you're happy with it, or that I should make any changes.

That looks good now.

Thanks

Comment From: evpaassen

You're welcome. And thanks for reviewing and merging!

Comment From: sbrannen

Note that this was also backported to 5.2.17 in 10a90d32044014386aee5c9923c38320fc9c2d90.