From daae61a6f50a98dddaf649d919d2a46e55567802 Mon Sep 17 00:00:00 2001 From: Donald Woods Date: Thu, 25 Feb 2010 16:28:54 +0000 Subject: [PATCH] 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 --- .../apache/openjpa/meta/MetaDataRepository.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/openjpa-kernel/src/main/java/org/apache/openjpa/meta/MetaDataRepository.java b/openjpa-kernel/src/main/java/org/apache/openjpa/meta/MetaDataRepository.java index ab63ae718..9260d6ae7 100644 --- a/openjpa-kernel/src/main/java/org/apache/openjpa/meta/MetaDataRepository.java +++ b/openjpa-kernel/src/main/java/org/apache/openjpa/meta/MetaDataRepository.java @@ -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 - .toArray(new Exception[_errs.size()])); + } else { + re = new MetaDataException(_loc.get("resolve-errs")) + .setNestedThrowables((Throwable[]) _errs + .toArray(new Exception[_errs.size()])); + } _errs.clear(); throw re; }