Skip to main content

[1.1.4] Should the Stack switch to Application Context when reporting a HN operation complete?

2 replies [Last post]
howardteece
Offline
Joined: 2010-06-17
Points: 0

There seems to be some asymmetery in the way requests are dispatched to a HN server and the response sent back to the client. That is, if an application attempts to set a value on a server we can get either a Null Pointer Exception, or if we code around that an Access Control Exception as the context trying to manipulate a service context is not that which previously created it.
It's hard to reproduce the problem, but here's a textual walk through.
The app calls,. for example,

RecordingContentItem[Impl].requestSetMediaTime(new Time(0), this);

This in turn creates an ActionRequest which is then processed by
Client.getInstance().doAction(iAction, request);

This purposely jumps to the System Context before calling doTask() on a newly created ActionRequest.
Once the post() is complete the registered Stack listener is called [still in the System Context] and it then reports the response to Application listener, but still in the System Context.
At this point, if the Application decides to do anything, it's in the wrong context and so chaos can ensue. [What this application does is select the existing service based on the returned mediaTime, but it no longer owns the context...]
In recording.ActionRequest.notifyEvent(...) there is a deliberate avoidance of a context switch:
super.prepareNotify(e);

/* Notify the completion of the action */

super.handler.notify((NetActionEvent) new NetActionEventImpl(this, null, super.error, super.actionStatus));

If we were to call super.notify() here, then the context would be switched.
This is only in 1.1.4, the way Action/Response is performed in 1.2 seems to have fixed this issue.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
greg80303
Offline
Joined: 2008-07-03
Points: 0

The short answer is that no application code should ever be executed on anything except that application's context (thread). If application code is being called on the system context, please create a bug.

G

howardteece
Offline
Joined: 2010-06-17
Points: 0

Blocker Issue Tracker has been raised.

http://java.net/jira/browse/OCAP_RI-533

Thanks.

Howard.