In GetInstancesFromServiceLoader, do not hide ServiceConfigurationError

Description

In class GetInstancesFromServiceLoader, thrown ServiceConfigurationErrors are not logged:

There are cases where it would be useful if these were logged after all.
Take for example the case where a developer adding a new ConstraintValidator has made a mistake and has not provided a no-args constructor for the validator. ServiceLoader will in this case fail to load the ConstraintValidator, but this will not be obvious to the developer.

Environment

None

Activity

Show:
Guillaume Smet
January 17, 2019, 3:15 PM

Indeed, we should probably log an error.

do you have any recollection of why it was totally ignored in the first place? Can we consider logging an error with the exception but still ignore it?

Gunnar Morling
January 17, 2019, 4:55 PM

I don't quite remember unfortunately. Can you tell apart a missing no-arg constructor from classloader-incompatibility perhaps, e.g. by examining the exception's cause? But in general I'd agree that logging something seems reasonable.

Stein Desmet
January 17, 2019, 5:04 PM

In case of the missing no-arg constructor, the cause of the ServiceConfigurationError appears to be an InstantiationException

Asutosh Pandya
February 16, 2019, 9:46 PM

Have added corresponding code. Kindly review.

https://github.com/hibernate/hibernate-validator/pull/1016

Fixed

Assignee

Asutosh Pandya

Reporter

Stein Desmet

Labels

Feedback Requested

None

Feedback Requested By

None

backPortable

None

Suitable for new contributors

Yes, likely

backportDecision

None

backportReEvaluate

None

Components

Fix versions

Affects versions

Priority

Minor
Configure