Thread block on add appointment to PST


#1

Hi,
I see strange exception while running 15 threads that adding appointments to PSTs (each thread to it’s own PST) :
java.lang.Thread.State: BLOCKED (on object monitor)

at java.text.RuleBasedCollator.compare(RuleBasedCollator.java:356)

- waiting to lock <0x00000001a8784178> (a java.text.RuleBasedCollator)

at com.aspose.email.internal.k.a.b(Unknown Source)

at com.aspose.email.internal.k.a.a(Unknown Source)

at com.aspose.email.internal.b.an.c(Unknown Source)

at com.aspose.email.avx.b(SourceFile:49)

at com.aspose.email.ayl.a(SourceFile:554)

at com.aspose.email.ayl.a(SourceFile:486)

at com.aspose.email.ayl.b(SourceFile:524)

at com.aspose.email.Appointment.a(SourceFile:1680)

at com.aspose.email.Appointment.a(SourceFile:1552)

at com.aspose.email.Appointment.b(SourceFile:1443)

	at com.aspose.email.Appointment.load(SourceFile:1458)

Please advise.

Thanks


com.aspose.email.system.exceptions.ArgumentOutOfRangeException: Specified argument was out of the range of valid values
#2

@slavago,

I have tried to re-produce the issue using following code where 100 threads adding 100 appointments to individual PST. No such issue is observed and all the 100 threads complete successfully. You may please give it a try and share the feedback.

package com.company;

import com.aspose.email.*;
import com.aspose.email.system.DateTime;


import java.util.Date;
import java.util.GregorianCalendar;
import java.util.TimeZone;

class RunnableDemo implements Runnable
{
    private Thread t;
    private String threadName;
    private PersonalStorage pst;
    RunnableDemo( String name, PersonalStorage ArgPst)
    {
        threadName = name;
        System.out.println("Creating " +  threadName );
        pst = ArgPst;
    }

    public void run()
    {
        System.out.println("Running " +  threadName );
        try
        {
            FolderInfo f_FolderInfoObj = pst.createPredefinedFolder("Cal1", StandardIpmFolder.Appointments);
            for(int i = 100; i > 0; i--)
            {
                System.out.println("Thread: " + threadName + ", " + "Appointment # " + i);
                String sender = "test@gmail.com";
                String recipient = "test@email.com";

                MailMessage message = new MailMessage(sender, recipient, "", "");

                Date startDate = null;
                java.util.Calendar cal = GregorianCalendar.getInstance();
                cal.set(2017, 10, 2);
                startDate = cal.getTime();

                Date endDate = null;
                cal = GregorianCalendar.getInstance();
                cal.set(2017, 10, 3);
                endDate = cal.getTime();
                MailAddressCollection attendees = new MailAddressCollection();
                attendees.addMailAddress(new MailAddress("attendee_address@aspose.com", "Attendee"));
                Appointment app = new Appointment("", startDate, endDate, new MailAddress("organizer_address@aspose.com", "Organizer"), attendees);
                app.setMethod(AppointmentMethodType.Publish);
                message.addAlternateView(app.requestApointment());
                MapiMessage msg = MapiMessage.fromMailMessage(message);
                MapiCalendar MapiCal = (MapiCalendar)msg.toMapiMessageItem();
                f_FolderInfoObj.addMapiMessageItem(MapiCal);
                // Let the thread sleep for a while.
                Thread.sleep(50);
            }
            pst.dispose();
        }
        catch (InterruptedException e)
        {
            System.out.println("Thread " +  threadName + " interrupted.");
        }
        System.out.println("Thread " +  threadName + " exiting.");
    }

    public void start ()
    {
        System.out.println("Starting " +  threadName );
        if (t == null)
        {
            t = new Thread (this, threadName);
            t.start ();
        }
    }
}

//https://forum.aspose.com/t/thread-block-on-add-appointment-to-pst/171295

public class Main
{
    public static void main(String[] args)
    {
        for(int i = 1; i < 100; i ++)
        {
            PersonalStorage pst = PersonalStorage.create("PST-" + i + ".pst", FileFormatVersion.Unicode);
            RunnableDemo R1 = new RunnableDemo( "PST-" + i + ".pst", pst);
            R1.start();
        }
    }
}

#3

The sample is working fine, but maybe it’s somehow related to content, but this is very dificult to reproduce.


#4

@slavago,

Thank you for providing the feedback. It is must required to re-produce issue here. Please provide us a simple console application containing only Aspose related code, which can be compiled and executed here without any missing references. Also provide the sample data which can be used for observing the issue. It will help us to analyze the problem and provide assistance accordingly.