Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
OLAT CI-CD Testing Project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Lars Oliver Dam
OLAT CI-CD Testing Project
Commits
87528999
Commit
87528999
authored
5 years ago
by
srosse
Browse files
Options
Downloads
Patches
Plain Diff
nno-jira: sorted properties are not sorted running Java 11
parent
523078fd
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/org/olat/core/util/SortedProperties.java
+22
-3
22 additions, 3 deletions
src/main/java/org/olat/core/util/SortedProperties.java
with
22 additions
and
3 deletions
src/main/java/org/olat/core/util/SortedProperties.java
+
22
−
3
View file @
87528999
...
@@ -28,8 +28,10 @@ import java.util.ArrayList;
...
@@ -28,8 +28,10 @@ import java.util.ArrayList;
import
java.util.Collections
;
import
java.util.Collections
;
import
java.util.Enumeration
;
import
java.util.Enumeration
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map.Entry
;
import
java.util.Properties
;
import
java.util.Properties
;
import
java.util.Set
;
import
java.util.Set
;
import
java.util.TreeMap
;
/**
/**
* Description:<br>
* Description:<br>
...
@@ -51,8 +53,12 @@ import java.util.Set;
...
@@ -51,8 +53,12 @@ import java.util.Set;
* @author gnaegi
* @author gnaegi
*/
*/
public
class
SortedProperties
extends
Properties
{
public
class
SortedProperties
extends
Properties
{
private
static
final
long
serialVersionUID
=
-
5930211273975255180L
;
/**
/**
* Overriden to be able to write properties sorted by keys to the disk
* Override to be able to write properties sorted by keys
* to the disk (only Java 8)
*
*
* @see java.util.Hashtable#keys()
* @see java.util.Hashtable#keys()
*/
*/
...
@@ -61,7 +67,20 @@ public class SortedProperties extends Properties {
...
@@ -61,7 +67,20 @@ public class SortedProperties extends Properties {
public
synchronized
Enumeration
<
Object
>
keys
()
{
public
synchronized
Enumeration
<
Object
>
keys
()
{
// sort elements based on detector (prop key) names
// sort elements based on detector (prop key) names
Set
set
=
keySet
();
Set
set
=
keySet
();
return
(
Enumeration
<
Object
>)
sortKeys
(
set
);
return
sortKeys
(
set
);
}
/**
* Override to be able to write properties sorted by keys
* to the disk (Java 11)
*/
@Override
public
Set
<
Entry
<
Object
,
Object
>>
entrySet
()
{
TreeMap
<
Object
,
Object
>
map
=
new
TreeMap
<>();
for
(
Object
propertyName:
keySet
())
{
map
.
put
(
propertyName
,
get
(
propertyName
));
}
return
map
.
entrySet
();
}
}
/**
/**
...
@@ -74,7 +93,7 @@ public class SortedProperties extends Properties {
...
@@ -74,7 +93,7 @@ public class SortedProperties extends Properties {
* @return non null list wich contains all given keys, sorted
* @return non null list wich contains all given keys, sorted
* lexicographically. The list may be empty if given set was empty
* lexicographically. The list may be empty if given set was empty
*/
*/
static
publ
ic
Enumeration
<?>
sortKeys
(
Set
<
String
>
keySet
)
{
public
stat
ic
Enumeration
<?>
sortKeys
(
Set
<
String
>
keySet
)
{
List
<
String
>
sortedList
=
new
ArrayList
<>();
List
<
String
>
sortedList
=
new
ArrayList
<>();
sortedList
.
addAll
(
keySet
);
sortedList
.
addAll
(
keySet
);
Collections
.
sort
(
sortedList
);
Collections
.
sort
(
sortedList
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment