rgrunber

Testing p2 the easy way, and the hard way

So you want to debug changes you’re making to p2 by launching in a child Eclipse process. Simple enough. If it works for other plugins, why not p2 ? Turns out, it can be a little tricky.

In my case I wanted to test out a shared installation while looking at what was going on in the SimpleProfileRegistry (methods like getProfile, containsProfile, and createSurrogateProfile).

Here’s what I needed to do in order to get that working :

In addition to the generated config.ini, I needed the following attributes set.

eclipse.p2.data.area=@config.dir/.p2
osgi.sharedConfiguration.area=file\:/usr/lib64/eclipse/configuration

(Note: Default p2 data area is defined in LaunchConfigurationHelper of org.eclipse.pde.launching)

PDE has its own special way of setting up the configuration for a child Eclipse, so you’ll need to copy over the folder of your shared profile as SelfHostingProfile.profile and rename all IDs in the profiles accordingly . After failing countless times to get the child Eclipse to detect the SDKProfile.profile, I realized PDE always looks for a profile ID of SelfHostingProfile.

(Note: Default profile ID is defined in LaunchConfigurationHelper of org.eclipse.pde.launching)

It turns out containsProfile is a very popular method. There’s a separate thread that begins setting up profile preferences using the ProfilePreferences class. This ends up calling the synchronized method, containsProfile, and ultimately blocks because p2’s AutomaticUpdateSchedueler has already entered it. From within containsProfile, we end up calling setupRepos as well to set up the metadata repositories. As you might imagine, this ends up calling ProfilePreferences and blocks on entering the preference node because the other thread is in there. Now we have a deadlock.

Solution : You need to insert a breakpoint just before the containsProfile call to avoid a deadlock between the ProfilePreferences job and the p2’s AutomaticUpdateScheduler job. Let the ProfilePreferences thread continue before proceeding into the AutomaticUpdateScheduler’s call to containsProfile.

If all the above is too much of a giant pain (I found it kind of fun), you can always just run the p2 Tests, to hopefully take some solace in the fact that you (probably) haven’t broken anything.

mvn -Declipse-sdk-repo.url=http://download.eclipse.org/eclipse/updates/4.4-I-builds -Dmaven.test.skip=false clean verify

EclipseCon NA 2014

As I was working on some upcoming blog posts, I realized I’d completely forgotten to mention EclipseCon!┬áIt’s always nice to put a name to a face, and meet in person to discuss things. I gave a talk on Delivering Native Eclipse Software Packages , but this was mainly an opportunity to introduce the p2 Droplets work that was done by Krzysztof Daniel. This will be part of Eclipse Luna (4.4) but there’s still some improvements that could be made. It’s really a promising way forward for allowing distributions to package, and install their own Eclipse plugins without the deprecated (and unreliable) dropins approach.

Zombie Drive

I had a hard disk fail a while ago after about 2 years of use. It wasn’t even being detected as a physical device. It wasn’t that big of a deal as everything was backed up, but I was curious if there was any way to access it once again. I heard a suggestion from a colleague to try freezing the disk in the hopes of getting a last chance to access the data.

Solution : I placed the drive in a ziplock bag, and placed that bag into a larger plastic bag (I couldn’t find another ziplock bag). I left that in the fridge for about 3 hours. I then removed the drive from the bags and reconnected it. The first few times, it failed. Given that it was likely dead, a colleague decided to give it a few bashes (I believe the technical term is ‘kickstarts’). I don’t know if it was the freezing, or just the bashing but the combination allowed me to boot from the disk.

I did not expect that to work.

I tried booting from the drive a few days later, and it also seemed to work. I haven’t connected that drive back in a while, and it may indeed be back to normal but I wouldn’t trust it with anything.

Follow

Get every new post delivered to your Inbox.