static variable and step by step execution

Hello.
We have coded a java service that uses this static variable (in the “shared” section):

public static final ThreadLocal thSession = new ThreadLocal();

This variable contains a HashMap in which we may add, delete, retrieve objects, etc.

If we launch a service which uses this methods, it works perfectly, but if we launch this service in step by step mode, sometimes the flow behaves as if the thSession variable wasn’t initialized, therefore we lose elements we have added to the object associated with the ThreadLocal object.

Are we supposed to lose static variable in a step by step execution? Is there a way to work around this?

I think there is a new/different thread for each step. I’m not privvy to the inner workings of the debugger and the Developer/IS interaction while stepping but I believe each step will be executed on the server potentially using a different thread from the thread pool for each step.

Thus, I think that the thSession var is fine but since each step uses a different thread it appears that the vars you stored are gone–but they are really there, just associated with a different thread.

An alternative approach, if you feel you need to store vars in such a manner (if you care to elaborate on what you’re doing it might be helpful) then you might consider storing them within the IS session instead, which would survive stepping.

OK, this would explain that…
Our idea was to be able to save dynamic lists in the services.
I’m not sure of the necessity of this manner of doing, but I can’t replace it completely, I just wondered if there was a quick and easy-to-install workaround.
I’ll check this IS session thing
Thanks for the tip!

Do you clear the vars from the thSession var when a particular service is complete? If not, it would seem that you might cross-contaminate things when a particular thread is reused for a later service invocation.

What are you storing in thSession and why?