IDEMPIERE-5501 Misses in cache IDisplayTypeFactory (#1592)

This commit is contained in:
Carlos Ruiz 2022-11-29 04:46:40 +01:00 committed by GitHub
parent 7cac30ad13
commit 2fa0d49ac4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 92 additions and 53 deletions

View File

@ -232,12 +232,15 @@ public final class DisplayType
if (service != null)
return service.isID(displayType);
}
if (! s_displayTypeFactoryCache.containsKey(displayType)) {
Optional<IServiceReferenceHolder<IDisplayTypeFactory>> found = getDisplayTypeFactories().stream()
.filter(e -> e.getService() != null && e.getService().isID(displayType))
.findFirst();
if (found.isPresent()) {
s_displayTypeFactoryCache.put(displayType, found.get());
return true;
return found.get().getService().isID(displayType);
}
s_displayTypeFactoryCache.put(displayType, null);
}
return false;
@ -261,12 +264,15 @@ public final class DisplayType
if (service != null)
return service.isNumeric(displayType);
}
if (! s_displayTypeFactoryCache.containsKey(displayType)) {
Optional<IServiceReferenceHolder<IDisplayTypeFactory>> found = getDisplayTypeFactories().stream()
.filter(e -> e.getService() != null && e.getService().isNumeric(displayType))
.findFirst();
if (found.isPresent()) {
s_displayTypeFactoryCache.put(displayType, found.get());
return true;
return found.get().getService().isNumeric(displayType);
}
s_displayTypeFactoryCache.put(displayType, null);
}
return false;
@ -296,6 +302,7 @@ public final class DisplayType
return v != null ? v.intValue() : 0;
}
}
if (! s_displayTypeFactoryCache.containsKey(displayType)) {
Optional<IServiceReferenceHolder<IDisplayTypeFactory>> found = getDisplayTypeFactories().stream()
.filter(e -> e.getService() != null && e.getService().getDefaultPrecision(displayType) != null)
.findFirst();
@ -304,6 +311,8 @@ public final class DisplayType
Integer v = found.get().getService().getDefaultPrecision(displayType);
return v != null ? v.intValue() : 0;
}
s_displayTypeFactoryCache.put(displayType, null);
}
return 0;
} // getDefaultPrecision
@ -334,12 +343,15 @@ public final class DisplayType
if (service != null)
return service.isText(displayType);
}
if (! s_displayTypeFactoryCache.containsKey(displayType)) {
Optional<IServiceReferenceHolder<IDisplayTypeFactory>> found = getDisplayTypeFactories().stream()
.filter(e -> e.getService() != null && e.getService().isText(displayType))
.findFirst();
if (found.isPresent()) {
s_displayTypeFactoryCache.put(displayType, found.get());
return true;
return found.get().getService().isText(displayType);
}
s_displayTypeFactoryCache.put(displayType, null);
}
return false;
} // isText
@ -364,12 +376,15 @@ public final class DisplayType
if (service != null)
return service.isDate(displayType);
}
if (! s_displayTypeFactoryCache.containsKey(displayType)) {
Optional<IServiceReferenceHolder<IDisplayTypeFactory>> found = getDisplayTypeFactories().stream()
.filter(e -> e.getService() != null && e.getService().isDate(displayType))
.findFirst();
if (found.isPresent()) {
s_displayTypeFactoryCache.put(displayType, found.get());
return true;
return found.get().getService().isDate(displayType);
}
s_displayTypeFactoryCache.put(displayType, null);
}
return false;
@ -394,12 +409,15 @@ public final class DisplayType
if (service != null)
return service.isList(displayType);
}
if (! s_displayTypeFactoryCache.containsKey(displayType)) {
Optional<IServiceReferenceHolder<IDisplayTypeFactory>> found = getDisplayTypeFactories().stream()
.filter(e -> e.getService() != null && e.getService().isList(displayType))
.findFirst();
if (found.isPresent()) {
s_displayTypeFactoryCache.put(displayType, found.get());
return true;
return found.get().getService().isList(displayType);
}
s_displayTypeFactoryCache.put(displayType, null);
}
return false;
@ -427,12 +445,15 @@ public final class DisplayType
if (service != null)
return service.isLookup(displayType);
}
if (! s_displayTypeFactoryCache.containsKey(displayType)) {
Optional<IServiceReferenceHolder<IDisplayTypeFactory>> found = getDisplayTypeFactories().stream()
.filter(e -> e.getService() != null && e.getService().isLookup(displayType))
.findFirst();
if (found.isPresent()) {
s_displayTypeFactoryCache.put(displayType, found.get());
return true;
return found.get().getService().isLookup(displayType);
}
s_displayTypeFactoryCache.put(displayType, null);
}
return false;
@ -455,12 +476,15 @@ public final class DisplayType
if (service != null)
return service.isLOB(displayType);
}
if (! s_displayTypeFactoryCache.containsKey(displayType)) {
Optional<IServiceReferenceHolder<IDisplayTypeFactory>> found = getDisplayTypeFactories().stream()
.filter(e -> e.getService() != null && e.getService().isLOB(displayType))
.findFirst();
if (found.isPresent()) {
s_displayTypeFactoryCache.put(displayType, found.get());
return true;
return found.get().getService().isLOB(displayType);
}
s_displayTypeFactoryCache.put(displayType, null);
}
return false;
@ -542,6 +566,7 @@ public final class DisplayType
return f;
}
}
if (! s_displayTypeFactoryCache.containsKey(displayType)) {
Optional<IServiceReferenceHolder<IDisplayTypeFactory>> found = getDisplayTypeFactories().stream()
.filter(e -> e.getService() != null && e.getService().getNumberFormat(displayType, language, pattern) != null)
.findFirst();
@ -549,6 +574,8 @@ public final class DisplayType
s_displayTypeFactoryCache.put(displayType, found.get());
return found.get().getService().getNumberFormat(displayType, language, pattern);
}
s_displayTypeFactoryCache.put(displayType, null);
}
format.setMaximumIntegerDigits(MAX_DIGITS);
format.setMaximumFractionDigits(MAX_FRACTION);
@ -673,6 +700,7 @@ public final class DisplayType
return v;
}
}
if (! s_displayTypeFactoryCache.containsKey(displayType)) {
Optional<IServiceReferenceHolder<IDisplayTypeFactory>> found = getDisplayTypeFactories().stream()
.filter(e -> e.getService() != null && e.getService().getDateFormat(displayType, language, pattern) != null)
.findFirst();
@ -680,6 +708,8 @@ public final class DisplayType
s_displayTypeFactoryCache.put(displayType, found.get());
return found.get().getService().getDateFormat(displayType, language, pattern);
}
s_displayTypeFactoryCache.put(displayType, null);
}
}
// Date
@ -760,6 +790,7 @@ public final class DisplayType
return v;
}
}
if (! s_displayTypeFactoryCache.containsKey(displayType)) {
Optional<IServiceReferenceHolder<IDisplayTypeFactory>> found = getDisplayTypeFactories().stream()
.filter(e -> e.getService() != null && e.getService().getClass(displayType, yesNoAsBoolean) != null)
.findFirst();
@ -767,6 +798,8 @@ public final class DisplayType
s_displayTypeFactoryCache.put(displayType, found.get());
return found.get().getService().getClass(displayType, yesNoAsBoolean);
}
s_displayTypeFactoryCache.put(displayType, null);
}
}
//
return Object.class;
@ -851,6 +884,7 @@ public final class DisplayType
return v;
}
}
if (! s_displayTypeFactoryCache.containsKey(displayType)) {
Optional<IServiceReferenceHolder<IDisplayTypeFactory>> found = getDisplayTypeFactories().stream()
.filter(e -> e.getService() != null && e.getService().getSQLDataType(displayType, columnName, fieldLength) != null)
.findFirst();
@ -858,6 +892,8 @@ public final class DisplayType
s_displayTypeFactoryCache.put(displayType, found.get());
return found.get().getService().getSQLDataType(displayType, columnName, fieldLength);
}
s_displayTypeFactoryCache.put(displayType, null);
}
if (!DisplayType.isText(displayType))
s_log.severe("Unhandled Data Type = " + displayType);
@ -955,6 +991,7 @@ public final class DisplayType
return v;
}
}
if (! s_displayTypeFactoryCache.containsKey(displayType)) {
Optional<IServiceReferenceHolder<IDisplayTypeFactory>> found = getDisplayTypeFactories().stream()
.filter(e -> e.getService() != null && e.getService().getDescription(displayType) != null)
.findFirst();
@ -962,6 +999,8 @@ public final class DisplayType
s_displayTypeFactoryCache.put(displayType, found.get());
return found.get().getService().getDescription(displayType);
}
s_displayTypeFactoryCache.put(displayType, null);
}
//
return "UNKNOWN DisplayType=" + displayType;