From b50628d5cf317b07b40c67a049b527837661b934 Mon Sep 17 00:00:00 2001 From: Florian Zschocke Date: Wed, 14 Jul 2021 21:23:28 +0200 Subject: [PATCH] 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. --- .../java/com/gitblit/StoredUserConfig.java | 29 ++++++++++++++----- 1 file 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() { - @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); } -- 2.39.5