[mapdb] Avoid ArrayIndexOutOfBoundsExceptions being thrown (#8792)

Signed-off-by: Kai Kreuzer <kai@openhab.org>
This commit is contained in:
Kai Kreuzer 2020-10-18 20:03:55 +02:00 committed by GitHub
parent 42d1c26912
commit 5cca30492b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -43,11 +43,12 @@ public class StateTypeAdapter extends TypeAdapter<State> {
return null;
}
String value = reader.nextString();
String[] parts = value.split(TYPE_SEPARATOR);
String valueTypeName = parts[0];
String valueAsString = parts[1];
try {
String[] parts = value.split(TYPE_SEPARATOR);
String valueTypeName = parts[0];
String valueAsString = parts[1];
@SuppressWarnings("unchecked")
Class<? extends State> valueType = (Class<? extends State>) Class.forName(valueTypeName);
List<Class<? extends State>> types = Collections.singletonList(valueType);