Bug 47458 - Manual updates are not detected at startup
Summary: Manual updates are not detected at startup
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Update (deprecated - use Eclipse>Equinox>p2) (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows XP
: P1 normal (vote)
Target Milestone: 3.0 M8   Edit
Assignee: Dorian Birsan CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 47842 (view as bug list)
Depends on:
Blocks:
 
Reported: 2003-11-25 13:48 EST by Dorian Birsan CLA
Modified: 2004-03-03 12:58 EST (History)
4 users (show)

See Also:


Attachments
feature to drop in the install to test the problem (12.10 KB, application/octet-stream)
2003-11-26 18:11 EST, Dorian Birsan CLA
no flags Details
Patching ConfigurationActivator (4.26 KB, patch)
2003-12-02 16:26 EST, Pascal Rapicault CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dorian Birsan CLA 2003-11-25 13:48:20 EST
RCP changes had a side effect on the update manager (I actually like the end 
result, but it is a regression):
- launch M5 and then shut it down.
- unzip a new feature into the features/ folder
- restart eclipse
- the old behavior: after the reconciler runs and detects the new feature, a 
dialog prompts the user to accept or reject the newly discovered feature
- the M5 behavior: nothing happens. You can still go to the 
Help>SoftwareUpdates>Manage Configuration, turn on disabled features filter 
and enable the unzipped feature.

It looks like IDEWorkbenchAdviser.checkUpdates() invokes this dialog 
(indirectly) by first checking if "-newUpdates" is on the command line. 
Somehow, this string is not present.
Comment 1 Brent Nicolle CLA 2003-11-25 17:45:31 EST
(Similar to bug47469.)
Comment 2 Dejan Glozic CLA 2003-11-25 18:03:48 EST
This is a note from Christophe Elek who wrote the original code:

<note>
I have to check the code in details but I believe the path is the following

PlatformConfiguration detect change on the file system (a new feature is a 
change, a new plug-in without a feature is not a change)
PlatformConfiguration calls the UpdateManager core and asks for reconciliation
Update Manager reconciles (the best it can :) and saves data in a file (the 
name escapes me)
UM shuts down
Startup catches the shutdown and restarts
PlatformConfiguration (I believe I will need to check) finds the file and 
calls -newUpdate

I will have to check the name of the file and the behavior of the last sentence
checking...

Ok, it is in PlatformConfiguration

private static final String CHANGES_MARKER = ".newupdates"; //$NON-NLS-1$

 private static String[] checkForNewUpdates(IPlatformConfiguration cfg, String
[] args) {
  try {
   URL markerURL = new URL(cfg.getConfigurationLocation(), CHANGES_MARKER);
   File marker = new File(markerURL.getFile());
   if (!marker.exists())
    return args;

   // indicate -newUpdates
   marker.delete();
   String[] newArgs = new String[args.length + 1];
   newArgs[0] = CMD_NEW_UPDATES;
   System.arraycopy(args, 0, newArgs, 1, args.length);
   return newArgs;
  } catch (MalformedURLException e) {
   return args;
  }
 }

Update Manager Reconciler does

 private void markChanges(IPlatformConfiguration cfg) {
  // indicate we have changes in restart scenario ... converted to -newUpdates 
on restart
  FileOutputStream fos = null;
  try {
   URL markerLocation = new URL(cfg.getConfigurationLocation(), 
CHANGES_MARKER);
   fos = new FileOutputStream(new File(markerLocation.getFile()));
   fos.write(0);
   fos.close();
  } catch (IOException e) {
   if (fos != null)
    try {
     fos.close();
    } catch (IOException e2) {
    }
  }
 }

So if the file is not generated, either PlatformConfiguration didn't pick up 
changes (you can trace the execution) or I didn't save any marker
If the file is created, maybe cfg.getConfigurationLocation() is not resolved 
properly
</note> 
Comment 3 Dorian Birsan CLA 2003-11-26 18:09:40 EST
It looks like update works as Chris describes, and the problem is in the 
InternalBootLoader class, likely caused by RCP changes.


I added my comments <db></db> in the code that seems to cause the problem:

/**
 * @see BootLoader
 */
public static String[] startup(URL pluginPathLocation/*R1.0 compatibility*/, 
String location, String[] args, Runnable handler) throws Exception {
	assertNotRunning();
	starting = true;
	commandLine = args;
	String[] applicationArgs = initialize(pluginPathLocation, location, 
args);
<db> at this point, applicationArgs[0] is "-newUpdates", which is correctly 
computed.
</db>
	Class platform = loader.loadClass(PLATFORM_ENTRYPOINT);
	Method method = platform.getDeclaredMethod("loaderStartup", new Class
[] { URL[].class, String.class, Properties.class, String[].class, 
Runnable.class }); //$NON-NLS-1$
	try {
		URL[] pluginPath = getCurrentPlatformConfiguration
().getPluginPath();
<db>
 when we call the loaderStartup, we don't pass applicationArgs 
 (that contain -newUpdates, but we pass args, and args does not 
  contain -newUpdates)
</db>
		method.invoke(platform, new Object[] { pluginPath, 
baseLocation, options, args, handler });
	} catch (InvocationTargetException e) {
		if (e.getTargetException() instanceof Error)
			throw (Error) e.getTargetException();
		else
			throw e;
	}
	// only record the platform as running if everything went swimmingly
	running = true;
	starting = false;
	return applicationArgs;


To see the scenario, run eclipse, shutdown.
Then drop a new feature in eclipse/features and then restart.
What happens is: during the first pass, update detects the new feature, 
creates eclipse/.config/.newupdates and restarts the platform.
Upon restart, .newupdates is detected, and -newUpdates is added on the list of 
arguments. As described above, this arguments are not actually used anywhere.

I will append a feature that you can use for testing.
Comment 4 Dorian Birsan CLA 2003-11-26 18:11:07 EST
Created attachment 6983 [details]
feature to drop in the install to test the problem
Comment 5 Dorian Birsan CLA 2003-12-01 16:19:15 EST
*** Bug 47842 has been marked as a duplicate of this bug. ***
Comment 6 Dorian Birsan CLA 2003-12-02 10:30:58 EST
We have another startup related bug (infinite startup loop after installing 
new features), that could be related to this bug, but can't tell for sure:
bug 47861.

What is the esitmate time for fixing this bug ?
Comment 7 Pascal Rapicault CLA 2003-12-02 16:26:21 EST
Created attachment 7038 [details]
Patching ConfigurationActivator
Comment 8 Pascal Rapicault CLA 2003-12-02 16:30:04 EST
decreasing priority as a patch has been submitted and is being released
Comment 9 Dorian Birsan CLA 2003-12-02 17:14:35 EST
The patch works only for bug 47842 but not for the problem described 
initially. See my original comments about where the problem seems to be 
located.
Comment 10 Pascal Rapicault CLA 2003-12-02 18:14:27 EST
It was the only case I was trying to fix.
The other problems seems to be related to the PlatformConfiguration object 
willing to run the reconciler.
Comment 11 Pascal Rapicault CLA 2003-12-08 15:00:25 EST
This is fixed in N20031208.
Closing.
Comment 12 Dorian Birsan CLA 2003-12-30 12:53:08 EST
Original problem still not solved:

RCP changes had a side effect on the update manager (I actually like the end 
result, but it is a regression):
- launch M5 and then shut it down.
- unzip a new feature into the features/ folder
- restart eclipse
- the old behavior: after the reconciler runs and detects the new feature, a 
dialog prompts the user to accept or reject the newly discovered feature
- the M5 behavior: nothing happens. You can still go to the 
Help>SoftwareUpdates>Manage Configuration, turn on disabled features filter 
and enable the unzipped feature.

It looks like IDEWorkbenchAdviser.checkUpdates() invokes this dialog 
(indirectly) by first checking if "-newUpdates" is on the command line. 
Somehow, this string is not present."

As far as I can tell, this is an RCP defect.
Comment 13 Pascal Rapicault CLA 2004-01-16 16:25:12 EST
As pointed earlier the problem comes both from the fact that  
PlatformConfiguration is invoked later than before and the way parameters are 
passed around in the new runtime.

In eclipse 2.1, PlatformConfiguration.startup was called really early by the 
InternalBootLoader and was modifying the content of the command line (for 
example adding the -newUpdate argument (see last method class in startup)). 
Therefore every caller higher on the chain were able to see this new parameter.

Now the PlatformConfiguration is called as a regular bundle 
(update.configurator) and by consequence once the system is up and running. At 
that time, it is impossible to change the command line args.

Basically PlatformConfiguration needs to find another way to indicate the -
newUpdate. One solution could be a system property.
Comment 14 Dorian Birsan CLA 2004-02-24 12:20:51 EST
In the latest integration build (0223) any new feature or plugin is 
automatically added to the configuration. 

The direction for installing updates is to have eclipse ship with a predefined 
configuration and install new features using the update manager UI or 
standalone commands. Unzipping features/plugins will still work, but is not 
what we encourage. There is some effort into getting better tooling for 
developing and deploying features, and to improve the installation process.
Comment 15 Dorian Birsan CLA 2004-03-03 12:58:40 EST
Fixed, as per comment #14. Use the latest 0303 integration build, for latest 
fixes.