Improve reload diagnosics when a character set plugin is missing #1282
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently, reloading a saved parser when a neccessary character set plugin is not on the classpath results in an exception with a very helpful message that has nothing to do with character sets or plugins, for example:
This is a known issue with scala and its use of proxy when serializing data structures like Lists and Maps.
To fix the exception and improve diagnostics, this uses writeReplace to serialize a BitsCharset as a BitsCharsetSerializationProxy with information about the needed BitsCharset. This proxy implements readResolve to look up the BitsCharset from the bits charset registry and restore the original BitsChraset. If not found in the registry, then we throw an helpful exception that bubbles up to the reload function and we can output a helpful diagnostic. Now we get something like:
Add an integraion test to make sure this errors with a reasonable diagnostic, which require splitting a schema file into valid and invalid parts so we can reuse it with the CLI.
DAFFODIL-2915