ignite-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ilya Kasnacheev (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (IGNITE-8547) Deserialization of Enum values as anonymous classes may cause deadlock
Date Mon, 21 May 2018 16:27:00 GMT

     [ https://issues.apache.org/jira/browse/IGNITE-8547?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Ilya Kasnacheev updated IGNITE-8547:
------------------------------------
    Description: 
Due to the following problem:
{code}
package jvmtest;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.BrokenBarrierException;
import java.util.concurrent.CyclicBarrier;

public class LegTypeTest {
    public static void main(String[] args) throws InterruptedException, BrokenBarrierException
{
        List<Thread> threadList = new ArrayList<>();

        CyclicBarrier b1 = new CyclicBarrier(16);
        CyclicBarrier b2 = new CyclicBarrier(17);

	    for (int i = 0; i < 16; i++) {
	        final int ii = i;
	        Thread thread = new Thread(() -> {
                try {
                    b1.await();

                    if (ii % 2 == 0)
                        Class.forName("jvmtest.LegTypeTest$E$1");

                    if (ii % 2 == 1)
                        Class.forName("jvmtest.LegTypeTest$E");

                    b2.await();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            });
	        thread.start();
	        threadList.add(thread);
        }

        b2.await();

        for (Thread thread : threadList) {
	        thread.join();
        }
    }

    private enum E {
        A("A"),
        B("B") {
            @Override
            public String virtual() {
                return null;
            }
        };

        private String displayString;

        E(String displayString) {
            this.displayString = displayString;
        }

        public String virtual() {
            return displayString;
        }
    }
}
{code}
When doing Class.forName on different enum values deadlock can be caused. And that's exactly
what OptimizedMarshaller does.

See also the attached test.

  was:
Due to the following problem:
{code}
package jvmtest;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.BrokenBarrierException;
import java.util.concurrent.CyclicBarrier;

public class LegTypeTest {
	public static void main(String[] args) throws InterruptedException, BrokenBarrierException
{
	    List<Thread> threadList = new ArrayList<>();

        CyclicBarrier b1 = new CyclicBarrier(16);
        CyclicBarrier b2 = new CyclicBarrier(17);

	    for (int i = 0; i < 16; i++) {
	        final int ii = i;
	        Thread thread = new Thread(() -> {
                try {
                    b1.await();

                    if (ii % 2 == 0)
                        Class.forName("jvmtest.LegTypeTest$E$1");

                    if (ii % 2 == 1)
                        Class.forName("jvmtest.LegTypeTest$E");

                    b2.await();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            });
	        thread.start();
	        threadList.add(thread);
        }

        b2.await();

        for (Thread thread : threadList) {
	        thread.join();
        }
    }

    private enum E {
        A("A"),
        B("B") {
            @Override
            public String virtual() {
                return null;
            }
        };

        private String displayString;

        E(String displayString) {
            this.displayString = displayString;
        }

        public String virtual() {
            return displayString;
        }
    }
}
{code}
When doing Class.forName on different enum values deadlock can be caused. And that's exactly
what OptimizedMarshaller does.

See also the attached test.


> Deserialization of Enum values as anonymous classes may cause deadlock
> ----------------------------------------------------------------------
>
>                 Key: IGNITE-8547
>                 URL: https://issues.apache.org/jira/browse/IGNITE-8547
>             Project: Ignite
>          Issue Type: Bug
>    Affects Versions: 1.9
>            Reporter: Ilya Kasnacheev
>            Assignee: Ilya Kasnacheev
>            Priority: Major
>         Attachments: MarshallerDeadlockMultiJvmTest.java
>
>
> Due to the following problem:
> {code}
> package jvmtest;
> import java.util.ArrayList;
> import java.util.List;
> import java.util.concurrent.BrokenBarrierException;
> import java.util.concurrent.CyclicBarrier;
> public class LegTypeTest {
>     public static void main(String[] args) throws InterruptedException, BrokenBarrierException
{
>         List<Thread> threadList = new ArrayList<>();
>         CyclicBarrier b1 = new CyclicBarrier(16);
>         CyclicBarrier b2 = new CyclicBarrier(17);
> 	    for (int i = 0; i < 16; i++) {
> 	        final int ii = i;
> 	        Thread thread = new Thread(() -> {
>                 try {
>                     b1.await();
>                     if (ii % 2 == 0)
>                         Class.forName("jvmtest.LegTypeTest$E$1");
>                     if (ii % 2 == 1)
>                         Class.forName("jvmtest.LegTypeTest$E");
>                     b2.await();
>                 } catch (Exception e) {
>                     e.printStackTrace();
>                 }
>             });
> 	        thread.start();
> 	        threadList.add(thread);
>         }
>         b2.await();
>         for (Thread thread : threadList) {
> 	        thread.join();
>         }
>     }
>     private enum E {
>         A("A"),
>         B("B") {
>             @Override
>             public String virtual() {
>                 return null;
>             }
>         };
>         private String displayString;
>         E(String displayString) {
>             this.displayString = displayString;
>         }
>         public String virtual() {
>             return displayString;
>         }
>     }
> }
> {code}
> When doing Class.forName on different enum values deadlock can be caused. And that's
exactly what OptimizedMarshaller does.
> See also the attached test.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message