dropwizard-java8 icon indicating copy to clipboard operation
dropwizard-java8 copied to clipboard

Argument factories should be using Class.isAssignableFrom, not instanceof

Open qualidafial opened this issue 10 years ago • 0 comments

instanceof is always false for null, which means the argument factory misses a chance to provide the correct SQL type.

These factories should be using e.g. Foo.class.isAssignableFrom(expectedType) instead of value instanceof Foo:

  • InstantArgumentFactory
  • LocalDateArgumentFactory
  • LocalDateTimeArgumentFactory
  • OptionalArgumentFactory
  • OptionalInstantArgumentFactory
  • OptionalLocalDateArgumentFactory
  • OptionalLocalDateTimeArgumentFactory

Although the optional ones are arguably moot, since one should never pass null to a method that expects an optional.

qualidafial avatar Nov 24 '15 18:11 qualidafial