Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
8279222: Incorrect legacyMap.get in java.security.Provider after JDK-…
…8276660

Co-authored-by: Valerie Peng <valeriep@openjdk.org>
Reviewed-by: alanb, valeriep
  • Loading branch information
shipilev and Valerie Peng committed Jan 5, 2022
1 parent f8f9148 commit 0f4807e8fe2468f303b32a6f2dc9ccc7ecad82a1
Showing 2 changed files with 18 additions and 6 deletions.
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -1149,7 +1149,7 @@ private void parseLegacy(String name, String value, OPType opType) {
switch (opType) {
case ADD:
// clean up old alias if present
Service prevAliasService = legacyMap.get(aliasAlg);
Service prevAliasService = legacyMap.get(aliasKey);
if (prevAliasService != null) {
prevAliasService.removeAlias(aliasAlg);
}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2004, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@

/*
* @test
* @bug 5097015 8130181
* @bug 5097015 8130181 8279222
* @summary make sure we correctly treat Provider string entries as case insensitive
* @author Andreas Sterbenz
*/
@@ -36,9 +36,12 @@ public class CaseSensitiveServices extends Provider {
super("Foo", "1.0", null);
put("MessageDigest.Foo", "com.Foo");
put("mESSAGEdIGEST.fOO xYz", "aBc");
put("ALg.aliaS.MESSAGEdigest.Fu", "FoO");
// first assign the DEF alias to algorithm Foo
put("ALg.aliaS.MESSAGEdigest.DEF", "FoO");
put("messageDigest.Bar", "com.Bar");
put("MESSAGEDIGEST.BAZ", "com.Baz");
// reassign the DEF alias to algorithm Bar
put("ALg.aliaS.MESSAGEdigest.DEF", "Bar");
}

public static void main(String[] args) throws Exception {
@@ -47,12 +50,21 @@ public static void main(String[] args) throws Exception {
if (p.getServices().size() != 3) {
throw new Exception("services.size() should be 3");
}

Service s = testService(p, "MessageDigest", "fOO");
String val = s.getAttribute("Xyz");
if ("aBc".equals(val) == false) {
throw new Exception("Wrong value: " + val);
}
testService(p, "MessageDigest", "fU");
if (s.toString().indexOf("DEF") != -1) {
throw new Exception("Old alias DEF should be removed");
}

// test Service alias DEF and its associated impl is Bar
s = testService(p, "MessageDigest", "DeF");
if (s.getAttribute("Xyz") != null) {
throw new Exception("DEF mapped to the wrong impl");
}
testService(p, "MessageDigest", "BAR");
testService(p, "MessageDigest", "baz");
System.out.println("OK");

1 comment on commit 0f4807e

@openjdk-notifier
Copy link

@openjdk-notifier openjdk-notifier bot commented on 0f4807e Jan 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.