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
d9f5900e
Commit
d9f5900e
authored
Nov 14, 2014
by
Christian Schudt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
OF-837 PubSub should return non-persistent items (last published item)
parent
d1df562f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
4 deletions
+30
-4
LeafNode.java
src/java/org/jivesoftware/openfire/pubsub/LeafNode.java
+30
-4
No files found.
src/java/org/jivesoftware/openfire/pubsub/LeafNode.java
View file @
d9f5900e
...
...
@@ -341,21 +341,47 @@ public class LeafNode extends Node {
}
@Override
public
PublishedItem
getPublishedItem
(
String
itemID
)
{
public
PublishedItem
getPublishedItem
(
String
itemID
)
{
if
(!
isItemRequired
())
{
return
null
;
}
synchronized
(
this
)
{
if
(
lastPublished
!=
null
&&
lastPublished
.
getID
().
equals
(
itemID
))
{
return
lastPublished
;
}
}
return
PubSubPersistenceManager
.
getPublishedItem
(
this
,
itemID
);
}
@Override
public
List
<
PublishedItem
>
getPublishedItems
()
{
return
PubSubPersistenceManager
.
getPublishedItems
(
this
,
getMaxPublishedItems
());
return
getPublishedItems
(
getMaxPublishedItems
());
}
@Override
public
List
<
PublishedItem
>
getPublishedItems
(
int
recentItems
)
{
return
PubSubPersistenceManager
.
getPublishedItems
(
this
,
recentItems
);
public
synchronized
List
<
PublishedItem
>
getPublishedItems
(
int
recentItems
)
{
List
<
PublishedItem
>
publishedItems
=
PubSubPersistenceManager
.
getPublishedItems
(
this
,
recentItems
);
if
(
lastPublished
!=
null
)
{
// The persistent items may not contain the last item, if it wasn't persisted anymore (e.g. if node configuration changed).
// Therefore check, if the last item has been persisted.
boolean
persistentItemsContainsLastItem
=
false
;
for
(
PublishedItem
publishedItem
:
publishedItems
)
{
if
(
publishedItem
.
getID
().
equals
(
lastPublished
.
getID
()))
{
persistentItemsContainsLastItem
=
true
;
break
;
}
}
if
(!
persistentItemsContainsLastItem
)
{
// And if not, include the last item.
publishedItems
.
add
(
0
,
lastPublished
);
// Recheck the collection size, it might have one more element now (the last item).
// Remove it, if it exceeds the max items.
if
(
publishedItems
.
size
()
>
recentItems
)
{
publishedItems
.
remove
(
publishedItems
.
size
()
-
1
);
}
}
}
return
publishedItems
;
}
@Override
...
...
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