From f4a2c9836d39391fa4d98e22f6d9d33f5abf3a7b Mon Sep 17 00:00:00 2001 From: bernd Date: Wed, 25 Jul 2012 23:43:40 +0200 Subject: [PATCH 17/22] 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 file changed, 8 insertions(+) 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.9.5