Ankh25-zz / cassia

Automatically exported from code.google.com/p/cassia
0 stars 0 forks source link

GetSession should return null when the session does not exist #62

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
If I call the GetSession method (in class TerminalServicesServer) with an 
invalid session as argument, the return value is a TerminalServicesSession. If 
I try to retrieve the value of a property, an exception is thrown.

Please change your code that this method returns null or throws an exception if 
the session does not exist.

Cassia Version: latest (2.0.0.60)

Original issue reported on code.google.com by surf...@gmail.com on 13 Sep 2012 at 2:12

GoogleCodeExporter commented 9 years ago
I can see how this might be confusing. Most of the session properties are lazy 
loaded, which is where this originates, though it's rarely a problem when 
GetSessions() is called. How are you using GetSession() in your app? (Or, how 
would a solution to this make your life easier?)

Original comment by danports on 14 Sep 2012 at 2:51

GoogleCodeExporter commented 9 years ago
I see, the lazy loading is causing the problem.

I use Cassia in the following situation:
The ServiceBase class provides methods to receive session notification events. 
When a sessionlogoff event or a remote disconnect event is received it may be 
possible that the session is at this point already gone. Especially when the 
server is under heavy load the event gets called too late and then I get an 
exception when I try to retrieve information about the session using Cassia.

However, there is no sense in returning an instance of a 
TerminalServicesSession when there is no session at all!

Original comment by surf...@gmail.com on 14 Sep 2012 at 8:21