Skip to content

Commit

Permalink
Merge pull request #457 from 1c-syntax/feature/fix240531
Browse files Browse the repository at this point in the history
Фиксы многопоточной работы
  • Loading branch information
theshadowco authored Jun 3, 2024
2 parents 6f78f00 + edbfd30 commit 4dec71b
Show file tree
Hide file tree
Showing 20 changed files with 24 additions and 8,758 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -147,34 +147,10 @@ public Class<?> computeType(@NonNull ParameterizedType fieldClass) {

@Nullable
private Method getMethod(@NonNull Class<?> clazz, @NonNull String methodName) {
var classMethods = methods.get(clazz.getName());
if (classMethods == null) {
classMethods = new ConcurrentSkipListMap<>(String.CASE_INSENSITIVE_ORDER);
}

var method = classMethods.get(methodName);
// ключ метода в кэше есть, но метода нет
if (method == null) {
// ключ метода в кэше есть, но метода нет
if (classMethods.containsKey(methodName)) {
return null;
}
method = Arrays.stream(clazz.getDeclaredMethods())
.filter(classMethod -> methodName.equalsIgnoreCase(classMethod.getName()))
return methods.computeIfAbsent(clazz.getName(), k -> new ConcurrentSkipListMap<>(String.CASE_INSENSITIVE_ORDER))
.computeIfAbsent(methodName, k -> Arrays.stream(clazz.getDeclaredMethods())
.filter(m -> methodName.equalsIgnoreCase(m.getName()))
.findFirst()
.orElse(null);
if (method != null) {
saveMethod(clazz, classMethods, method, methodName);
}
}
return method;
}

private static void saveMethod(@NonNull Class<?> builderClass,
@NonNull Map<String, Method> classMethods,
@NonNull Method method,
@NonNull String builderMethodName) {
classMethods.put(builderMethodName, method);
methods.put(builderClass.getName(), classMethods);
.orElse(null));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -107,46 +107,35 @@ public final void setValue(String methodName, Object value) {

@Override
public Object build() {
try {
mdoReference = MdoReference.create(owner, mdoType, name);
setValue(MDO_REFERENCE_FIELD_NAME, mdoReference);
mdoReference = MdoReference.create(owner, mdoType, name);
setValue(MDO_REFERENCE_FIELD_NAME, mdoReference);

if (MDChild.class.isAssignableFrom(realClass)) {
setValue(OWNER_FIELD_NAME, owner);
}

if (Subsystem.class.isAssignableFrom(realClass)) {
setValue(PARENT_SUBSYSTEM_FIELD_NAME, owner);
}
if (MDChild.class.isAssignableFrom(realClass)) {
setValue(OWNER_FIELD_NAME, owner);
}

if (Form.class.isAssignableFrom(realClass)) {
setValue(DATA_FIELD_NAME, mdReader.readFormData(currentPath, name, mdoType));
}
if (Subsystem.class.isAssignableFrom(realClass)) {
setValue(PARENT_SUBSYSTEM_FIELD_NAME, owner);
}

if (ChildrenOwner.class.isAssignableFrom(realClass)) {
setValueChildren();
}
if (Form.class.isAssignableFrom(realClass)) {
setValue(DATA_FIELD_NAME, mdReader.readFormData(currentPath, name, mdoType));
}

if (ModuleOwner.class.isAssignableFrom(realClass)) {
setValueModules();
}
if (ChildrenOwner.class.isAssignableFrom(realClass)) {
setValueChildren();
}

return super.build();
} catch (Exception e) {
LOGGER.warn("Can't read file '{}' - it's broken (object skipped) \n: ", currentPath, e);
LOGGER.warn("Reader context\n: '{}'", this);
LOGGER.warn("Builder content\n: '{}'", builder);
if (ModuleOwner.class.isAssignableFrom(realClass)) {
setValueModules();
}
return null;

return super.build();
}

private void saveChildName(String collectionName, MDReaderContext child) {
var collection = childrenContexts.get(collectionName);
if (collection == null) {
collection = Collections.synchronizedList(new ArrayList<>());
}
collection.add(child);
childrenContexts.put(collectionName, collection);
childrenContexts.computeIfAbsent(collectionName, k -> Collections.synchronizedList(new ArrayList<>()))
.add(child);
}

private void setValueChildren() {
Expand Down
29 changes: 0 additions & 29 deletions src/main/resources/xsd/edt/CommonModule.xsd

This file was deleted.

113 changes: 0 additions & 113 deletions src/main/resources/xsd/edt/Configuration.xsd

This file was deleted.

30 changes: 0 additions & 30 deletions src/main/resources/xsd/edt/MDBase.xsd

This file was deleted.

26 changes: 0 additions & 26 deletions src/main/resources/xsd/edt/MDClasses.xsd

This file was deleted.

57 changes: 0 additions & 57 deletions src/main/resources/xsd/original/DataBSL.xsd

This file was deleted.

Loading

0 comments on commit 4dec71b

Please sign in to comment.