Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Equinox » [security] NullPointerException when calling ISecurePreferences.get() from splash
[security] NullPointerException when calling ISecurePreferences.get() from splash [message #534034] Mon, 17 May 2010 19:10 Go to next message
Christophe Fondacci is currently offline Christophe FondacciFriend
Messages: 95
Registered: July 2009
Location: Paris
Member
Hello all,

I am facing a strange error.
First of all, it happened to work before... but it is not working anymore.

Here is what I am doing :
* Got an RCP app
* The product start with a splash screen (no workbench initialized)
* In this splash, I need to go in the ISecurePreferences to fetch a password from there

Here is the code which raise the problem :
	final ISecurePreferences root = SecurePreferencesFactory.getDefault();
	final ISecurePreferences connectionNode = root.node("repository/connection"); //$NON-NLS-1$
	String password = null;
	try {
		password = connectionNode.get(DesignerCoreConstants.REP_PASSWORD_PROPERTY, null);
	} catch (StorageException e) {
		throw new ErrorException(CoreMessages
				.getString("connection.editor.passwordStorageError"), e); //$NON-NLS-1$
	}


In my context, the section connectionNode.get(...) raises a null pointer exception in Workbench.getWorkbenchWindows(). Indeed, the workbench is not yet initialized, but the JavaEncryption class seems to use UICallbacks to synchronize some calls in the UI thread...

You can find below the complete stack trace of the error...
The important thing is the exact same code worked before. It does not work anymore since I removed my workspace folder (and so I am now working on a brand new one).

I am working on MacOSX with SWT Cocoa 64 bits. Equinox security is release 1.0.100.v20090520-1800. The same code running on windows 64 bits platform works well, even with the same workspace manipulation

Tried antoher thing : removed the workspace, removed the .eclipse and .eclipse_keyring in my home dir (by the way, they don't come back). Now got a very similar problem on the put method... The stack trace below corresponds to this put() call.

I am not able to restore a working configuration anymore. I am out of ideas. Is there anyone who can help me with this problem ? Anything I am doing wrong ?

Thank you very much for any help,
Christophe.
http://www.nextep-softwares.com

Caused by: java.lang.NullPointerException
	at org.eclipse.ui.internal.Workbench.getWorkbenchWindows(Workbench.java:1270)
	at org.eclipse.ui.internal.progress.ProgressManagerUtil.getNonModalShell(ProgressManagerUtil.java:356)
	at org.eclipse.ui.internal.progress.ProgressManagerUtil.getDefaultParent(ProgressManagerUtil.java:343)
	at org.eclipse.ui.internal.progress.ProgressManager.busyCursorWhile(ProgressManager.java:956)
	at org.eclipse.equinox.internal.security.ui.storage.UICallbackProvider$2.run(UICallbackProvider.java:95)
	at org.eclipse.swt.widgets.Synchronizer.syncExec(Synchronizer.java:179)
	at org.eclipse.ui.internal.UISynchronizer.syncExec(UISynchronizer.java:150)
	at org.eclipse.swt.widgets.Display.syncExec(Display.java:3945)
	at org.eclipse.equinox.internal.security.ui.storage.UICallbackProvider.execute(UICallbackProvider.java:90)
	at org.eclipse.equinox.internal.security.storage.JavaEncryption.init(JavaEncryption.java:88)
	at org.eclipse.equinox.internal.security.storage.JavaEncryption.encrypt(JavaEncryption.java:131)
	at org.eclipse.equinox.internal.security.storage.SecurePreferencesRoot.getModulePassword(SecurePreferencesRoot.java:260)
	at org.eclipse.equinox.internal.security.storage.SecurePreferencesRoot.getPassword(SecurePreferencesRoot.java:219)
	at org.eclipse.equinox.internal.security.storage.SecurePreferences.put(SecurePreferences.java:224)
	at org.eclipse.equinox.internal.security.storage.SecurePreferencesWrapper.put(SecurePreferencesWrapper.java:110)
	at com.nextep.designer.services.impl.RepositoryService.setRepositoryConnection(RepositoryService.java:231)
	... 28 more

Re: [security] NullPointerException when calling ISecurePreferences.get() from splash [message #534734 is a reply to message #534034] Thu, 20 May 2010 08:07 Go to previous messageGo to next message
Christophe Fondacci is currently offline Christophe FondacciFriend
Messages: 95
Registered: July 2009
Location: Paris
Member
A summary in short : It seems not safe to use equinox security during startup in a splash screen ! If anybody has best practises on how to achieve this, it would help me very much.
The thing is : some platforms seem to be OK (like windows), some are not (like Mac). And it definitely has something to do with UI synchronization.


A few steps forward, here is what I did :
1- Reinitialized everything (removed workspace and .eclipse folders)
2- The NullPointerException disappeared because there was no more entry in the secured store so the default value was immediately returned
3- During the put() call on the secured store : had a problem on a neverending loop due to UI synchronization made by JavaEncryption init method because of its use of UICallback.


The thing is :
* it seems to work well on Windows platforms.
* it hangs on Mac platform
(don't know on Linux)

After deep debugging in the internal classes, it seems to be a Display.sync problem: the UICallback go through a ModalContext which spawns a ModalContextThread. Though, we are no longer on the "startupThread" which has "synchronization privileges" and that was this thread which made Display.syncExec, thus causing a neverending wait (because sync and async events from anything outside the startup thread seems to be delayed).

The only solution to this hang was to set the org.eclipse.ui.internal.IPreferenceConstants.USE_32_THREADIN G to avoid postponing synchronized events (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=219913)


And it worked! No more neverending loop, but guess what now ? I'm having this NullPointerException again (see stack).
I do not understand why the get and put from the secure store have 2 different ways of synchronizing with the UI thread through UICallbacks.


java.lang.NullPointerException
	at org.eclipse.ui.internal.Workbench.getWorkbenchWindows(Workbench.java:1270)
	at org.eclipse.ui.internal.progress.ProgressManagerUtil.getNonModalShell(ProgressManagerUtil.java:356)
	at org.eclipse.ui.internal.progress.ProgressManagerUtil.getDefaultParent(ProgressManagerUtil.java:343)
	at org.eclipse.ui.internal.progress.ProgressManager.busyCursorWhile(ProgressManager.java:956)
	at org.eclipse.equinox.internal.security.ui.storage.UICallbackProvider$2.run(UICallbackProvider.java:95)
	at org.eclipse.swt.widgets.Synchronizer.syncExec(Synchronizer.java:179)
	at org.eclipse.ui.internal.UISynchronizer.syncExec(UISynchronizer.java:150)
	at org.eclipse.swt.widgets.Display.syncExec(Display.java:3945)
	at org.eclipse.equinox.internal.security.ui.storage.UICallbackProvider.execute(UICallbackProvider.java:90)
	at org.eclipse.equinox.internal.security.storage.JavaEncryption.init(JavaEncryption.java:88)
	at org.eclipse.equinox.internal.security.storage.JavaEncryption.decrypt(JavaEncryption.java:175)
	at org.eclipse.equinox.internal.security.storage.SecurePreferencesRoot.getModulePassword(SecurePreferencesRoot.java:271)
	at org.eclipse.equinox.internal.security.storage.SecurePreferencesRoot.getPassword(SecurePreferencesRoot.java:219)
	at org.eclipse.equinox.internal.security.storage.SecurePreferences.get(SecurePreferences.java:262)
	at org.eclipse.equinox.internal.security.storage.SecurePreferencesWrapper.get(SecurePreferencesWrapper.java:106)
	at com.nextep.designer.services.impl.RepositoryService.getRepositoryConnection(RepositoryService.java:187)
	at com.nextep.designer.ui.services.impl.RepositoryUIService.getRepositoryConnection(RepositoryUIService.java:47)
	at com.nextep.designer.ui.services.impl.RepositoryUIService.getRepositoryConnector(RepositoryUIService.java:79)
	at com.nextep.datadesigner.vcs.gui.dialog.UserLoginGUI.refreshGUI(UserLoginGUI.java:183)
	at com.nextep.datadesigner.vcs.gui.dialog.UserLoginGUI.initializeGUI(UserLoginGUI.java:175)
	at com.nextep.designer.splashHandlers.InteractiveSplashHandler.init(InteractiveSplashHandler.java:78)
	at org.eclipse.ui.internal.Workbench$6.run(Workbench.java:606)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.ui.internal.Workbench.createSplashWrapper(Workbench.java:622)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2250)
	at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2221)
	at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:500)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:493)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at com.nextep.designer.Application.start(Application.java:42)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:194)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:368)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:559)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:514)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1311)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1287)



