Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
AsamK opened this issue Jan 23, 2024 · 1 comment
Closed

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

AsamK opened this issue Jan 23, 2024 · 1 comment

Comments

@AsamK
Copy link
Contributor

AsamK commented Jan 23, 2024

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

@hypfvieh
Copy link
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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants