Skip to content

Sending signal with byte[] fails with verbose logging  #247

Closed

Description

@AsamK

I have a signal defined, that contains a field with type byte[].

class Signal extends DBusSignal {

        private final byte[] groupId;

        public Signal(
                String objectpath,
                byte[] groupId
        ) throws DBusException {
            super(objectpath, groupId);
            this.groupId = groupId;
        }
}

Sending this connection.sendMessage(new Signal(...)) works fine, with normal log level.
But when I set the log level to verbose, the sending fails.

The error seems to be in the code in LoggingHelper that tries to to serialize the the object to a string.
It fails to cast a byte array (byte[], [B) to an object array (Object[], [Ljava.lang.Object;), which doesn't work. Primitive arrays can't be cast to an object array.

Error:

java.lang.ClassCastException: class [B cannot be cast to class [Ljava.lang.Object; ([B and [Ljava.lang.Object; are in module java.base of loader 'bootstrap')
        at org.freedesktop.dbus.utils.LoggingHelper.arraysVeryDeepStringRecursive(LoggingHelper.java:56)
        at org.freedesktop.dbus.utils.LoggingHelper.arraysVeryDeepString(LoggingHelper.java:34)
        at org.freedesktop.dbus.messages.Message.lambda$append$3(Message.java:882)
        at org.freedesktop.dbus.utils.LoggingHelper.logIf(LoggingHelper.java:76)
        at org.freedesktop.dbus.messages.Message.append(Message.java:882)
        at org.freedesktop.dbus.messages.DBusSignal.appendbody(DBusSignal.java:277)
        at org.freedesktop.dbus.connections.AbstractConnection.sendMessageInternally(AbstractConnection.java:1087)
        at org.freedesktop.dbus.connections.AbstractConnection$1.run(AbstractConnection.java:406)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
        at java.base/java.lang.Thread.run(Thread.java:1583)

Version: 4.3.1

Activity

  1. added 2 commits that reference this issue on Jan 24, 2024
  2. hypfvieh commented on Jan 24, 2024

    @hypfvieh
    Owner

    Will be fixed in 5.x and 4.3.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions