From cae586057c188e1fa90048b6b5ae70936c611997 Mon Sep 17 00:00:00 2001 From: bernd Date: Mon, 1 Aug 2011 14:09:15 +0200 Subject: [PATCH 09/12] Guard MapDataObjectBinding against setting a bad object type (can happen by providing MapDataObjectBinding as a custom resultSetBinding when it does not match the actual return type) --- .../eodsql/spi/util/MapDataObjectBinding.java | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-) diff --git a/eodsql/src/net/lemnik/eodsql/spi/util/MapDataObjectBinding.java b/eodsql/src/net/lemnik/eodsql/spi/util/MapDataObjectBinding.java index 723ebf0..6883c84 100644 --- a/eodsql/src/net/lemnik/eodsql/spi/util/MapDataObjectBinding.java +++ b/eodsql/src/net/lemnik/eodsql/spi/util/MapDataObjectBinding.java @@ -14,6 +14,7 @@ import java.util.HashMap; import java.util.Map; import net.lemnik.eodsql.EoDException; +import net.lemnik.eodsql.InvalidDataTypeException; /** * A {@link DataObjectBinding} that stores the {@link ResultSet} in a @@ -23,6 +24,13 @@ import net.lemnik.eodsql.EoDException; */ public class MapDataObjectBinding extends DataObjectBinding> { @Override + protected void setObjectType(Class> objectType) { + if (Map.class.isAssignableFrom(objectType) == false) { + throw new InvalidDataTypeException(objectType); + } + } + + @Override public Class> getObjectType() { return getStringObjectMapObjectType(); } -- 1.7.6