Author: max.andersen(a)jboss.com
Date: 2011-10-09 05:05:36 -0400 (Sun, 09 Oct 2011)
New Revision: 35502
Modified:
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/ShowJBossCentral.java
Log:
Removed NPE that were occurring because of getProfile apparently returning null
Modified:
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/ShowJBossCentral.java
===================================================================
---
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/ShowJBossCentral.java 2011-10-08
00:17:12 UTC (rev 35501)
+++
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/ShowJBossCentral.java 2011-10-09
09:05:36 UTC (rev 35502)
@@ -34,19 +34,28 @@
} else {
IProfile profile = profileRegistry
.getProfile(IProfileRegistry.SELF);
- String profileId = profile.getProfileId();
- IEclipsePreferences prefs = JBossCentralActivator.getDefault().getPreferences();
- String savedId = prefs.get(JBossCentralActivator.PROFILE_ID, null);
- if (savedId == null || !savedId.equals(profileId)) {
- prefs.put(JBossCentralActivator.PROFILE_ID, profileId);
- showJBossCentral = true;
+
+ if (profile != null) { // got NPE's when running in PDE
+ String profileId = profile.getProfileId();
+ IEclipsePreferences prefs = JBossCentralActivator.getDefault()
+ .getPreferences();
+ String savedId = prefs.get(JBossCentralActivator.PROFILE_ID,
+ null);
+ if (savedId == null || !savedId.equals(profileId)) {
+ prefs.put(JBossCentralActivator.PROFILE_ID, profileId);
+ showJBossCentral = true;
+ }
+ long timestamp = profile.getTimestamp();
+ long savedTimestamp = prefs.getLong(
+ JBossCentralActivator.PROFILE_TIMESTAMP, -1);
+ if (timestamp != savedTimestamp) {
+ prefs.putLong(JBossCentralActivator.PROFILE_TIMESTAMP,
+ timestamp);
+ showJBossCentral = true;
+ }
+ } else {
+ // TODO: Not sure what is supposed to happen here if profile doesn't exist ?
}
- long timestamp = profile.getTimestamp();
- long savedTimestamp = prefs.getLong(JBossCentralActivator.PROFILE_TIMESTAMP, -1);
- if (timestamp != savedTimestamp) {
- prefs.putLong(JBossCentralActivator.PROFILE_TIMESTAMP, timestamp);
- showJBossCentral = true;
- }
}
if (!showJBossCentral) {
return;