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
ba13f4d6
Unverified
Commit
ba13f4d6
authored
Aug 12, 2016
by
Guus der Kinderen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "OF-1156: Be consistent with the contents of DefaultCache with the"
This reverts commit
d93e8d83
.
parent
c94c6706
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
21 deletions
+16
-21
Cache.java
src/java/org/jivesoftware/util/cache/Cache.java
+1
-4
DefaultCache.java
src/java/org/jivesoftware/util/cache/DefaultCache.java
+15
-17
No files found.
src/java/org/jivesoftware/util/cache/Cache.java
View file @
ba13f4d6
...
@@ -30,7 +30,7 @@ package org.jivesoftware.util.cache;
...
@@ -30,7 +30,7 @@ package org.jivesoftware.util.cache;
*
*
* If the cache does grow too large, objects will be removed such that those
* If the cache does grow too large, objects will be removed such that those
* that are accessed least frequently are removed first. Because expiration
* that are accessed least frequently are removed first. Because expiration
* happens automatically, the cache makes <b>no</b> g
ua
rantee as to how long
* happens automatically, the cache makes <b>no</b> g
au
rantee as to how long
* an object will remain in cache after it is put in.<p>
* an object will remain in cache after it is put in.<p>
*
*
* Optionally, a maximum lifetime for all objects can be specified. In that
* Optionally, a maximum lifetime for all objects can be specified. In that
...
@@ -41,9 +41,6 @@ package org.jivesoftware.util.cache;
...
@@ -41,9 +41,6 @@ package org.jivesoftware.util.cache;
*
*
* All cache operations are thread safe.<p>
* All cache operations are thread safe.<p>
*
*
* Note that neither keys or values can be null; A {@link NullPointerException}
* will be thrown attempting to place or retrieve null values in to the cache.
*
* @see Cacheable
* @see Cacheable
*/
*/
public
interface
Cache
<
K
,
V
>
extends
java
.
util
.
Map
<
K
,
V
>
{
public
interface
Cache
<
K
,
V
>
extends
java
.
util
.
Map
<
K
,
V
>
{
...
...
src/java/org/jivesoftware/util/cache/DefaultCache.java
View file @
ba13f4d6
...
@@ -59,10 +59,7 @@ import org.slf4j.LoggerFactory;
...
@@ -59,10 +59,7 @@ import org.slf4j.LoggerFactory;
*/
*/
public
class
DefaultCache
<
K
,
V
>
implements
Cache
<
K
,
V
>
{
public
class
DefaultCache
<
K
,
V
>
implements
Cache
<
K
,
V
>
{
private
static
final
String
NULL_KEY_IS_NOT_ALLOWED
=
"Null key is not allowed!"
;
private
static
final
Logger
Log
=
LoggerFactory
.
getLogger
(
DefaultCache
.
class
);
private
static
final
String
NULL_VALUE_IS_NOT_ALLOWED
=
"Null value is not allowed!"
;
private
static
final
Logger
Log
=
LoggerFactory
.
getLogger
(
DefaultCache
.
class
);
/**
/**
* The map the keys and values are stored in.
* The map the keys and values are stored in.
...
@@ -136,8 +133,6 @@ public class DefaultCache<K, V> implements Cache<K, V> {
...
@@ -136,8 +133,6 @@ public class DefaultCache<K, V> implements Cache<K, V> {
@Override
@Override
public
synchronized
V
put
(
K
key
,
V
value
)
{
public
synchronized
V
put
(
K
key
,
V
value
)
{
checkNotNull
(
key
,
NULL_KEY_IS_NOT_ALLOWED
);
checkNotNull
(
value
,
NULL_VALUE_IS_NOT_ALLOWED
);
// Delete an old entry if it exists.
// Delete an old entry if it exists.
V
answer
=
remove
(
key
);
V
answer
=
remove
(
key
);
...
@@ -179,7 +174,6 @@ public class DefaultCache<K, V> implements Cache<K, V> {
...
@@ -179,7 +174,6 @@ public class DefaultCache<K, V> implements Cache<K, V> {
@Override
@Override
public
synchronized
V
get
(
Object
key
)
{
public
synchronized
V
get
(
Object
key
)
{
checkNotNull
(
key
,
NULL_KEY_IS_NOT_ALLOWED
);
// First, clear all entries that have been in cache longer than the
// First, clear all entries that have been in cache longer than the
// maximum defined age.
// maximum defined age.
deleteExpiredEntries
();
deleteExpiredEntries
();
...
@@ -206,7 +200,6 @@ public class DefaultCache<K, V> implements Cache<K, V> {
...
@@ -206,7 +200,6 @@ public class DefaultCache<K, V> implements Cache<K, V> {
@Override
@Override
public
synchronized
V
remove
(
Object
key
)
{
public
synchronized
V
remove
(
Object
key
)
{
checkNotNull
(
key
,
NULL_KEY_IS_NOT_ALLOWED
);
DefaultCache
.
CacheObject
<
V
>
cacheObject
=
map
.
get
(
key
);
DefaultCache
.
CacheObject
<
V
>
cacheObject
=
map
.
get
(
key
);
// If the object is not in cache, stop trying to remove it.
// If the object is not in cache, stop trying to remove it.
if
(
cacheObject
==
null
)
{
if
(
cacheObject
==
null
)
{
...
@@ -292,7 +285,6 @@ public class DefaultCache<K, V> implements Cache<K, V> {
...
@@ -292,7 +285,6 @@ public class DefaultCache<K, V> implements Cache<K, V> {
@Override
@Override
public
boolean
contains
(
Object
o
)
{
public
boolean
contains
(
Object
o
)
{
checkNotNull
(
o
,
NULL_KEY_IS_NOT_ALLOWED
);
Iterator
<
V
>
it
=
iterator
();
Iterator
<
V
>
it
=
iterator
();
while
(
it
.
hasNext
())
{
while
(
it
.
hasNext
())
{
if
(
it
.
next
().
equals
(
o
))
{
if
(
it
.
next
().
equals
(
o
))
{
...
@@ -399,7 +391,6 @@ public class DefaultCache<K, V> implements Cache<K, V> {
...
@@ -399,7 +391,6 @@ public class DefaultCache<K, V> implements Cache<K, V> {
@Override
@Override
public
boolean
containsKey
(
Object
key
)
{
public
boolean
containsKey
(
Object
key
)
{
checkNotNull
(
key
,
NULL_KEY_IS_NOT_ALLOWED
);
// First, clear all entries that have been in cache longer than the
// First, clear all entries that have been in cache longer than the
// maximum defined age.
// maximum defined age.
deleteExpiredEntries
();
deleteExpiredEntries
();
...
@@ -418,11 +409,14 @@ public class DefaultCache<K, V> implements Cache<K, V> {
...
@@ -418,11 +409,14 @@ public class DefaultCache<K, V> implements Cache<K, V> {
@Override
@Override
public
boolean
containsValue
(
Object
value
)
{
public
boolean
containsValue
(
Object
value
)
{
checkNotNull
(
value
,
NULL_VALUE_IS_NOT_ALLOWED
);
// First, clear all entries that have been in cache longer than the
// First, clear all entries that have been in cache longer than the
// maximum defined age.
// maximum defined age.
deleteExpiredEntries
();
deleteExpiredEntries
();
if
(
value
==
null
)
{
return
containsNullValue
();
}
Iterator
it
=
values
().
iterator
();
Iterator
it
=
values
().
iterator
();
while
(
it
.
hasNext
())
{
while
(
it
.
hasNext
())
{
if
(
value
.
equals
(
it
.
next
()))
{
if
(
value
.
equals
(
it
.
next
()))
{
...
@@ -432,6 +426,16 @@ public class DefaultCache<K, V> implements Cache<K, V> {
...
@@ -432,6 +426,16 @@ public class DefaultCache<K, V> implements Cache<K, V> {
return
false
;
return
false
;
}
}
private
boolean
containsNullValue
()
{
Iterator
it
=
values
().
iterator
();
while
(
it
.
hasNext
())
{
if
(
it
.
next
()
==
null
)
{
return
true
;
}
}
return
false
;
}
@Override
@Override
public
Set
<
Entry
<
K
,
V
>>
entrySet
()
{
public
Set
<
Entry
<
K
,
V
>>
entrySet
()
{
// First, clear all entries that have been in cache longer than the
// First, clear all entries that have been in cache longer than the
...
@@ -699,10 +703,4 @@ public class DefaultCache<K, V> implements Cache<K, V> {
...
@@ -699,10 +703,4 @@ public class DefaultCache<K, V> implements Cache<K, V> {
this
.
size
=
size
;
this
.
size
=
size
;
}
}
}
}
private
void
checkNotNull
(
final
Object
argument
,
final
String
message
)
{
if
(
argument
==
null
)
{
throw
new
NullPointerException
(
message
);
}
}
}
}
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