From 24d086c3cabf8080fde230c9a193bed483db3f4b Mon Sep 17 00:00:00 2001 From: Kim van der Riet Date: Mon, 4 Dec 2006 14:48:13 +0000 Subject: Added check for non-existent domains - throws Exception instead of NPE. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@482194 13f79535-47bb-0310-9956-ffa450edef68 --- gentools/src/org/apache/qpid/gentools/CppGenerator.java | 9 ++++++++- gentools/src/org/apache/qpid/gentools/JavaGenerator.java | 14 +++++++++----- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/gentools/src/org/apache/qpid/gentools/CppGenerator.java b/gentools/src/org/apache/qpid/gentools/CppGenerator.java index 26a9950d8a..cf97e01877 100644 --- a/gentools/src/org/apache/qpid/gentools/CppGenerator.java +++ b/gentools/src/org/apache/qpid/gentools/CppGenerator.java @@ -176,9 +176,16 @@ public class CppGenerator extends Generator { String domainType = getDomainType(domainName, version); if (domainType == null) + { throw new AmqpTypeMappingException("Domain type \"" + domainName + "\" not found in C++ typemap."); - return typeMap.get(domainType).type; + } + DomainInfo info = typeMap.get(domainType); + if (info == null) + { + throw new AmqpTypeMappingException("Unknown domain: \"" + domainType + "\""); + } + return info.type; } // === Abstract methods from class Generator - C++-specific implementation === diff --git a/gentools/src/org/apache/qpid/gentools/JavaGenerator.java b/gentools/src/org/apache/qpid/gentools/JavaGenerator.java index bd83e85090..c465677bff 100644 --- a/gentools/src/org/apache/qpid/gentools/JavaGenerator.java +++ b/gentools/src/org/apache/qpid/gentools/JavaGenerator.java @@ -355,11 +355,15 @@ public class JavaGenerator extends Generator { String domainType = globalDomainMap.getDomainType(domainName, version); if (domainType == null) - throw new AmqpTypeMappingException("Domain type \"" + domainName + "\" not found in Java typemap."); - DomainInfo info = typeMap.get(domainType); - if (info == null) { - throw new AmqpTypeMappingException("Unknown type: \"" + domainType + "\""); - } + { + throw new AmqpTypeMappingException("Domain type \"" + domainName + + "\" not found in Java typemap."); + } + DomainInfo info = typeMap.get(domainType); + if (info == null) + { + throw new AmqpTypeMappingException("Unknown domain: \"" + domainType + "\""); + } return info.type; } -- cgit v1.2.1