Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
3c23292f
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
4
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_jdk
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
3c23292f
编写于
8月 18, 2019
作者:
A
aivanov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8222108: Reduce minRefreshTime for updating remote printer list on Windows
Reviewed-by: prr, serb
上级
f0d4d2a5
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
48 addition
and
66 deletion
+48
-66
src/windows/classes/sun/print/PrintServiceLookupProvider.java
...windows/classes/sun/print/PrintServiceLookupProvider.java
+37
-59
test/jdk/java/awt/print/RemotePrinterStatusRefresh/RemotePrinterStatusRefresh.java
...emotePrinterStatusRefresh/RemotePrinterStatusRefresh.java
+11
-7
未找到文件。
src/windows/classes/sun/print/PrintServiceLookupProvider.java
浏览文件 @
3c23292f
...
@@ -27,6 +27,8 @@ package sun.print;
...
@@ -27,6 +27,8 @@ package sun.print;
import
java.security.AccessController
;
import
java.security.AccessController
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Comparator
;
import
javax.print.DocFlavor
;
import
javax.print.DocFlavor
;
import
javax.print.MultiDocPrintService
;
import
javax.print.MultiDocPrintService
;
import
javax.print.PrintService
;
import
javax.print.PrintService
;
...
@@ -47,9 +49,11 @@ public class PrintServiceLookupProvider extends PrintServiceLookup {
...
@@ -47,9 +49,11 @@ public class PrintServiceLookupProvider extends PrintServiceLookup {
private
PrintService
defaultPrintService
;
private
PrintService
defaultPrintService
;
private
String
[]
printers
;
/* excludes the default printer */
private
String
[]
printers
;
/* excludes the default printer */
private
PrintService
[]
printServices
;
/* includes the default printer */
private
PrintService
[]
printServices
;
/* includes the default printer */
private
static
boolean
pollServices
=
true
;
private
static
final
int
DEFAULT_MINREFRESH
=
240
;
// 4 minutes
private
static
final
int
DEFAULT_REFRESH_TIME
=
240
;
// 4 minutes
private
static
int
minRefreshTime
=
DEFAULT_MINREFRESH
;
private
static
final
int
MINIMUM_REFRESH_TIME
=
120
;
// 2 minutes
private
static
final
boolean
pollServices
;
private
static
final
int
refreshTime
;
static
{
static
{
/* The system property "sun.java2d.print.polling"
/* The system property "sun.java2d.print.polling"
...
@@ -58,12 +62,7 @@ public class PrintServiceLookupProvider extends PrintServiceLookup {
...
@@ -58,12 +62,7 @@ public class PrintServiceLookupProvider extends PrintServiceLookup {
*/
*/
String
pollStr
=
java
.
security
.
AccessController
.
doPrivileged
(
String
pollStr
=
java
.
security
.
AccessController
.
doPrivileged
(
new
sun
.
security
.
action
.
GetPropertyAction
(
"sun.java2d.print.polling"
));
new
sun
.
security
.
action
.
GetPropertyAction
(
"sun.java2d.print.polling"
));
pollServices
=
!(
"false"
.
equalsIgnoreCase
(
pollStr
));
if
(
pollStr
!=
null
)
{
if
(
pollStr
.
equalsIgnoreCase
(
"false"
))
{
pollServices
=
false
;
}
}
/* The system property "sun.java2d.print.minRefreshTime"
/* The system property "sun.java2d.print.minRefreshTime"
* can be used to specify minimum refresh time (in seconds)
* can be used to specify minimum refresh time (in seconds)
...
@@ -72,17 +71,9 @@ public class PrintServiceLookupProvider extends PrintServiceLookup {
...
@@ -72,17 +71,9 @@ public class PrintServiceLookupProvider extends PrintServiceLookup {
String
refreshTimeStr
=
java
.
security
.
AccessController
.
doPrivileged
(
String
refreshTimeStr
=
java
.
security
.
AccessController
.
doPrivileged
(
new
sun
.
security
.
action
.
GetPropertyAction
(
new
sun
.
security
.
action
.
GetPropertyAction
(
"sun.java2d.print.minRefreshTime"
));
"sun.java2d.print.minRefreshTime"
));
refreshTime
=
(
refreshTimeStr
!=
null
)
if
(
refreshTimeStr
!=
null
)
{
?
getRefreshTime
(
refreshTimeStr
)
try
{
:
DEFAULT_REFRESH_TIME
;
minRefreshTime
=
Integer
.
parseInt
(
refreshTimeStr
);
}
catch
(
NumberFormatException
e
)
{
// ignore
}
if
(
minRefreshTime
<
DEFAULT_MINREFRESH
)
{
minRefreshTime
=
DEFAULT_MINREFRESH
;
}
}
java
.
security
.
AccessController
.
doPrivileged
(
java
.
security
.
AccessController
.
doPrivileged
(
new
java
.
security
.
PrivilegedAction
<
Void
>()
{
new
java
.
security
.
PrivilegedAction
<
Void
>()
{
...
@@ -93,6 +84,17 @@ public class PrintServiceLookupProvider extends PrintServiceLookup {
...
@@ -93,6 +84,17 @@ public class PrintServiceLookupProvider extends PrintServiceLookup {
});
});
}
}
private
static
int
getRefreshTime
(
final
String
refreshTimeStr
)
{
try
{
int
minRefreshTime
=
Integer
.
parseInt
(
refreshTimeStr
);
return
(
minRefreshTime
<
MINIMUM_REFRESH_TIME
)
?
MINIMUM_REFRESH_TIME
:
minRefreshTime
;
}
catch
(
NumberFormatException
e
)
{
return
DEFAULT_REFRESH_TIME
;
}
}
/* The singleton win32 print lookup service.
/* The singleton win32 print lookup service.
* Code that is aware of this field and wants to use it must first
* Code that is aware of this field and wants to use it must first
* see if its null, and if so instantiate it by calling a method such as
* see if its null, and if so instantiate it by calling a method such as
...
@@ -394,61 +396,37 @@ public class PrintServiceLookupProvider extends PrintServiceLookup {
...
@@ -394,61 +396,37 @@ public class PrintServiceLookupProvider extends PrintServiceLookup {
count of printer status changes(add\remove) and based on it update the printers
count of printer status changes(add\remove) and based on it update the printers
list.
list.
*/
*/
class
RemotePrinterChangeListener
extends
Thread
{
class
RemotePrinterChangeListener
extends
Thread
implements
Comparator
<
String
>{
private
String
[]
prevRemotePrinters
;
RemotePrinterChangeListener
()
{
RemotePrinterChangeListener
()
{
prevRemotePrinters
=
getRemotePrintersNames
();
}
}
private
boolean
doCompare
(
String
[]
str1
,
String
[]
str2
)
{
@Override
if
(
str1
==
null
&&
str2
==
null
)
{
public
int
compare
(
String
o1
,
String
o2
)
{
return
false
;
return
((
o1
==
null
)
}
else
if
(
str1
==
null
||
str2
==
null
)
{
?
((
o2
==
null
)
?
0
:
1
)
return
true
;
:
((
o2
==
null
)
?
-
1
:
o1
.
compareTo
(
o2
)));
}
if
(
str1
.
length
!=
str2
.
length
)
{
return
true
;
}
else
{
for
(
int
i
=
0
;
i
<
str1
.
length
;
i
++)
{
for
(
int
j
=
0
;
j
<
str2
.
length
;
j
++)
{
// skip if both are nulls
if
(
str1
[
i
]
==
null
&&
str2
[
j
]
==
null
)
{
continue
;
}
// return true if there is a 'difference' but
// no need to access the individual string
if
(
str1
[
i
]
==
null
||
str2
[
j
]
==
null
)
{
return
true
;
}
// do comparison only if they are non-nulls
if
(!
str1
[
i
].
equals
(
str2
[
j
]))
{
return
true
;
}
}
}
}
return
false
;
}
}
@Override
@Override
public
void
run
()
{
public
void
run
()
{
// Init the list of remote printers
// Init the list of remote printers
prevRemotePrinters
=
getRemotePrintersNames
();
String
[]
prevRemotePrinters
=
getRemotePrintersNames
();
if
(
prevRemotePrinters
!=
null
)
{
Arrays
.
sort
(
prevRemotePrinters
,
this
);
}
while
(
true
)
{
while
(
true
)
{
try
{
try
{
Thread
.
sleep
(
minR
efreshTime
*
1000
);
Thread
.
sleep
(
r
efreshTime
*
1000
);
}
catch
(
InterruptedException
e
)
{
}
catch
(
InterruptedException
e
)
{
break
;
break
;
}
}
String
[]
currentRemotePrinters
=
getRemotePrintersNames
();
String
[]
currentRemotePrinters
=
getRemotePrintersNames
();
if
(
doCompare
(
prevRemotePrinters
,
currentRemotePrinters
))
{
if
(
currentRemotePrinters
!=
null
)
{
Arrays
.
sort
(
currentRemotePrinters
,
this
);
}
if
(!
Arrays
.
equals
(
prevRemotePrinters
,
currentRemotePrinters
))
{
// The list of remote printers got updated,
// The list of remote printers got updated,
// so update the cached list printers which
// so update the cached list printers which
// includes both local and network printers
// includes both local and network printers
...
...
test/jdk/java/awt/print/RemotePrinterStatusRefresh/RemotePrinterStatusRefresh.java
浏览文件 @
3c23292f
...
@@ -23,10 +23,10 @@
...
@@ -23,10 +23,10 @@
/*
/*
* @test
* @test
* @bug 8153732 8212202 8221263 8221412
* @bug 8153732 8212202 8221263 8221412
8222108
* @requires (os.family == "Windows")
* @requires (os.family == "Windows")
* @summary Windows remote printer changes do not reflect in lookupPrintServices()
* @summary Windows remote printer changes do not reflect in lookupPrintServices()
* @run main/manual RemotePrinterStatusRefresh
* @run main/manual
/othervm -Dsun.java2d.print.minRefreshTime=120
RemotePrinterStatusRefresh
*/
*/
import
java.awt.BorderLayout
;
import
java.awt.BorderLayout
;
...
@@ -63,6 +63,9 @@ import static javax.swing.BorderFactory.createTitledBorder;
...
@@ -63,6 +63,9 @@ import static javax.swing.BorderFactory.createTitledBorder;
public
class
RemotePrinterStatusRefresh
extends
WindowAdapter
{
public
class
RemotePrinterStatusRefresh
extends
WindowAdapter
{
private
static
final
long
DEFAULT_REFRESH_TIME
=
240L
;
private
static
final
long
MINIMAL_REFRESH_TIME
=
120L
;
private
static
final
long
refreshTime
=
getRefreshTime
();
private
static
final
long
refreshTime
=
getRefreshTime
();
private
static
final
long
TIMEOUT
=
refreshTime
*
4
+
60
;
private
static
final
long
TIMEOUT
=
refreshTime
*
4
+
60
;
...
@@ -181,7 +184,7 @@ public class RemotePrinterStatusRefresh extends WindowAdapter {
...
@@ -181,7 +184,7 @@ public class RemotePrinterStatusRefresh extends WindowAdapter {
+
"configured printers.\n"
+
"configured printers.\n"
+
"Step 1: Add or Remove a network printer using "
+
"Step 1: Add or Remove a network printer using "
+
"Windows Control Panel.\n"
+
"Windows Control Panel.\n"
+
"Step 2: Wait for 4 minutes after adding or removing.\n"
+
"Step 2: Wait for
2\u2013
4 minutes after adding or removing.\n"
+
" \"Next printer refresh in\" gives you a "
+
" \"Next printer refresh in\" gives you a "
+
"rough estimation on when update will happen.\n"
+
"rough estimation on when update will happen.\n"
+
"Step 3: Click Refresh."
+
"Step 3: Click Refresh."
...
@@ -195,7 +198,7 @@ public class RemotePrinterStatusRefresh extends WindowAdapter {
...
@@ -195,7 +198,7 @@ public class RemotePrinterStatusRefresh extends WindowAdapter {
+
"Step 5: Click Pass if the list of printers is correctly "
+
"Step 5: Click Pass if the list of printers is correctly "
+
"updated.\n"
+
"updated.\n"
+
"Step 6: If the list is not updated, wait for another "
+
"Step 6: If the list is not updated, wait for another "
+
"4 minutes, and then click Refresh again.\n"
+
"
2\u2013
4 minutes, and then click Refresh again.\n"
+
"Step 7: If the list does not update, click Fail.\n"
+
"Step 7: If the list does not update, click Fail.\n"
+
"\n"
+
"\n"
+
"You have to click Refresh to enable Pass and Fail buttons. "
+
"You have to click Refresh to enable Pass and Fail buttons. "
...
@@ -215,12 +218,13 @@ public class RemotePrinterStatusRefresh extends WindowAdapter {
...
@@ -215,12 +218,13 @@ public class RemotePrinterStatusRefresh extends WindowAdapter {
private
static
long
getRefreshTime
()
{
private
static
long
getRefreshTime
()
{
String
refreshTime
=
String
refreshTime
=
System
.
getProperty
(
"sun.java2d.print.minRefreshTime"
,
"240"
);
System
.
getProperty
(
"sun.java2d.print.minRefreshTime"
,
Long
.
toString
(
DEFAULT_REFRESH_TIME
));
try
{
try
{
long
value
=
Long
.
parseLong
(
refreshTime
);
long
value
=
Long
.
parseLong
(
refreshTime
);
return
value
<
240L
?
240L
:
value
;
return
value
<
MINIMAL_REFRESH_TIME
?
MINIMAL_REFRESH_TIME
:
value
;
}
catch
(
NumberFormatException
e
)
{
}
catch
(
NumberFormatException
e
)
{
return
240L
;
return
DEFAULT_REFRESH_TIME
;
}
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录