SimpleAliasRegistry fully synchronizes registerAlias and removeAlias
Issue: SPR-16577
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2017 the original author or authors.
|
* Copyright 2002-2018 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -45,6 +45,7 @@ public class SimpleAliasRegistry implements AliasRegistry {
|
|||||||
public void registerAlias(String name, String alias) {
|
public void registerAlias(String name, String alias) {
|
||||||
Assert.hasText(name, "'name' must not be empty");
|
Assert.hasText(name, "'name' must not be empty");
|
||||||
Assert.hasText(alias, "'alias' must not be empty");
|
Assert.hasText(alias, "'alias' must not be empty");
|
||||||
|
synchronized (this.aliasMap) {
|
||||||
if (alias.equals(name)) {
|
if (alias.equals(name)) {
|
||||||
this.aliasMap.remove(alias);
|
this.aliasMap.remove(alias);
|
||||||
}
|
}
|
||||||
@@ -64,6 +65,7 @@ public class SimpleAliasRegistry implements AliasRegistry {
|
|||||||
this.aliasMap.put(alias, name);
|
this.aliasMap.put(alias, name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return whether alias overriding is allowed.
|
* Return whether alias overriding is allowed.
|
||||||
@@ -92,11 +94,13 @@ public class SimpleAliasRegistry implements AliasRegistry {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeAlias(String alias) {
|
public void removeAlias(String alias) {
|
||||||
|
synchronized (this.aliasMap) {
|
||||||
String name = this.aliasMap.remove(alias);
|
String name = this.aliasMap.remove(alias);
|
||||||
if (name == null) {
|
if (name == null) {
|
||||||
throw new IllegalStateException("No alias '" + alias + "' registered");
|
throw new IllegalStateException("No alias '" + alias + "' registered");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isAlias(String name) {
|
public boolean isAlias(String name) {
|
||||||
|
|||||||
Reference in New Issue
Block a user