Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
f29071a2
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看板
提交
f29071a2
编写于
2月 18, 2011
作者:
S
smarks
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
7018385: update javax.sql classes to use try-with-resources
Reviewed-by: alanb, lancea, darcy
上级
9748b4ec
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
50 addition
and
31 deletion
+50
-31
src/share/classes/javax/sql/rowset/serial/SerialClob.java
src/share/classes/javax/sql/rowset/serial/SerialClob.java
+36
-27
src/share/classes/javax/sql/rowset/spi/SyncFactory.java
src/share/classes/javax/sql/rowset/spi/SyncFactory.java
+14
-4
未找到文件。
src/share/classes/javax/sql/rowset/serial/SerialClob.java
浏览文件 @
f29071a2
...
@@ -57,10 +57,10 @@ public class SerialClob implements Clob, Serializable, Cloneable {
...
@@ -57,10 +57,10 @@ public class SerialClob implements Clob, Serializable, Cloneable {
private
char
buf
[];
private
char
buf
[];
/**
/**
* Internal Clob representation if SerialClob is intialized with a
* Internal Clob representation if SerialClob is in
i
tialized with a
* Clob
* Clob
. Null if SerialClob is initialized with a char[].
*/
*/
private
Clob
clob
;
private
final
Clob
clob
;
/**
/**
* The length in characters of this <code>SerialClob</code> object's
* The length in characters of this <code>SerialClob</code> object's
...
@@ -71,12 +71,12 @@ public class SerialClob implements Clob, Serializable, Cloneable {
...
@@ -71,12 +71,12 @@ public class SerialClob implements Clob, Serializable, Cloneable {
private
long
len
;
private
long
len
;
/**
/**
* The original length in characters of t
gu
s <code>SerialClob</code>
* The original length in characters of t
hi
s <code>SerialClob</code>
* objects internal array of characters.
* object
'
s internal array of characters.
*
*
* @serial
* @serial
*/
*/
private
long
origLen
;
private
final
long
origLen
;
/**
/**
* Constructs a <code>SerialClob</code> object that is a serialized version of
* Constructs a <code>SerialClob</code> object that is a serialized version of
...
@@ -104,6 +104,7 @@ public class SerialClob implements Clob, Serializable, Cloneable {
...
@@ -104,6 +104,7 @@ public class SerialClob implements Clob, Serializable, Cloneable {
buf
[
i
]
=
ch
[
i
];
buf
[
i
]
=
ch
[
i
];
}
}
origLen
=
len
;
origLen
=
len
;
clob
=
null
;
}
}
/**
/**
...
@@ -117,19 +118,19 @@ public class SerialClob implements Clob, Serializable, Cloneable {
...
@@ -117,19 +118,19 @@ public class SerialClob implements Clob, Serializable, Cloneable {
* the database. Otherwise, the new <code>SerialClob</code> object
* the database. Otherwise, the new <code>SerialClob</code> object
* object will contain no data.
* object will contain no data.
* <p>
* <p>
* Note: The <code>Clob</code> object supplied to this constructor
canno
t
* Note: The <code>Clob</code> object supplied to this constructor
mus
t
* return
<code>null</code> for
the <code>Clob.getCharacterStream()</code>
* return
non-null for both
the <code>Clob.getCharacterStream()</code>
* and <code>Clob.getAsciiStream</code> methods. This <code>SerialClob</code>
* and <code>Clob.getAsciiStream</code> methods. This <code>SerialClob</code>
* constructor cannot
serialize a <code>Clob</code> object in this instance
* constructor cannot serialize a <code>Clob</code> object in this instance
* and will throw an <code>SQLException</code> object.
* and will throw an <code>SQLException</code> object.
*
*
* @param clob the <code>Clob</code> object from which this
* @param clob the <code>Clob</code> object from which this
* <code>SerialClob</code> object is to be constructed; cannot be null
* <code>SerialClob</code> object is to be constructed; cannot be null
* @throws SerialException if an error occurs during serialization
* @throws SerialException if an error occurs during serialization
* @throws SQLException if a SQL error occurs in capturing the CLOB;
* @throws SQLException if a SQL error occurs in capturing the CLOB;
* if the <code>Clob</code> object is a null; or if
both
the
* if the <code>Clob</code> object is a null; or if
either of
the
* <code>Clob.getCharacterStream()</code> and <code>Clob.getAsciiStream()</code>
* <code>Clob.getCharacterStream()</code> and <code>Clob.getAsciiStream()</code>
* methods on the <code>Clob</code> return a null
* methods on the <code>Clob</code> return
s
a null
* @see java.sql.Clob
* @see java.sql.Clob
*/
*/
public
SerialClob
(
Clob
clob
)
throws
SerialException
,
SQLException
{
public
SerialClob
(
Clob
clob
)
throws
SerialException
,
SQLException
{
...
@@ -144,19 +145,27 @@ public class SerialClob implements Clob, Serializable, Cloneable {
...
@@ -144,19 +145,27 @@ public class SerialClob implements Clob, Serializable, Cloneable {
int
read
=
0
;
int
read
=
0
;
int
offset
=
0
;
int
offset
=
0
;
BufferedReader
reader
;
try
(
Reader
charStream
=
clob
.
getCharacterStream
())
{
if
(
(((
reader
=
new
BufferedReader
(
clob
.
getCharacterStream
()))
==
null
))
&&
if
(
charStream
==
null
)
{
(
clob
.
getAsciiStream
()
==
null
))
{
throw
new
SQLException
(
"Invalid Clob object. The call to getCharacterStream "
+
throw
new
SQLException
(
"Invalid Clob object. Calls to getCharacterStream "
+
"returned null which cannot be serialized."
);
"and getAsciiStream return null which cannot be serialized."
);
}
}
try
{
// Note: get an ASCII stream in order to null-check it,
do
{
// even though we don't do anything with it.
read
=
reader
.
read
(
buf
,
offset
,
(
int
)(
len
-
offset
));
try
(
InputStream
asciiStream
=
clob
.
getAsciiStream
())
{
offset
+=
read
;
if
(
asciiStream
==
null
)
{
}
while
(
read
>
0
);
throw
new
SQLException
(
"Invalid Clob object. The call to getAsciiStream "
+
"returned null which cannot be serialized."
);
}
}
try
(
Reader
reader
=
new
BufferedReader
(
charStream
))
{
do
{
read
=
reader
.
read
(
buf
,
offset
,
(
int
)(
len
-
offset
));
offset
+=
read
;
}
while
(
read
>
0
);
}
}
catch
(
java
.
io
.
IOException
ex
)
{
}
catch
(
java
.
io
.
IOException
ex
)
{
throw
new
SerialException
(
"SerialClob: "
+
ex
.
getMessage
());
throw
new
SerialException
(
"SerialClob: "
+
ex
.
getMessage
());
}
}
...
@@ -207,13 +216,13 @@ public class SerialClob implements Clob, Serializable, Cloneable {
...
@@ -207,13 +216,13 @@ public class SerialClob implements Clob, Serializable, Cloneable {
* used to create this <code>SerialClob</code> object
* used to create this <code>SerialClob</code> object
*/
*/
public
java
.
io
.
InputStream
getAsciiStream
()
throws
SerialException
,
SQLException
{
public
java
.
io
.
InputStream
getAsciiStream
()
throws
SerialException
,
SQLException
{
if
(
this
.
clob
!=
null
)
{
if
(
this
.
clob
!=
null
)
{
return
this
.
clob
.
getAsciiStream
();
return
this
.
clob
.
getAsciiStream
();
}
else
{
}
else
{
throw
new
SerialException
(
"Unsupported operation. SerialClob cannot "
+
throw
new
SerialException
(
"Unsupported operation. SerialClob cannot "
+
"return a the CLOB value as an ascii stream, unless instantiated "
+
"return a the CLOB value as an ascii stream, unless instantiated "
+
"with a fully implemented Clob object."
);
"with a fully implemented Clob object."
);
}
}
}
}
/**
/**
...
...
src/share/classes/javax/sql/rowset/spi/SyncFactory.java
浏览文件 @
f29071a2
...
@@ -32,6 +32,7 @@ import java.sql.*;
...
@@ -32,6 +32,7 @@ import java.sql.*;
import
javax.sql.*
;
import
javax.sql.*
;
import
java.io.FileInputStream
;
import
java.io.FileInputStream
;
import
java.io.InputStream
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.FileNotFoundException
;
import
java.io.FileNotFoundException
;
...
@@ -366,7 +367,9 @@ public class SyncFactory {
...
@@ -366,7 +367,9 @@ public class SyncFactory {
// Load user's implementation of SyncProvider
// Load user's implementation of SyncProvider
// here. -Drowset.properties=/abc/def/pqr.txt
// here. -Drowset.properties=/abc/def/pqr.txt
ROWSET_PROPERTIES
=
strRowsetProperties
;
ROWSET_PROPERTIES
=
strRowsetProperties
;
properties
.
load
(
new
FileInputStream
(
ROWSET_PROPERTIES
));
try
(
FileInputStream
fis
=
new
FileInputStream
(
ROWSET_PROPERTIES
))
{
properties
.
load
(
fis
);
}
parseProperties
(
properties
);
parseProperties
(
properties
);
}
}
...
@@ -376,12 +379,19 @@ public class SyncFactory {
...
@@ -376,12 +379,19 @@ public class SyncFactory {
ROWSET_PROPERTIES
=
"javax"
+
strFileSep
+
"sql"
+
ROWSET_PROPERTIES
=
"javax"
+
strFileSep
+
"sql"
+
strFileSep
+
"rowset"
+
strFileSep
+
strFileSep
+
"rowset"
+
strFileSep
+
"rowset.properties"
;
"rowset.properties"
;
// properties.load(
// ClassLoader.getSystemResourceAsStream(ROWSET_PROPERTIES));
ClassLoader
cl
=
Thread
.
currentThread
().
getContextClassLoader
();
ClassLoader
cl
=
Thread
.
currentThread
().
getContextClassLoader
();
properties
.
load
(
cl
.
getResourceAsStream
(
ROWSET_PROPERTIES
));
try
(
InputStream
stream
=
(
cl
==
null
)
?
ClassLoader
.
getSystemResourceAsStream
(
ROWSET_PROPERTIES
)
:
cl
.
getResourceAsStream
(
ROWSET_PROPERTIES
))
{
if
(
stream
==
null
)
{
throw
new
SyncFactoryException
(
"Resource "
+
ROWSET_PROPERTIES
+
" not found"
);
}
properties
.
load
(
stream
);
}
parseProperties
(
properties
);
parseProperties
(
properties
);
// removed else, has properties should sum together
// removed else, has properties should sum together
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录