Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
Openfire
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Openfire
Commits
15f19d80
Commit
15f19d80
authored
Dec 01, 2016
by
Dave Cridland
Committed by
GitHub
Dec 01, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #686 from akrherz/of1229
OF-1229 Safeguard JDBC.executeBatch() calls on empty batch
parents
626417c6
476ab027
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
4 deletions
+9
-4
PubSubPersistenceManager.java
...ivesoftware/openfire/pubsub/PubSubPersistenceManager.java
+9
-4
No files found.
src/java/org/jivesoftware/openfire/pubsub/PubSubPersistenceManager.java
View file @
15f19d80
...
...
@@ -1314,9 +1314,10 @@ public class PubSubPersistenceManager {
try
{
LinkedListNode
<
PublishedItem
>
delHead
=
delItem
.
previous
;
pstmt
=
con
.
prepareStatement
(
DELETE_ITEM
);
Boolean
hasBatchItems
=
false
;
while
(
delItem
!=
delHead
)
{
hasBatchItems
=
true
;
PublishedItem
item
=
delItem
.
object
;
pstmt
.
setString
(
1
,
item
.
getNode
().
getService
().
getServiceID
());
pstmt
.
setString
(
2
,
encodeNodeID
(
item
.
getNode
().
getNodeID
()));
...
...
@@ -1325,7 +1326,7 @@ public class PubSubPersistenceManager {
delItem
=
delItem
.
next
;
}
pstmt
.
executeBatch
();
if
(
hasBatchItems
)
pstmt
.
executeBatch
();
}
catch
(
SQLException
ex
)
{
log
.
error
(
"Failed to delete published item(s) from DB"
,
ex
);
// do not re-throw here; continue with insert operation if possible
...
...
@@ -1359,8 +1360,10 @@ public class PubSubPersistenceManager {
PublishedItem
item
=
null
;
try
{
pstmt
=
con
.
prepareStatement
(
ADD_ITEM
);
Boolean
hasBatchItems
=
false
;
while
(
addItem
!=
addHead
)
{
hasBatchItems
=
true
;
wrappedItem
=
addItem
.
object
;
item
=
wrappedItem
.
get
();
pstmt
.
setString
(
1
,
item
.
getNode
().
getService
().
getServiceID
());
...
...
@@ -1386,7 +1389,7 @@ public class PubSubPersistenceManager {
}
addItem
=
addItem
.
next
;
}
if
(
batch
)
{
pstmt
.
executeBatch
();
}
if
(
batch
&&
hasBatchItems
)
{
pstmt
.
executeBatch
();
}
}
catch
(
SQLException
se
)
{
log
.
error
(
"Failed to persist published items as batch; will retry individually"
,
se
);
// caught by caller; should not cause a transaction rollback
...
...
@@ -1880,8 +1883,10 @@ public class PubSubPersistenceManager {
PreparedStatement
purgeNode
=
con
.
prepareStatement
(
getPurgeStatement
(
DbConnectionManager
.
getDatabaseType
()));
Boolean
hasBatchItems
=
false
;
while
(
rs
.
next
())
{
hasBatchItems
=
true
;
String
svcId
=
rs
.
getString
(
1
);
String
nodeId
=
rs
.
getString
(
2
);
int
maxItems
=
rs
.
getInt
(
3
);
...
...
@@ -1890,7 +1895,7 @@ public class PubSubPersistenceManager {
purgeNode
.
addBatch
();
}
purgeNode
.
executeBatch
();
if
(
hasBatchItems
)
purgeNode
.
executeBatch
();
}
catch
(
Exception
sqle
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment