View | Details | Raw Unified | Return to bug 244849 | Differences between
and this patch

Collapse All | Expand All

(-)model/org/eclipse/jdt/internal/core/DeltaProcessor.java (-1 / +3 lines)
Lines 1013-1020 Link Here
1013
		if (elementType == IJavaElement.JAVA_PROJECT) {
1013
		if (elementType == IJavaElement.JAVA_PROJECT) {
1014
			// project add is handled by JavaProject.configure() because
1014
			// project add is handled by JavaProject.configure() because
1015
			// when a project is created, it does not yet have a java nature
1015
			// when a project is created, it does not yet have a java nature
1016
			if (delta != null && JavaProject.hasJavaNature((IProject)delta.getResource())) {
1016
			IProject project;
1017
			if (delta != null && JavaProject.hasJavaNature(project = (IProject)delta.getResource())) {
1017
				addToParentInfo(element);
1018
				addToParentInfo(element);
1019
				this.manager.getPerProjectInfo(project, false /* don't create info */).rememberExternalLibTimestamps();
1018
				if ((delta.getFlags() & IResourceDelta.MOVED_FROM) != 0) {
1020
				if ((delta.getFlags() & IResourceDelta.MOVED_FROM) != 0) {
1019
					Openable movedFromElement = (Openable)element.getJavaModel().getJavaProject(delta.getMovedFromPath().lastSegment());
1021
					Openable movedFromElement = (Openable)element.getJavaModel().getJavaProject(delta.getMovedFromPath().lastSegment());
1020
					currentDelta().movedTo(element, movedFromElement);
1022
					currentDelta().movedTo(element, movedFromElement);
(-)model/org/eclipse/jdt/internal/core/ClasspathChange.java (-20 lines)
Lines 333-358 Link Here
333
					}
333
					}
334
				}
334
				}
335
				addClasspathDeltas(delta, pkgFragmentRoots, IJavaElementDelta.F_REMOVED_FROM_CLASSPATH);
335
				addClasspathDeltas(delta, pkgFragmentRoots, IJavaElementDelta.F_REMOVED_FROM_CLASSPATH);
336
337
				// remember timestamp of jars that were removed (in case they are added as external jar in the same operation)
338
				for (int j = 0, length = pkgFragmentRoots.length; j < length; j++) {
339
					PackageFragmentRoot root = pkgFragmentRoots[j];
340
					if (root.isArchive() && !root.isExternal()) {
341
						URI location = root.resource().getLocationURI();
342
						File file = null;
343
						try {
344
							IFileStore fileStore = EFS.getStore(location);
345
							file = fileStore.toLocalFile(EFS.NONE, null);
346
						} catch (CoreException e) {
347
							// continue
348
						}
349
						if (file == null)
350
							continue;
351
						long timeStamp = DeltaProcessor.getTimeStamp(file);
352
						IPath externalPath = new org.eclipse.core.runtime.Path(file.getAbsolutePath());
353
						state.getExternalLibTimeStamps().put(externalPath, new Long(timeStamp));
354
					}
355
				}
356
			} else {
336
			} else {
357
				// remote project changes
337
				// remote project changes
358
				if (this.oldResolvedClasspath[i].getEntryKind() == IClasspathEntry.CPE_PROJECT) {
338
				if (this.oldResolvedClasspath[i].getEntryKind() == IClasspathEntry.CPE_PROJECT) {
(-)model/org/eclipse/jdt/internal/core/DeltaProcessingState.java (-4 / +19 lines)
Lines 507-524 Link Here
507
507
508
	public void saveExternalLibTimeStamps() throws CoreException {
508
	public void saveExternalLibTimeStamps() throws CoreException {
509
		if (this.externalTimeStamps == null) return;
509
		if (this.externalTimeStamps == null) return;
510
		
511
		// cleanup to avoid any leak ( https://bugs.eclipse.org/bugs/show_bug.cgi?id=244849 )
512
		HashSet toRemove = new HashSet();
513
		if (this.roots != null) {
514
			Enumeration keys = this.externalTimeStamps.keys();
515
			while (keys.hasMoreElements()) {
516
				Object key = keys.nextElement();
517
				if (this.roots.get(key) == null) {
518
					toRemove.add(key);
519
				}
520
			}
521
		}
522
		
510
		File timestamps = getTimeStampsFile();
523
		File timestamps = getTimeStampsFile();
511
		DataOutputStream out = null;
524
		DataOutputStream out = null;
512
		try {
525
		try {
513
			out = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(timestamps)));
526
			out = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(timestamps)));
514
			out.writeInt(this.externalTimeStamps.size());
527
			out.writeInt(this.externalTimeStamps.size() - toRemove.size());
515
			Iterator entries = this.externalTimeStamps.entrySet().iterator();
528
			Iterator entries = this.externalTimeStamps.entrySet().iterator();
516
			while (entries.hasNext()) {
529
			while (entries.hasNext()) {
517
				Map.Entry entry = (Map.Entry) entries.next();
530
				Map.Entry entry = (Map.Entry) entries.next();
518
				IPath key = (IPath) entry.getKey();
531
				IPath key = (IPath) entry.getKey();
519
				out.writeUTF(key.toPortableString());
532
				if (!toRemove.contains(key)) {
520
				Long timestamp = (Long) entry.getValue();
533
					out.writeUTF(key.toPortableString());
521
				out.writeLong(timestamp.longValue());
534
					Long timestamp = (Long) entry.getValue();
535
					out.writeLong(timestamp.longValue());
536
				}
522
			}
537
			}
523
		} catch (IOException e) {
538
		} catch (IOException e) {
524
			IStatus status = new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, IStatus.ERROR, "Problems while saving timestamps", e); //$NON-NLS-1$
539
			IStatus status = new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, IStatus.ERROR, "Problems while saving timestamps", e); //$NON-NLS-1$

Return to bug 244849