Skip to content

Commit a13ab2c

Browse files
committed
Issue #163: Handle objects in 'appendOne' method when creating return values for list of objects
1 parent e7df495 commit a13ab2c

File tree

1 file changed

+13
-4
lines changed
  • dbus-java-core/src/main/java/org/freedesktop/dbus/messages

1 file changed

+13
-4
lines changed

dbus-java-core/src/main/java/org/freedesktop/dbus/messages/Message.java

+13-4
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import org.freedesktop.dbus.exceptions.DBusException;
2121
import org.freedesktop.dbus.exceptions.MarshallingException;
2222
import org.freedesktop.dbus.exceptions.UnknownTypeCodeException;
23+
import org.freedesktop.dbus.interfaces.DBusInterface;
2324
import org.freedesktop.dbus.types.UInt16;
2425
import org.freedesktop.dbus.types.UInt32;
2526
import org.freedesktop.dbus.types.UInt64;
@@ -530,9 +531,17 @@ private int appendOne(byte[] _sigb, int _sigofs, Object _data) throws DBusExcept
530531
break;
531532
case ArgumentType.STRING:
532533
case ArgumentType.OBJECT_PATH:
533-
// Strings are marshalled as a UInt32 with the length,
534-
// followed by the String, followed by a null byte.
535-
String payload = _data.toString();
534+
535+
String payload;
536+
// if the given data is an object, not a ObjectPath itself
537+
if (_data instanceof DBusInterface) {
538+
payload = ((DBusInterface) _data).getObjectPath();
539+
} else {
540+
// Strings are marshalled as a UInt32 with the length,
541+
// followed by the String, followed by a null byte.
542+
payload = _data.toString();
543+
}
544+
536545
byte[] payloadbytes = null;
537546
try {
538547
payloadbytes = payload.getBytes("UTF-8");
@@ -1421,4 +1430,4 @@ public interface Endian {
14211430
byte BIG = 'B';
14221431
byte LITTLE = 'l';
14231432
}
1424-
}
1433+
}

0 commit comments

Comments
 (0)