[
https://issues.apache.org/jira/browse/IGNITE-2947?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15231963#comment-15231963
]
Anton Vinogradov commented on IGNITE-2947:
------------------------------------------
Improved test found that this case is not work for classes loaded by default
classloader in case user classloader set.
Written complex test and suggested solution idea (not work because marshaller
cache is not ready at node start)
https://github.com/apache/ignite/pull/620/commits/e398c18efe46ce7bf9fdd65442ea8ea75f47fc53
Fixed by Denis by spliting cacheTypes to store separately classes from user and
default classloader
https://github.com/apache/ignite/pull/620/commits/6383694a71d3bfd9f844615e44617d686bf7aaa7
Alexey also suggest another fix for my solution (
https://github.com/apache/ignite/pull/620/commits/e398c18efe46ce7bf9fdd65442ea8ea75f47fc53
)
"There is a 'registered' flag in BinaryClassDescriptor that is for some reason
set to true in the method that registers configuration-defined types. I believe
it should be changed to 'false' since class name is not registered in
marshaller context, then it would register the class name during the first
serialization. If I change it to 'false', deserialization starts to work in
your test, however it fails later on some assertion. Please take a look."
Going to check it.
> BinaryContext doesn't honor custom loader set through
> IgniteConfiguration.classLoader
> -------------------------------------------------------------------------------------
>
> Key: IGNITE-2947
> URL: https://issues.apache.org/jira/browse/IGNITE-2947
> Project: Ignite
> Issue Type: Bug
> Components: binary
> Affects Versions: 1.5.0.final
> Reporter: Denis Magda
> Assignee: Anton Vinogradov
> Priority: Critical
> Labels: community, important
> Fix For: 1.6
>
>
> If to register a specific object with {{BinaryTypeConfiguration}} setting its
> {{typeName}} and load Class of objects of this type using a custom class
> loader passed to {{IgniteConfiguration.classLoader}} then at
> {{BinaryContext}} initialization time the context will not properly register
> this {{BinaryTypeConfiguration}} because it doesn't suppose that the Class of
> the type can be loaded by the custom class loader
> In the code below {{Class.forName}} has to use
> {{IgniteConfiguration.classLoader}} if the latest is set and fall back to
> {{dfltLdr}} otherwise.
> {noformat}
> @SuppressWarnings("ErrorNotRethrown")
> public void registerUserType(String clsName,
> BinaryInternalMapper mapper,
> @Nullable BinarySerializer serializer,
> @Nullable String affKeyFieldName,
> boolean isEnum)
> throws BinaryObjectException {
> assert mapper != null;
> Class<?> cls = null;
> try {
> cls = Class.forName(clsName);
> }
> catch (ClassNotFoundException | NoClassDefFoundError ignored) {
> // No-op.
> }
> {noformat}
> Also there are several conditions in {{BinaryContext}} that are done for
> {{dfltLdr}}. The same conditions have to be executed for
> {{IgniteConfiguration.classLoader}}.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)