Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
84da54be
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看板
提交
84da54be
编写于
3月 03, 2011
作者:
M
michaelm
浏览文件
操作
浏览文件
下载
差异文件
Merge
上级
8c06d5c5
c4c1f9d8
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
247 addition
and
38 deletion
+247
-38
src/share/classes/com/sun/jndi/ldap/Connection.java
src/share/classes/com/sun/jndi/ldap/Connection.java
+11
-5
src/share/classes/com/sun/jndi/ldap/LdapClient.java
src/share/classes/com/sun/jndi/ldap/LdapClient.java
+5
-3
src/share/classes/com/sun/jndi/ldap/LdapCtx.java
src/share/classes/com/sun/jndi/ldap/LdapCtx.java
+60
-5
src/share/classes/com/sun/jndi/ldap/LdapRequest.java
src/share/classes/com/sun/jndi/ldap/LdapRequest.java
+37
-12
src/share/classes/java/net/URI.java
src/share/classes/java/net/URI.java
+4
-4
src/share/classes/java/net/package.html
src/share/classes/java/net/package.html
+4
-4
test/com/sun/jndi/ldap/NoWaitForReplyTest.java
test/com/sun/jndi/ldap/NoWaitForReplyTest.java
+118
-0
test/java/lang/Thread/StartOOMTest.java
test/java/lang/Thread/StartOOMTest.java
+8
-5
未找到文件。
src/share/classes/com/sun/jndi/ldap/Connection.java
浏览文件 @
84da54be
/*
* Copyright (c) 1999, 201
0
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 201
1
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
...
...
@@ -380,13 +380,19 @@ public final class Connection implements Runnable {
}
LdapRequest
writeRequest
(
BerEncoder
ber
,
int
msgId
)
throws
IOException
{
return
writeRequest
(
ber
,
msgId
,
false
/* pauseAfterReceipt */
);
return
writeRequest
(
ber
,
msgId
,
false
/* pauseAfterReceipt */
,
-
1
);
}
LdapRequest
writeRequest
(
BerEncoder
ber
,
int
msgId
,
boolean
pauseAfterReceipt
)
throws
IOException
{
LdapRequest
writeRequest
(
BerEncoder
ber
,
int
msgId
,
boolean
pauseAfterReceipt
)
throws
IOException
{
return
writeRequest
(
ber
,
msgId
,
pauseAfterReceipt
,
-
1
);
}
LdapRequest
writeRequest
(
BerEncoder
ber
,
int
msgId
,
boolean
pauseAfterReceipt
,
int
replyQueueCapacity
)
throws
IOException
{
LdapRequest
req
=
new
LdapRequest
(
msgId
,
pauseAfterReceipt
);
LdapRequest
req
=
new
LdapRequest
(
msgId
,
pauseAfterReceipt
,
replyQueueCapacity
);
addRequest
(
req
);
if
(
traceFile
!=
null
)
{
...
...
src/share/classes/com/sun/jndi/ldap/LdapClient.java
浏览文件 @
84da54be
/*
* Copyright (c) 1999, 20
05
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 20
11
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
...
...
@@ -516,7 +516,8 @@ public final class LdapClient implements PooledConnection {
LdapResult
search
(
String
dn
,
int
scope
,
int
deref
,
int
sizeLimit
,
int
timeLimit
,
boolean
attrsOnly
,
String
attrs
[],
String
filter
,
int
batchSize
,
Control
[]
reqCtls
,
Hashtable
binaryAttrs
,
boolean
waitFirstReply
)
Hashtable
binaryAttrs
,
boolean
waitFirstReply
,
int
replyQueueCapacity
)
throws
IOException
,
NamingException
{
ensureOpen
();
...
...
@@ -543,7 +544,8 @@ public final class LdapClient implements PooledConnection {
if
(
isLdapv3
)
encodeControls
(
ber
,
reqCtls
);
ber
.
endSeq
();
LdapRequest
req
=
conn
.
writeRequest
(
ber
,
curMsgId
);
LdapRequest
req
=
conn
.
writeRequest
(
ber
,
curMsgId
,
false
,
replyQueueCapacity
);
res
.
msgId
=
curMsgId
;
res
.
status
=
LdapClient
.
LDAP_SUCCESS
;
//optimistic
...
...
src/share/classes/com/sun/jndi/ldap/LdapCtx.java
浏览文件 @
84da54be
/*
* Copyright (c) 1999, 20
05
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 20
11
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
...
...
@@ -191,6 +191,14 @@ final public class LdapCtx extends ComponentDirContext
// Environment property for the domain name (derived from this context's DN)
private
static
final
String
DOMAIN_NAME
=
"com.sun.jndi.ldap.domainname"
;
// Block until the first search reply is received
private
static
final
String
WAIT_FOR_REPLY
=
"com.sun.jndi.ldap.search.waitForReply"
;
// Size of the queue of unprocessed search replies
private
static
final
String
REPLY_QUEUE_SIZE
=
"com.sun.jndi.ldap.search.replyQueueSize"
;
// ----------------- Fields that don't change -----------------------
private
static
final
NameParser
parser
=
new
LdapNameParser
();
...
...
@@ -246,6 +254,8 @@ final public class LdapCtx extends ComponentDirContext
private
Hashtable
binaryAttrs
=
null
;
// attr values returned as byte[]
private
int
connectTimeout
=
-
1
;
// no timeout value
private
int
readTimeout
=
-
1
;
// no timeout value
private
boolean
waitForReply
=
true
;
// wait for search response
private
int
replyQueueSize
=
-
1
;
// unlimited queue size
private
boolean
useSsl
=
false
;
// true if SSL protocol is active
private
boolean
useDefaultPortNumber
=
false
;
// no port number was supplied
...
...
@@ -1759,8 +1769,8 @@ final public class LdapCtx extends ComponentDirContext
SearchControls
cons
,
Continuation
cont
)
throws
NamingException
{
return
searchAux
(
name
,
filter
,
cloneSearchControls
(
cons
),
true
,
true
,
cont
);
return
searchAux
(
name
,
filter
,
cloneSearchControls
(
cons
),
true
,
waitForReply
,
cont
);
}
protected
NamingEnumeration
c_search
(
Name
name
,
...
...
@@ -1928,7 +1938,7 @@ final public class LdapCtx extends ComponentDirContext
}
private
LdapResult
doSearch
(
Name
name
,
String
filter
,
SearchControls
cons
,
boolean
relative
,
boolean
waitF
irst
Reply
)
throws
NamingException
{
boolean
relative
,
boolean
waitF
or
Reply
)
throws
NamingException
{
ensureOpen
();
try
{
int
scope
;
...
...
@@ -1984,7 +1994,8 @@ final public class LdapCtx extends ComponentDirContext
batchSize
,
reqCtls
,
binaryAttrs
,
waitFirstReply
);
waitForReply
,
replyQueueSize
);
respCtls
=
answer
.
resControls
;
// retrieve response controls
return
answer
;
...
...
@@ -2170,6 +2181,10 @@ final public class LdapCtx extends ComponentDirContext
connectTimeout
=
-
1
;
}
else
if
(
propName
.
equals
(
READ_TIMEOUT
))
{
readTimeout
=
-
1
;
}
else
if
(
propName
.
equals
(
WAIT_FOR_REPLY
))
{
waitForReply
=
true
;
}
else
if
(
propName
.
equals
(
REPLY_QUEUE_SIZE
))
{
replyQueueSize
=
-
1
;
// The following properties affect the connection
...
...
@@ -2225,6 +2240,11 @@ final public class LdapCtx extends ComponentDirContext
setConnectTimeout
((
String
)
propVal
);
}
else
if
(
propName
.
equals
(
READ_TIMEOUT
))
{
setReadTimeout
((
String
)
propVal
);
}
else
if
(
propName
.
equals
(
WAIT_FOR_REPLY
))
{
setWaitForReply
((
String
)
propVal
);
}
else
if
(
propName
.
equals
(
REPLY_QUEUE_SIZE
))
{
setReplyQueueSize
((
String
)
propVal
);
// The following properties affect the connection
}
else
if
(
propName
.
equals
(
Context
.
SECURITY_PROTOCOL
))
{
...
...
@@ -2312,6 +2332,13 @@ final public class LdapCtx extends ComponentDirContext
// Set the read timeout
setReadTimeout
((
String
)
envprops
.
get
(
READ_TIMEOUT
));
// Set the flag that controls whether to block until the first reply
// is received
setWaitForReply
((
String
)
envprops
.
get
(
WAIT_FOR_REPLY
));
// Set the size of the queue of unprocessed search replies
setReplyQueueSize
((
String
)
envprops
.
get
(
REPLY_QUEUE_SIZE
));
// When connection is created, it will use these and other
// properties from the environment
}
...
...
@@ -2441,6 +2468,34 @@ final public class LdapCtx extends ComponentDirContext
}
}
/**
* Sets the size of the queue of unprocessed search replies
*/
private
void
setReplyQueueSize
(
String
replyQueueSizeProp
)
{
if
(
replyQueueSizeProp
!=
null
)
{
replyQueueSize
=
Integer
.
parseInt
(
replyQueueSizeProp
);
// disallow an empty queue
if
(
replyQueueSize
<=
0
)
{
replyQueueSize
=
-
1
;
// unlimited
}
}
else
{
replyQueueSize
=
-
1
;
// unlimited
}
}
/**
* Sets the flag that controls whether to block until the first search
* reply is received
*/
private
void
setWaitForReply
(
String
waitForReplyProp
)
{
if
(
waitForReplyProp
!=
null
&&
(
waitForReplyProp
.
equalsIgnoreCase
(
"false"
)))
{
waitForReply
=
false
;
}
else
{
waitForReply
=
true
;
}
}
/**
* Sets the read timeout value
*/
...
...
src/share/classes/com/sun/jndi/ldap/LdapRequest.java
浏览文件 @
84da54be
/*
* Copyright (c) 1999, 20
02
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 20
11
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
...
...
@@ -26,7 +26,8 @@
package
com.sun.jndi.ldap
;
import
java.io.IOException
;
import
java.util.Vector
;
import
java.util.concurrent.BlockingQueue
;
import
java.util.concurrent.LinkedBlockingQueue
;
import
javax.naming.CommunicationException
;
final
class
LdapRequest
{
...
...
@@ -35,14 +36,26 @@ final class LdapRequest {
int
msgId
;
// read-only
private
int
gotten
=
0
;
private
Vector
replies
=
new
Vector
(
3
);
private
BlockingQueue
<
BerDecoder
>
replies
;
private
int
highWatermark
=
-
1
;
private
boolean
cancelled
=
false
;
private
boolean
pauseAfterReceipt
=
false
;
private
boolean
completed
=
false
;
LdapRequest
(
int
msgId
,
boolean
pause
)
{
this
(
msgId
,
pause
,
-
1
);
}
LdapRequest
(
int
msgId
,
boolean
pause
,
int
replyQueueCapacity
)
{
this
.
msgId
=
msgId
;
this
.
pauseAfterReceipt
=
pause
;
if
(
replyQueueCapacity
==
-
1
)
{
this
.
replies
=
new
LinkedBlockingQueue
<
BerDecoder
>();
}
else
{
this
.
replies
=
new
LinkedBlockingQueue
<
BerDecoder
>(
replyQueueCapacity
);
highWatermark
=
(
replyQueueCapacity
*
80
)
/
100
;
// 80% capacity
}
}
synchronized
void
cancel
()
{
...
...
@@ -57,7 +70,13 @@ final class LdapRequest {
if
(
cancelled
)
{
return
false
;
}
replies
.
addElement
(
ber
);
// Add a new reply to the queue of unprocessed replies.
try
{
replies
.
put
(
ber
);
}
catch
(
InterruptedException
e
)
{
// ignore
}
// peek at the BER buffer to check if it is a SearchResultDone PDU
try
{
...
...
@@ -70,6 +89,14 @@ final class LdapRequest {
ber
.
reset
();
notify
();
// notify anyone waiting for reply
/*
* If a queue capacity has been set then trigger a pause when the
* queue has filled to 80% capacity. Later, when the queue has drained
* then the reader gets unpaused.
*/
if
(
highWatermark
!=
-
1
&&
replies
.
size
()
>=
highWatermark
)
{
return
true
;
// trigger the pause
}
return
pauseAfterReceipt
;
}
...
...
@@ -79,14 +106,12 @@ final class LdapRequest {
" cancelled"
);
}
if
(
gotten
<
replies
.
size
())
{
BerDecoder
answer
=
(
BerDecoder
)
replies
.
elementAt
(
gotten
);
replies
.
setElementAt
(
null
,
gotten
);
// remove reference
++
gotten
;
// skip to next
return
answer
;
}
else
{
return
null
;
}
/*
* Remove a reply if the queue is not empty.
* poll returns null if queue is empty.
*/
BerDecoder
reply
=
replies
.
poll
();
return
reply
;
}
synchronized
boolean
hasSearchCompleted
()
{
...
...
src/share/classes/java/net/URI.java
浏览文件 @
84da54be
...
...
@@ -991,7 +991,7 @@ public final class URI
* authority and path are taken from the given URI. </p></li>
*
* <li><p> Otherwise the new URI's authority component is copied from
* this URI, and its path is computed as follows: </p>
</li>
* this URI, and its path is computed as follows: </p>
*
* <ol type=a>
*
...
...
@@ -1005,7 +1005,7 @@ public final class URI
* path and then normalizing the result as if by invoking the {@link
* #normalize() normalize} method. </p></li>
*
* </ol>
* </ol>
</li>
*
* </ol>
*
...
...
@@ -1511,7 +1511,7 @@ public final class URI
* fragments. </p></li>
*
* <li><p> Two hierarchical URIs with identical schemes are ordered
* according to the ordering of their authority components: </p>
</li>
* according to the ordering of their authority components: </p>
*
* <ul type=disc>
*
...
...
@@ -1526,7 +1526,7 @@ public final class URI
* the URIs are ordered according to the ordering of their authority
* components. </p></li>
*
* </ul>
* </ul>
</li>
*
* <li><p> Finally, two hierarchical URIs with identical schemes and
* authority components are ordered according to the ordering of their
...
...
src/share/classes/java/net/package.html
浏览文件 @
84da54be
...
...
@@ -31,18 +31,18 @@ Provides the classes for implementing networking applications.
<p>
The java.net package can be roughly divided in two sections:
</p>
<ul>
<li>
<p><i>
A Low Level API
</i>
, which deals with the following abstractions:
</p>
</li>
<li>
<p><i>
A Low Level API
</i>
, which deals with the following abstractions:
</p>
<ul>
<li><p><i>
Addresses
</i>
, which are networking identifiers, like IP addresses.
</p></li>
<li><p><i>
Sockets
</i>
, which are basic bidirectional data communication mechanisms.
</p></li>
<li><p><i>
Interfaces
</i>
, which describe network interfaces.
</p></li>
</ul>
<li>
<p><i>
A High Level API
</i>
, which deals with the following abstractions:
</p>
</li>
</ul>
</li>
<li>
<p><i>
A High Level API
</i>
, which deals with the following abstractions:
</p>
<ul>
<li><p><i>
URIs
</i>
, which represent Universal Resource Identifiers.
</p></li>
<li><p><i>
URLs
</i>
, which represent Universal Resource Locators.
</p></li>
<li><p><i>
Connections
</i>
, which represents connections to the resource pointed to by
<i>
URLs
</i>
.
</p></li>
</ul>
</ul>
</li>
</ul>
<h2>
Addresses
</h2>
<p>
Addresses are used throughout the java.net APIs as either host identifiers, or socket endpoint identifiers.
</p>
...
...
test/com/sun/jndi/ldap/NoWaitForReplyTest.java
0 → 100644
浏览文件 @
84da54be
/*
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* @test
* @bug 6748156
* @summary add an new JNDI property to control the boolean flag WaitForReply
*/
import
java.net.Socket
;
import
java.net.ServerSocket
;
import
java.io.*
;
import
javax.naming.*
;
import
javax.naming.directory.*
;
import
java.util.Hashtable
;
public
class
NoWaitForReplyTest
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
boolean
passed
=
false
;
// Set up the environment for creating the initial context
Hashtable
env
=
new
Hashtable
(
11
);
env
.
put
(
Context
.
PROVIDER_URL
,
"ldap://localhost:22001"
);
env
.
put
(
Context
.
INITIAL_CONTEXT_FACTORY
,
"com.sun.jndi.ldap.LdapCtxFactory"
);
// Wait up to 10 seconds for a response from the LDAP server
env
.
put
(
"com.sun.jndi.ldap.read.timeout"
,
"10000"
);
// Don't wait until the first search reply is received
env
.
put
(
"com.sun.jndi.ldap.search.waitForReply"
,
"false"
);
// Send the LDAP search request without first authenticating (no bind)
env
.
put
(
"java.naming.ldap.version"
,
"3"
);
DummyServer
ldapServer
=
new
DummyServer
();
try
{
// start the LDAP server
ldapServer
.
start
();
// Create initial context
System
.
out
.
println
(
"Client: connecting to the server"
);
DirContext
ctx
=
new
InitialDirContext
(
env
);
SearchControls
scl
=
new
SearchControls
();
scl
.
setSearchScope
(
SearchControls
.
SUBTREE_SCOPE
);
System
.
out
.
println
(
"Client: performing search"
);
NamingEnumeration
answer
=
ctx
.
search
(
"ou=People,o=JNDITutorial"
,
"(objectClass=*)"
,
scl
);
// Server will never reply: either we waited in the call above until
// the timeout (fail) or we did not wait and reached here (pass).
passed
=
true
;
System
.
out
.
println
(
"Client: did not wait until first reply"
);
// Close the context when we're done
ctx
.
close
();
}
catch
(
NamingException
e
)
{
// timeout (ignore)
}
ldapServer
.
interrupt
();
if
(!
passed
)
{
throw
new
Exception
(
"Test FAILED: should not have waited until first search reply"
);
}
System
.
out
.
println
(
"Test PASSED"
);
}
static
class
DummyServer
extends
Thread
{
static
int
serverPort
=
22001
;
DummyServer
()
{
}
public
void
run
()
{
try
{
ServerSocket
serverSock
=
new
ServerSocket
(
serverPort
);
Socket
socket
=
serverSock
.
accept
();
System
.
out
.
println
(
"Server: accepted a connection"
);
BufferedInputStream
bin
=
new
BufferedInputStream
(
socket
.
getInputStream
());
while
(
true
)
{
bin
.
read
();
}
}
catch
(
IOException
e
)
{
// ignore
}
}
}
}
test/java/lang/Thread/StartOOMTest.java
浏览文件 @
84da54be
...
...
@@ -22,11 +22,14 @@
*/
/*
* @test
* @bug 6379235
* @ignore until 6721694 is fixed
* @run main/othervm -server -Xmx32m -Xms32m -Xss256m StartOOMTest
* @summary ThreadGroup accounting mistake possible with failure of Thread.start()
* This test is relatively useful for verifying 6379235, but
* is too resource intensive, especially on 64 bit systems,
* to be run automatically, see 6721694.
*
* When run it should be typically be run with the server vm
* and a relatively small java heap, and a large stack size
* ( to provoke the OOM quicker ).
* java -server -Xmx32m -Xms32m -Xss256m StartOOMTest
*/
import
java.util.*
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录