summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFlorian Zschocke <f.zschocke+git@gmail.com>2021-07-14 21:23:28 +0200
committerFlorian Zschocke <f.zschocke+git@gmail.com>2021-07-14 21:23:28 +0200
commitb50628d5cf317b07b40c67a049b527837661b934 (patch)
treece3b24f236b9c314cb378fb8512971b625ec4d85 /src
parente04cad2726141653e9e2559a95a91d83ae5e4fa4 (diff)
downloadgitblit-b50628d5cf317b07b40c67a049b527837661b934.tar.gz
gitblit-b50628d5cf317b07b40c67a049b527837661b934.zip
Fix: Make CPU hog fix Java 7 compatible
The last fix for the stored config merged from Curly060 used Java8-isms. In order to be able to include this fix in the next release, which will be for 1.9, I have converted this to be compatible with Java 7. Also, a file header was added to place it under APL.
Diffstat (limited to 'src')
-rw-r--r--src/main/java/com/gitblit/StoredUserConfig.java29
1 files changed, 22 insertions, 7 deletions
diff --git a/src/main/java/com/gitblit/StoredUserConfig.java b/src/main/java/com/gitblit/StoredUserConfig.java
index 2161ebb2..eae1d3cf 100644
--- a/src/main/java/com/gitblit/StoredUserConfig.java
+++ b/src/main/java/com/gitblit/StoredUserConfig.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2021 gitblit.com, Ingo Lafrenz
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package com.gitblit;
import java.io.File;
@@ -9,7 +25,6 @@ import java.util.Map;
import java.util.Objects;
import java.util.SortedMap;
import java.util.TreeMap;
-import java.util.function.Function;
/**
* Simple class with the only purpose to save the realm file (users.conf) in
@@ -29,12 +44,12 @@ public class StoredUserConfig {
}
public void setString(final String section, final String subsection, String name, String value) {
- Section s = sections.computeIfAbsent(generateKey(section, subsection), new Function<String, Section>() {
- @Override
- public Section apply(String k) {
- return new Section(section, subsection);
- }
- });
+ String key = generateKey(section, subsection);
+ Section s = sections.get(key);
+ if (s == null) {
+ s = new Section(section, subsection);
+ sections.put(key, s);
+ }
s.addEntry(name, value);
}