Skip to content

LinkedCaseInsensitiveMap doesn't override HashMap.clone() [SPR-14509] #19078

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
spring-projects-issues opened this issue Jul 25, 2016 · 0 comments
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) status: backported An issue that has been backported to maintenance branches type: bug A general bug
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Jul 25, 2016

Richard Browne opened SPR-14509 and commented

LinkedCaseInsensitiveMap derives from HashMap, but it does not override the clone() method. As a result, if you clone() a LinkedCaseInsensitiveMap, then subsequently modify the clone, the original can become corrupt.

Here is a test program to illustrate:

public class Test
{
	public static void main(String[] args)
	{
		LinkedCaseInsensitiveMap<String> map1 = new LinkedCaseInsensitiveMap<>();
		map1.put("KEY", "FOO");
		LinkedCaseInsensitiveMap<String> map2 = (LinkedCaseInsensitiveMap<String>)map1.clone();
		map2.put("Key", "Foo");
		String value = map1.get("KEY");

		System.err.format("Got '%s', expected 'FOO' .. ", value);
		System.err.println("FOO".equals(value) ? "SUCCESS" : "FAIL!");
	}
}

The map1.get("KEY") line should return "FOO". But instead it returns null.


Affects: 3.2.17, 4.2.7, 4.3.1

Issue Links:

Referenced from: commits 6459559, dd65f7a, e8562bb, dadd2c3

Backported to: 4.2.8, 3.2.18

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) status: backported An issue that has been backported to maintenance branches type: bug A general bug
Projects
None yet
Development

No branches or pull requests

2 participants