eclipse-platform/eclipse.platform.resources

Test TestBug316182.test02_startWorkspace() access the workspace while init

Closed this issue · 3 comments

The test extends RefreshProvider#installMonitor but instead of accessing the workspace via the provided resource it calls the static method that interferes with the startup of the workspace leading to:

java.lang.IllegalStateException: Workspace is already closed or not ready yet. Consider tracking the org.eclipse.core.resources.IWorkspace service (using your favorite technique, e.g. Declarative Services, ServiceTracker, Blueprint, ...) instead of calling the static method here to prevent such issues!
	at org.eclipse.core.resources.ResourcesPlugin.getWorkspace(ResourcesPlugin.java:423)
	at org.eclipse.core.tests.resources.refresh.Bug316182RefreshProvider.installMonitor(Bug316182RefreshProvider.java:27)
	at org.eclipse.core.resources.refresh.RefreshProvider.installMonitor(RefreshProvider.java:92)
	at org.eclipse.core.internal.refresh.MonitorManager.safeInstallMonitor(MonitorManager.java:261)
	at org.eclipse.core.internal.refresh.MonitorManager.monitor(MonitorManager.java:154)
	at org.eclipse.core.internal.refresh.MonitorManager.start(MonitorManager.java:279)
	at org.eclipse.core.internal.refresh.RefreshManager.manageAutoRefresh(RefreshManager.java:60)
	at org.eclipse.core.internal.refresh.RefreshManager.startup(RefreshManager.java:131)

Please read https://bugs.eclipse.org/bugs/show_bug.cgi?id=316182 , the execution in early startup seems intentional and the test does actually verify that this case is supported.

The bug is about calling Resource.getPersistentProperty() the failure here is due the call of ResourcesPlugin.getWorkspace() what is unnecessary in all cases if you have a resource as it has a Resource#getWorkspace() that is more appropriate in all cases.

OK, I see.