Bug 294497 NPE thrown when switching between populated and empty albums
1. Run the photo demo. 2. Select an album with pictures in it. 3. Select the 'Exif' part. 4. Select an entry in the table. 5. Select an empty album. 6. An NPE is thrown. java.lang.NullPointerException at java.util.Hashtable.put(Unknown Source) at org.eclipse.e4.ui.services.internal.events.EventBroker.constructEvent(EventBroker.java:91) at org.eclipse.e4.ui.services.internal.events.EventBroker.post(EventBroker.java:72) at org.eclipse.e4.demo.e4photo.ExifTable$2.selectionChanged(ExifTable.java:161) at org.eclipse.jface.viewers.Viewer$2.run(Viewer.java:162) at org.eclipse.jface.util.SafeRunnable$1.run(SafeRunnable.java:128) at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:175) at org.eclipse.jface.viewers.Viewer.fireSelectionChanged(Viewer.java:160) at org.eclipse.jface.viewers.StructuredViewer.updateSelection(StructuredViewer.java:2132) at org.eclipse.jface.viewers.TableViewer.remove(TableViewer.java:417) at org.eclipse.jface.viewers.AbstractTableViewer.remove(AbstractTableViewer.java:856) at org.eclipse.jface.internal.databinding.viewers.TableViewerUpdater.remove(TableViewerUpdater.java:36) at org.eclipse.jface.databinding.viewers.ObservableListContentProvider$2.handleRemove(ObservableListContentProvider.java:124) at org.eclipse.core.databinding.observable.list.ListDiff.accept(ListDiff.java:137) at org.eclipse.jface.databinding.viewers.ObservableListContentProvider$Impl.handleListChange(ObservableListContentProvider.java:118) at org.eclipse.core.databinding.observable.list.ListChangeEvent.dispatch(ListChangeEvent.java:61) at org.eclipse.core.databinding.observable.ChangeManager.fireEvent(ChangeManager.java:119) at org.eclipse.core.databinding.observable.list.ObservableList.fireListChange(ObservableList.java:73) at org.eclipse.core.databinding.observable.list.WritableList.clear(WritableList.java:269) at org.eclipse.e4.demo.e4photo.ExifTable.setSelection(ExifTable.java:81) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.eclipse.e4.core.services.internal.context.ContextInjector.callMethod(ContextInjector.java:561) at org.eclipse.e4.core.services.internal.context.ContextInjector.access$2(ContextInjector.java:538) at org.eclipse.e4.core.services.internal.context.ContextInjector$Processor.processMethod(ContextInjector.java:108) at org.eclipse.e4.core.services.internal.context.ContextInjector.processMethods(ContextInjector.java:376) at org.eclipse.e4.core.services.internal.context.ContextInjector.processClass(ContextInjector.java:319) at org.eclipse.e4.core.services.internal.context.ContextInjector.processClassHierarchy(ContextInjector.java:335) at org.eclipse.e4.core.services.internal.context.ContextInjector.inject(ContextInjector.java:211) at org.eclipse.e4.core.services.internal.context.ContextToObjectLink.handleAdd(ContextToObjectLink.java:59) at org.eclipse.e4.core.services.internal.context.ContextToObjectLink.notify(ContextToObjectLink.java:152) at org.eclipse.e4.core.services.internal.context.EclipseContext$TrackableComputationExt.notify(EclipseContext.java:197) at org.eclipse.e4.workbench.ui.internal.UISchedulerStrategy$1.run(UISchedulerStrategy.java:40) at org.eclipse.core.databinding.observable.Realm$1.run(Realm.java:148) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) at org.eclipse.core.databinding.observable.Realm.safeRun(Realm.java:152) at org.eclipse.jface.databinding.swt.SWTObservables$DisplayRealm.access$0(SWTObservables.java:1) at org.eclipse.jface.databinding.swt.SWTObservables$1.run(SWTObservables.java:502) at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:134) at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3892)
bundles/org.eclipse.e4.ui.services/src/org/eclipse/e4/ui/services/internal/events/EventBroker.java
private Map<EventHandler, ServiceRegistration> registrations = new HashMap<EventHandler, ServiceRegistration>();
	
	
	
	
	static {
		EventAdmin eventAdmin = Activator.getDefault().getEventAdmin();
		if (eventAdmin == null) {
			Bundle[] bundles = Activator.getDefault().getBundleContext().getBundles();
			for (Bundle bundle : bundles) {
				if (!"org.eclipse.equinox.event".equals(bundle.getSymbolicName()))
					continue;
				try {
					bundle.start(Bundle.START_TRANSIENT);
				} catch (BundleException e) {
					e.printStackTrace();
				}
				break;
			}
		}
	}
	
	public EventBroker() {
		
	}
	public boolean send(String topic, Object data) {
		Event event = constructEvent(topic, data);
		EventAdmin eventAdmin = Activator.getDefault().getEventAdmin();
		if (eventAdmin == null) {