This is an automated email from the ASF dual-hosted git repository. solomax pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/openmeetings.git
The following commit(s) were added to refs/heads/master by this push: new c6e429a [OPENMEETINGS-2525] NPE should be fixed c6e429a is described below commit c6e429aa65d4f5f92ca4e501703563f016f9821a Author: Maxim Solodovnik <solomax...@gmail.com> AuthorDate: Thu Nov 26 07:52:35 2020 +0700 [OPENMEETINGS-2525] NPE should be fixed --- .../apache/openmeetings/db/dao/label/LabelDao.java | 4 ++-- .../apache/openmeetings/db/entity/user/User.java | 21 +++++++++------------ openmeetings-server/src/main/assembly/quick.xml | 4 ++-- 3 files changed, 13 insertions(+), 16 deletions(-) diff --git a/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/label/LabelDao.java b/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/label/LabelDao.java index fceec2d..2e808fe 100644 --- a/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/label/LabelDao.java +++ b/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/label/LabelDao.java @@ -74,6 +74,7 @@ public class LabelDao implements IDataProviderDao<StringLabel>{ private static final String KEY_ATTR = "key"; public static final String APP_RESOURCES_PREFIX = "Application"; public static final String APP_RESOURCES_SUFFIX = ".properties.xml"; + private static final OmLanguage LNG_ENGLISH = new OmLanguage(Locale.ENGLISH); private static final LinkedHashMap<Long, OmLanguage> languages = new LinkedHashMap<>(); private static final ConcurrentHashMap<Locale, List<StringLabel>> labelCache = new ConcurrentHashMap<>(); private static final Set<String> keys = new HashSet<>(); @@ -207,8 +208,7 @@ public class LabelDao implements IDataProviderDao<StringLabel>{ } public static OmLanguage getLanguage(Long id) { - OmLanguage l = id == null ? null : languages.get(id); - return l == null ? languages.get(1L) : l; + return languages.getOrDefault(id == null ? 1L : id, LNG_ENGLISH); } public static Locale getLocale(Long id) { diff --git a/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/user/User.java b/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/user/User.java index e1ff983..a39b8c4 100644 --- a/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/user/User.java +++ b/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/user/User.java @@ -33,6 +33,7 @@ import java.util.HashSet; import java.util.List; import java.util.Optional; import java.util.Set; +import java.util.StringJoiner; import javax.persistence.Basic; import javax.persistence.CascadeType; @@ -663,28 +664,24 @@ public class User extends HistoricalEntity { } private String generateDisplayName() { - StringBuilder sb = new StringBuilder(); - String delim = ""; + StringJoiner joiner = new StringJoiner(" ") + .setEmptyValue(DISPLAY_NAME_NA); OmLanguage l = LabelDao.getLanguage(languageId); String first = l.isRtl() ? lastname : firstname; String last = l.isRtl() ? firstname : lastname; if (!Strings.isEmpty(first)) { - sb.append(first); - delim = " "; + joiner.add(first); } if (!Strings.isEmpty(last)) { - sb.append(delim).append(last); + joiner.add(last); } - if (id != null && Strings.isEmpty(sb)) { + if (id != null && joiner.length() == 0) { if (Type.CONTACT == type && address != null && !Strings.isEmpty(address.getEmail())) { - sb.append(address.getEmail()); + joiner.add(address.getEmail()); } else { - sb.append(login); + joiner.add(login); } } - if (Strings.isEmpty(sb)) { - sb.append(DISPLAY_NAME_NA); - } - return escapeMarkup(sb).toString(); + return escapeMarkup(joiner.toString()).toString(); } } diff --git a/openmeetings-server/src/main/assembly/quick.xml b/openmeetings-server/src/main/assembly/quick.xml index 80cb51d..14c2832 100644 --- a/openmeetings-server/src/main/assembly/quick.xml +++ b/openmeetings-server/src/main/assembly/quick.xml @@ -33,7 +33,7 @@ </includes> <excludes> <exclude>WEB-INF/web.xml</exclude> - <exclude>WEB-INF/classes/META-INF/*</exclude> + <exclude>WEB-INF/classes/*</exclude> </excludes> </fileSet> <fileSet> @@ -42,7 +42,7 @@ <filtered>true</filtered> <includes> <include>WEB-INF/web.xml</include> - <include>WEB-INF/classes/META-INF/*</include> + <include>WEB-INF/classes/*</include> </includes> </fileSet> <fileSet>