private static ObjectCache<Domain> myCache = new ObjectCache<>();
- public static Domain getById(int id) throws IllegalArgumentException {
+ public static synchronized Domain getById(int id) throws IllegalArgumentException {
Domain em = myCache.get(id);
if (em == null) {
try {
- synchronized (Domain.class) {
- myCache.put(em = new Domain(id));
- }
+ myCache.put(em = new Domain(id));
} catch (SQLException e1) {
throw new IllegalArgumentException(e1);
}
private static ObjectCache<DomainPingConfiguration> cache = new ObjectCache<>();
- public static DomainPingConfiguration getById(int id) {
+ public static synchronized DomainPingConfiguration getById(int id) {
DomainPingConfiguration res = cache.get(id);
if (res == null) {
try {
private static ObjectCache<EmailAddress> myCache = new ObjectCache<>();
- public static EmailAddress getById(int id) throws IllegalArgumentException {
+ public static synchronized EmailAddress getById(int id) throws IllegalArgumentException {
EmailAddress em = myCache.get(id);
if (em == null) {
try {
- synchronized (EmailAddress.class) {
- myCache.put(em = new EmailAddress(id));
- }
+ myCache.put(em = new EmailAddress(id));
} catch (SQLException e1) {
throw new IllegalArgumentException(e1);
}
private static ObjectCache<User> myCache = new ObjectCache<>();
- public static User getById(int id) {
+ public static synchronized User getById(int id) {
User u = myCache.get(id);
if (u == null) {
- synchronized (User.class) {
- myCache.put(u = new User(id));
- }
+ myCache.put(u = new User(id));
}
return u;
}