fix: correct ResourceOperationTypeAdapter dispatch and add guard#899
fix: correct ResourceOperationTypeAdapter dispatch and add guard#899pisv merged 2 commits intoeclipse-lsp4j:mainfrom
Conversation
|
@sebthom Good catch, thank you for the fix! 👍 It is already a great improvement, but would not it even better to check that the (I don't quite like throwing |
|
Would that mean the |
As far as I can see, if (!ResourceOperation.class.isAssignableFrom(type.getRawType())) {
return null;
}with if (!CreateFile.class.isAssignableFrom(type.getRawType()) &&
!DeleteFile.class.isAssignableFrom(type.getRawType()) &&
!RenameFile.class.isAssignableFrom(type.getRawType())) {
return null;
} |
|
This does not work |
|
Thank you for verifying it. Looks like it was not a good idea, then. What do you think about throwing |
I have no strong opinion about this. I am also fine the way it is. |
|
Just looking through the GSON source code, it seems that the |
Does it have any practical relevance which one is thrown? Both are not recoverable or? |
|
It does have a practical relevance by setting a precedent of throwing Otherwise, we could just as well throw a |
|
Maybe this should be discussed separately and addressed in a separate PR? I can see other places where |
|
Thank you for discussing it in detail. The only reason for this discussion is that I could find no prior cases of throwing |
|
I change it to whatever you feel comfortable. Shall I go for IllegalArgumentException? |
|
I'd suggest throwing |
6e38fd4 to
aa32c3e
Compare
|
@pisv done |
- Replace reversed `isAssignableFrom` checks with `instanceof` to correctly handle subclasses (e.g., `CreateFile` derivatives) in write(...) - Add explicit `JsonParseException` for unknown `ResourceOperation` subtypes in write(...) to mirror read(...) and avoid silent malformed JSON - Improves protocol correctness and failure transparency when encountering unsupported operations Tests: add `ResourceOperationTypeAdapterTest` covering subclass serialization and unknown subtype failure
aa32c3e to
86a1073
Compare
|
@sebthom I have made minor updates to |
|
Looks good. Thanks! |
pisv
left a comment
There was a problem hiding this comment.
LGTM, thanks! 👍 And sorry for the extensive discussion of a small thing that mattered to me.
isAssignableFromchecks withinstanceofto correctly handle subclasses (e.g.,CreateFilederivatives) in write(...)JsonParseExceptionfor unknownResourceOperationsubtypes in write(...) to mirror read(...) and avoid silent malformed JSONTests: add
ResourceOperationTypeAdapterTestcovering subclass serialization and unknown subtype failure