From cb77cfc872eefbfb9a08109be1942c8339220a89 Mon Sep 17 00:00:00 2001 From: David M Date: Fri, 17 May 2024 21:42:20 +0200 Subject: [PATCH] Issue #258: Handle Collection and Map types when converting annotated properties for GetAll method call --- .../dbus/connections/base/DBusBoundPropertyHandler.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/dbus-java-core/src/main/java/org/freedesktop/dbus/connections/base/DBusBoundPropertyHandler.java b/dbus-java-core/src/main/java/org/freedesktop/dbus/connections/base/DBusBoundPropertyHandler.java index 4d3665ab..90c188a9 100644 --- a/dbus-java-core/src/main/java/org/freedesktop/dbus/connections/base/DBusBoundPropertyHandler.java +++ b/dbus-java-core/src/main/java/org/freedesktop/dbus/connections/base/DBusBoundPropertyHandler.java @@ -122,6 +122,13 @@ protected PropHandled handleGetAll(ExportedObject _exportObject, final MethodCal try { _methodCall.setArgs(new Object[0]); Object val = invokeMethod(_methodCall, propMeth, object); + + // when the value is a collection or map, wrap them in a proper variant type + if (Collection.class.isInstance(val) || (Map.class.isInstance(val))) { + String[] dataType = Marshalling.getDBusType(propEn.getValue().getGenericReturnType()); + val = new Variant<>(val, String.join("", dataType)); + } + resultMap.put(propEn.getKey().getName(), val); } catch (Throwable _ex) { getLogger().debug("Error executing method {} on method call {}", propMeth, _methodCall, _ex);