[OpenJDK 2D-Dev] RFR: 8263984: Invalidate printServices when there are no printers

Alexey Ivanov aivanov at openjdk.java.net
Tue Mar 23 14:02:41 UTC 2021


On Tue, 23 Mar 2021 13:45:33 GMT, Alexey Ivanov <aivanov at openjdk.org> wrote:

> When `getAllPrinterNames()` returns null, the list of `printServices` is assigned a new empty array without invalidating old services which were in the array before.
> 
> The old print services should be invalidated.

src/java.desktop/windows/classes/sun/print/PrintServiceLookupProvider.java line 119:

> 117:             // In Windows it is safe to assume no default if printers == null so we
> 118:             // don't get the default.
> 119:             invalidateServices();

The default printer service, `defaultPrintService`, is usually in `printServices` array. It's possible that it's not in the array; in this case getDefaultPrintService() will reset it to `null` when accessed.

-------------

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


More information about the 2d-dev mailing list