aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.junit.http
diff options
context:
space:
mode:
authorThomas Wolf <thomas.wolf@paranor.ch>2020-12-30 17:17:44 +0100
committerMatthias Sohn <matthias.sohn@sap.com>2021-01-01 12:49:05 -0500
commit0f442d70836ee292ed916605448f806cc7d1fe78 (patch)
tree385934b067f392c40b645d46ecc94101815b53ac /org.eclipse.jgit.junit.http
parent5b1a6e0e382da62e8678afdb2524109efb38eeb4 (diff)
downloadjgit-0f442d70836ee292ed916605448f806cc7d1fe78.tar.gz
jgit-0f442d70836ee292ed916605448f806cc7d1fe78.zip
Use Map interface instead of ConcurrentHashMap class
On Android, the co-variant override of ConcurrentHashMap.keySet() introduced in Java 8 was undone. [1] If compiled Java code calls that co-variant override directly, one gets a NoSuchMethodError exception at run-time on Android. Making the code call that method via Map.keySet() side-steps this problem. This is similar to bug 496262, where the same problem cropped up when compiling with Java 8 against a Java 7 target, but here we cannot use bootclasspath. We build against Java 8, not against the Android version of it. Recent Android versions should have some bytecode "magic" that adds the co-variant override in bytecode (see the commit referenced in [1]), but on older Android version this problem may still occur. (Or perhaps the "magic" is ineffective...) There are two pull requests on Github for this problem, both from 2020, [2][3] while the Android commit [1] is from March 2018. Apparently people still occasionally run into this problem in the wild. [1] https://android.googlesource.com/platform/libcore/+/0e8b937ded4de39f1d1cea5f04800d67dd2ec570/ojluni/src/main/java/java/util/concurrent/ConcurrentHashMap.java#1244 [2] https://github.com/eclipse/jgit/pull/104 [3] https://github.com/eclipse/jgit/pull/100 Change-Id: I7c07e0cc59871cb7fe60795e22867827fa9c2458 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
Diffstat (limited to 'org.eclipse.jgit.junit.http')
-rw-r--r--org.eclipse.jgit.junit.http/src/org/eclipse/jgit/junit/http/AppServer.java4
1 files changed, 2 insertions, 2 deletions
diff --git a/org.eclipse.jgit.junit.http/src/org/eclipse/jgit/junit/http/AppServer.java b/org.eclipse.jgit.junit.http/src/org/eclipse/jgit/junit/http/AppServer.java
index 4e27a3d351..f9f8c856b8 100644
--- a/org.eclipse.jgit.junit.http/src/org/eclipse/jgit/junit/http/AppServer.java
+++ b/org.eclipse.jgit.junit.http/src/org/eclipse/jgit/junit/http/AppServer.java
@@ -23,8 +23,8 @@ import java.nio.file.Files;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
+import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
import org.eclipse.jetty.http.HttpVersion;
import org.eclipse.jetty.security.AbstractLoginService;
@@ -259,7 +259,7 @@ public class AppServer {
static class TestMappedLoginService extends AbstractLoginService {
private String role;
- protected final ConcurrentMap<String, UserPrincipal> users = new ConcurrentHashMap<>();
+ protected final Map<String, UserPrincipal> users = new ConcurrentHashMap<>();
TestMappedLoginService(String role) {
this.role = role;