rs.close();
}
- public EmailAddress(String address, User owner) {
+ public EmailAddress(User owner, String address) {
if ( !EmailProvider.MAIL.matcher(address).matches()) {
throw new IllegalArgumentException("Invalid email.");
}
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);
}