[OpenJDK 2D-Dev] RFR: 8263311: Watch registry changes for remote printers update instead of polling

Alexey Ivanov aivanov at openjdk.java.net
Fri Mar 12 11:32:10 UTC 2021

On Fri, 12 Mar 2021 04:55:45 GMT, Prasanta Sadhukhan <psadhukhan at openjdk.org> wrote:

> Is this only about addition/removal? What about printer name change?

You cannot change the name of a remote printer.

Opening *Printer Properties* dialog from the printer context menu on the local host and editing its name changes the name of the printer on the remote host which shares it. Windows warns, “This is a shared printer. If you rename a shared printer, existing connections to this printer from other computers will break and will have to be created again.”

Nothing has been updated on the local system after renaming the printer. As the warning said, the printer does not work any more because it refers to a printer that does not exist.

To fix this, one has to add a new remote printer which refers to the new name of the printer on the remote host.

> Shouldn't we get notified in that case as trying to print on printer with old name will not find the printer!!

I'm afraid there's nothing Java can do to mitigate renaming the printer.

> If yes, in that regard I guess `REG_NOTIFY_CHANGE_LAST_SET` is the one to go for as it states
> _"Notify the caller of changes to a value of the key. This can include adding or deleting a value, or changing an existing value. "_

Since no values are created, removed, or changed when a remote printer is added or removed under `Connections` key, adding `REG_NOTIFY_CHANGE_LAST_SET` to `dwNotifyFilter` is not required. There are some values stored in the printer key but Java does not use them directly; if any value is changed there, getting notifications about such an event only creates noise.

So, as far as Java is concerned, getting notifications about new keys being created or removed under `Connections` is enough. This is what `REG_NOTIFY_CHANGE_NAME` filter does.


PR: https://git.openjdk.java.net/jdk/pull/2915

More information about the 2d-dev mailing list