If anyone could help that would really help me a lot.
Christophe.
http://www.nextep-softwares.com
Re: [security] NullPointerException when calling ISecurePreferences.get() from splash [message #534743 is a reply to message #534034] Thu, 20 May 2010 08:30 Go to previous messageGo to next message
Christophe Fondacci is currently offline Christophe FondacciFriend
Messages: 95
Registered: July 2009
Location: Paris
Member
Second workaround :
The incriminated code is in the UICallbackProvider.execute() method :
	IProgressService progressService = PlatformUI.getWorkbench().getProgressService();
	InitWithProgress task = new InitWithProgress(callback);
	try {
		progressService.busyCursorWhile(task);
	} catch (InvocationTargetException e) {
		...
	}


This code is not compatible with the splash screen as it end up calling workbench.getWindows() which fires a NullPointerException before workbench init.

The thing is that this section is only called when calling from the UI thread. A non-UI thread uses a Job instead of the progress service. So my second workaround is to execute my call to :
secureStore.get(myKey,"")

from a dedicated thread.

=> That works.

But, in the end, I got 2 workarounds to make equinox security usable safely from a splash screen startup context :
* the use 3.2 thread compatibility to prevent synchronization from being delayed
* A thread fork to call a securedStore.get method

I think I should file a bug for this, but is there any equinox guys here who could send feedbacks on this use case ?

Thanks,
Christophe
http://www.nextep-softwares.com
Re: [security] [message #535747 is a reply to message #534743] Tue, 25 May 2010 13:24 Go to previous messageGo to next message
Oleg Besedin is currently offline Oleg BesedinFriend
Messages: 41
Registered: July 2009
Member
Hi Christophe,
Could you open a bug against Equinox/Security with a code sample and your
findings? This is an important use case and it would be good to have an
example of it added somewhere.

(I won't have much time to spend on it until late summer, but having your
findings will certainly help.)

Sincerely,
Oleg Besedin


"Christophe Fondacci" <christophefondacci@hotmail.com> wrote in message
news:ht2rvj$862$1@build.eclipse.org...
> Second workaround :
> The incriminated code is in the UICallbackProvider.execute() method :
>
> IProgressService progressService =
> PlatformUI.getWorkbench().getProgressService();
> InitWithProgress task = new InitWithProgress(callback);
> try {
> progressService.busyCursorWhile(task);
> } catch (InvocationTargetException e) {
> ...
> }
>
>
> This code is not compatible with the splash screen as it end up calling
> workbench.getWindows() which fires a NullPointerException before workbench
> init.
>
> The thing is that this section is only called when calling from the UI
> thread. A non-UI thread uses a Job instead of the progress service. So my
> second workaround is to execute my call to :
>
> secureStore.get(myKey,"")
>
> from a dedicated thread.
>
> => That works.
>
> But, in the end, I got 2 workarounds to make equinox security usable
> safely from a splash screen startup context :
> * the use 3.2 thread compatibility to prevent synchronization from being
> delayed
> * A thread fork to call a securedStore.get method
> I think I should file a bug for this, but is there any equinox guys here
> who could send feedbacks on this use case ?
>
> Thanks,
> Christophe
> http://www.nextep-softwares.com
>
Re: [security] [message #535872 is a reply to message #535747] Wed, 26 May 2010 07:24 Go to previous message
Christophe Fondacci is currently offline Christophe FondacciFriend
Messages: 95
Registered: July 2009
Location: Paris
Member
Sure, no problem, I will open a bug at the end of the week which will detail the problems listed above and the solutions I found.

Thanks for your feedback.

Christophe
http://www.nextep-softwares.com
Previous Topic:P2 flags a missing dependency that doesn't seem to be missing
Next Topic:Updating bundles with active DS components
Goto Forum:
  


Current Time: Thu Apr 25 13:24:59 GMT 2024

Powered by FUDForum. Page generated in 0.03156 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top