Skip to content

Thread contention on Converters.PROPERTY_EDITOR  #254

@raulcaj

Description

@raulcaj

Hi!

There is a problem of thread contention on the PropertyEditorManager.findEditor. It loads classes from the ClassLoader switch is a thread blocking operation.

Is it possible to cache this method result so it wouldn't be called again or it would break this functionality somehow?

It would go something like this:

			@Override
			Object tryConvert(Method targetMethod, Class<?> targetType, String text) {
				if (!canUsePropertyEditors())
					return SKIP;
				PropertyEditor editor = PROPERTY_BY_CLASS.get(targetType);
				if (editor == null) {
					editor = PropertyEditorManager.findEditor(targetType);
					if (editor != null)
						PROPERTY_BY_CLASS.put(targetType, editor);
				}
				if (editor == null)
					return SKIP;
				try {
					editor.setAsText(text);
					return editor.getValue();
				} catch (Exception e) {
					throw unsupportedConversion(e, targetType, text);
				}
			}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions