Skip to content

Commit

Permalink
#550 Do not rely on exceptions for flow control in HISinOneResolver#g…
Browse files Browse the repository at this point in the history
…etFieldValue
  • Loading branch information
Possommi committed Sep 30, 2024
1 parent b8d0288 commit c847951
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import java.lang.reflect.Field;
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
Expand Down Expand Up @@ -842,10 +843,12 @@ protected Object getFieldValue(SysValue sysValue, String fieldName) {

/* lookup field in class hierarchy */
while (clazz != null && field == null) {
try {
LOGGER.debug("Checking for field {} in {}", fieldName, clazz.getSimpleName());
field = clazz.getDeclaredField(fieldName);
} catch (Exception e) {
LOGGER.debug("Checking for field {} in {}", fieldName, clazz.getSimpleName());
Optional<Field> f = Arrays.stream(clazz.getDeclaredFields())
.filter(df -> df.getName().equals(fieldName)).findFirst();
if (f.isPresent()) {
field = f.get();
} else {
LOGGER.debug("Field {} could not be obtained from {}. Checking superclass {}", fieldName,
clazz.getSimpleName(),
clazz.getSuperclass().getSimpleName());
Expand Down

0 comments on commit c847951

Please sign in to comment.