OPENJPA-1535 Inconsistency in exceptions thrown from MetaDataRepository.resolve(). Patch contributed by Hiroki Tateno.

git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@916338 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Donald Woods 2010-02-25 16:28:54 +00:00
parent ea49b4cc6a
commit daae61a6f5
1 changed files with 9 additions and 5 deletions

View File

@ -631,14 +631,18 @@ public class MetaDataRepository implements PCRegistry.RegisterClassListener, Con
err &= resolveMapping(resolved.get(i));
// throw errors encountered
// OPENJPA-1535 Always throw a MetaDataException because callers
// of loadRegisteredClassMetaData expect only MetaDataException
// to be thrown.
if (err && !_errs.isEmpty()) {
RuntimeException re;
if (_errs.size() == 1)
if ((_errs.size() == 1) && (_errs.get(0) instanceof MetaDataException)) {
re = _errs.get(0);
else
re =
new MetaDataException(_loc.get("resolve-errs")).setNestedThrowables((Throwable[]) _errs
} else {
re = new MetaDataException(_loc.get("resolve-errs"))
.setNestedThrowables((Throwable[]) _errs
.toArray(new Exception[_errs.size()]));
}
_errs.clear();
throw re;
}