This repository was archived by the owner on Oct 29, 2025. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 1
This repository was archived by the owner on Oct 29, 2025. It is now read-only.
null returned by MessageHandler.send never handled #2
Copy link
Copy link
Closed
Description
This method may return null:
| public Object[] send(String service, String path, String iface, String method, String signature, Object... args) { | |
| try { | |
| org.freedesktop.dbus.messages.Message message = new MethodCall( | |
| service, | |
| path, | |
| iface, | |
| method, (byte) 0, signature, args); | |
| if (log.isTraceEnabled()) log.trace(String.valueOf(message)); | |
| connection.sendMessage(message); | |
| org.freedesktop.dbus.messages.Message response = ((MethodCall) message).getReply(2000L); | |
| if (log.isTraceEnabled()) log.trace(String.valueOf(response)); | |
| Object[] parameters = null; | |
| if (response != null) { | |
| parameters = response.getParameters(); | |
| log.debug(Arrays.deepToString(parameters)); | |
| } | |
| if (response instanceof org.freedesktop.dbus.errors.Error) { | |
| String error = response.getName(); | |
| switch (error) { | |
| case "org.freedesktop.DBus.Error.NoReply": | |
| case "org.freedesktop.DBus.Error.UnknownMethod": | |
| case "org.freedesktop.dbus.exceptions.NotConnected": | |
| log.debug(error); | |
| return null; | |
| default: | |
| throw new DBusException(error); | |
| } | |
| } | |
| return parameters; | |
| } catch (DBusException e) { | |
| log.error("Unexpected D-Bus response:", e); | |
| } | |
| return null; | |
| } |
But responses are always assumed to be non-null, see e.g.:
kdewallet/src/main/java/org/purejava/KDEWallet.java
Lines 110 to 114 in 821e6ce
| @Override | |
| public boolean isOpen(String wallet) { | |
| Object[] response = send("isOpen", "s", wallet); | |
| return (boolean) response[0]; | |
| } |
Which causes downstream uncaught NPEs, as in cryptomator/cryptomator#1866
Metadata
Metadata
Assignees
Labels
No labels