Skip to content

Conversation

@Marcono1234
Copy link
Contributor

Purpose

Follow-up for #2435 (comment) and comment below

Description

Validate that instances created by an InstanceCreator are not null, and are actually of the requested type. This hopefully makes troubleshooting for users easier than encountering a ClassCastException at a completely different place, without any indication that a faulty InstanceCreator is the cause.

As mentioned in #2435 (comment), there is currently code which relies on Java type erasure and Gson implementation details to misuse the missing checks and create unrelated instances. It has to be decided if it is acceptable to break that code.

Checklist

  • New code follows the Google Java Style Guide
  • If necessary, new public API validates arguments, for example rejects null
  • New public API has Javadoc
    • Javadoc uses @since $next-version$
      ($next-version$ is a special placeholder which is automatically replaced during release)
  • If necessary, new unit tests have been added
    • Assertions in unit tests use Truth, see existing tests
    • No JUnit 3 features are used (such as extending class TestCase)
    • If this pull request fixes a bug, a new test was added for a situation which failed previously and is now fixed
  • mvn clean verify javadoc:jar passes without errors

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.

1 participant