8263894: Convert defaultPrinter and printers fields to local variables

Reviewed-by: prr, azvegint, kizune
This commit is contained in:
Alexey Ivanov 2021-03-22 15:54:51 +00:00
parent ba504fcee8
commit 840ab7bf0f

View file

@ -43,9 +43,7 @@ import javax.print.attribute.standard.PrinterName;
public class PrintServiceLookupProvider extends PrintServiceLookup {
private String defaultPrinter;
private PrintService defaultPrintService;
private String[] printers; /* excludes the default printer */
private PrintService[] printServices; /* includes the default printer */
static {
@ -114,7 +112,7 @@ public class PrintServiceLookupProvider extends PrintServiceLookup {
}
private synchronized void refreshServices() {
printers = getAllPrinterNames();
String[] printers = getAllPrinterNames();
if (printers == null) {
// In Windows it is safe to assume no default if printers == null so we
// don't get the default.
@ -279,7 +277,7 @@ public class PrintServiceLookupProvider extends PrintServiceLookup {
// Windows does not have notification for a change in default
// so we always get the latest.
defaultPrinter = getDefaultPrinterName();
String defaultPrinter = getDefaultPrinterName();
if (defaultPrinter == null) {
return null;
}