How can I safely use the Eclipse p2 profile?

I am encountering some problems when trying to update Eclipse plugins when starting Eclipse. My program opens a dialog box Help -> Check for Updateswhen starting Eclipse. But when the user quickly performs the update, Eclipse throws an exception saying that the p2 profile is being used. I believe this is because other Eclipse jobs use the p2 profile at startup, so my program cannot use the p2 profile to update plugins. How can I use p2 profile safely? How can I use p2 profile in isolation?

I downloaded the minimal piece of code needed to reproduce the problem on github . And I described the problem and the steps to reproduce it in detail in the problem in the github repository .

+3
source share
2 answers

You can get ProvisioningJobfrom yours UpdateOperationthat it belongs to the family of running profile change tasks. See org.eclipse.core.runtime.jobs.Job.belongsTo(Object).

In addition, I have two ideas to do this using the internal API,

  • try checking the profile lock to see if it will be changed. org.eclipse.equinox.internal.p2.engine.SimpleProfileRegistry.lockProfile(Profile)
  • run yours as before, but catch an IlegalStateException, then log ProvisioningListenerin IProvisioningEventBusto receive notification of the completion of the current changechange.
0

My commit " ", "org.eclipse.equinox.p2.ui.sdk.update" .

org.eclipse.equinox.p2.ui.ProvisioningUI.openUpdateWizard(boolean, UpdateOperation, LoadMetadataRepositoryJob)

, , -, p2. - , ?

0

All Articles