You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ignite.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2017/09/20 20:44:00 UTC
[jira] [Commented] (IGNITE-3935) ClassLoaders are not switched
during object deserialization
[ https://issues.apache.org/jira/browse/IGNITE-3935?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16173799#comment-16173799 ]
ASF GitHub Bot commented on IGNITE-3935:
----------------------------------------
GitHub user knovik opened a pull request:
https://github.com/apache/ignite/pull/2708
IGNITE-3935 Test on deserialization from different nodes
ClassloaderSwitchSelfTest.java implements a test-case where class loaders should be switched to the peer-class-loading loader refering to IGNITE-3935 issue.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/knovik/ignite IGNITE-3935
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/ignite/pull/2708.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #2708
----
commit 107fff32693f18a73e9543bae9f496efd74cc6eb
Author: koctbik <ko...@bk.ru>
Date: 2017-09-19T15:00:38Z
IGNITE-3935 Testcase on class loader switching included in test suit CacheExamples
commit f7cd9116aab05c0e430ef5f5cd892b4a4b0f2a9e
Author: knovik <ko...@frtk.ru>
Date: 2017-09-20T20:29:25Z
This closes pull req
----
> ClassLoaders are not switched during object deserialization
> -----------------------------------------------------------
>
> Key: IGNITE-3935
> URL: https://issues.apache.org/jira/browse/IGNITE-3935
> Project: Ignite
> Issue Type: Bug
> Components: binary
> Affects Versions: 1.6
> Reporter: Denis Magda
>
> If an object is being deserialized with ClassLoader A then this ClassLoader A will be used for the deserialization of the whole object's state, i.e., including all its fields that can be custom objects loaded by ClassLoader B.
> In a basic scenario we can have an object of some Ignite class that is presented in the classpath. That Ignite class may enclose an object that is loaded by peer-class-loading class loader. The deserialization will fail because Ignite won't switch to the peer-class-loading loader when it's needed.
> To reproduce the issue do the following:
> 1. Start a remote ignite node using {{./ignite.sh ../examples/config/example-ignite.xml}}
> 2. Run the code below
> {code}
> public class StreamingExample {`
> public static class StreamingExampleCacheEntryProcessor implements CacheEntryProcessor<String, Long, Object> {
> @Override
> public Object process(MutableEntry<String, Long> e, Object... arg) throws EntryProcessorException {
> Long val = e.getValue();
> e.setValue(val == null ? 1L : val + 1);
> return null;
> }
> }
> public static void main(String[] args) throws IgniteException, IOException {
> Ignition.setClientMode(true);
> try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
> IgniteCache<String, Long> stmCache = ignite.getOrCreateCache("mycache");
> try (IgniteDataStreamer<String, Long> stmr = ignite.dataStreamer(stmCache.getName())) {
> stmr.allowOverwrite(true);
> stmr.receiver(StreamTransformer.from(new StreamingExampleCacheEntryProcessor()));
> stmr.addData("word", 1L);
> System.out.println("Finished");
> }
> }
> }
> {code}
> However if to modify this code to the following everything will work fine
> {code}
> public class StreamingExample {
> public static class StreamingExampleCacheEntryProcessor extends StreamTransformer<String, Long> {
> @Override
> public Object process(MutableEntry<String, Long> e, Object... arg) throws EntryProcessorException {
> System.out.println("Executed!");
> Long val = e.getValue();
> e.setValue(val == null ? 1L : val + 1);
> return null;
> }
> }
> public static void main(String[] args) throws IgniteException, IOException {
> Ignition.setClientMode(true);
> try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
> IgniteCache<String, Long> stmCache = ignite.getOrCreateCache("mycache");
> try (IgniteDataStreamer<String, Long> stmr = ignite.dataStreamer(stmCache.getName())) {
> stmr.allowOverwrite(true);
> stmr.receiver(new StreamingExampleCacheEntryProcessor());
> stmr.addData("word", 1L);
> System.out.println("Finished");
> }
> }
> }
> }
> {code}
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)