Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 355154 - PathTraverser must ignore non-existent files
Summary: PathTraverser must ignore non-existent files
Status: CLOSED WONTFIX
Alias: None
Product: TMF
Classification: Modeling
Component: Xtext (show other bugs)
Version: 2.0.1   Edit
Hardware: PC Mac OS X - Carbon (unsup.)
: P3 minor (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-08-18 15:28 EDT by Karsten Thoms CLA
Modified: 2012-11-23 02:37 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Karsten Thoms CLA 2011-08-18 15:28:17 EDT
I had the situation that a project's classpath might refer to a non-existent Jar file and the PathTraverser throws an exception:

======================================================
1    [Thread-1] ERROR mf.mwe2.launch.runtime.Mwe2Launcher  - Unsupported path : /Users/thoms/.m2/repository/org/eclipse/plugins/org.eclipse.emf.mapping.ecore2xml/2.7.0.v20110331-2022/org.eclipse.emf.mapping.ecore2xml-2.7.0.v20110331-2022.jar (only folders and archives are supported).
java.lang.IllegalArgumentException: Unsupported path : /Users/thoms/.m2/repository/org/eclipse/plugins/org.eclipse.emf.mapping.ecore2xml/2.7.0.v20110331-2022/org.eclipse.emf.mapping.ecore2xml-2.7.0.v20110331-2022.jar (only folders and archives are supported).
	at org.eclipse.xtext.mwe.PathTraverser.findAllResourceUris(PathTraverser.java:46)
	at org.eclipse.xtext.mwe.PathTraverser.resolvePathes(PathTraverser.java:33)
	at org.eclipse.xtext.mwe.RuntimeResourceSetInitializer.getPathToUriMap(RuntimeResourceSetInitializer.java:54)
	at org.eclipse.xtext.mwe.RuntimeResourceSetInitializer.getInitializedResourceSet(RuntimeResourceSetInitializer.java:72)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.findModule(Mwe2Runner.java:112)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:77)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:73)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:64)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:55)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.run(Mwe2Launcher.java:74)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.main(Mwe2Launcher.java:35)
======================================================


However, the workflow in this case could also succeed.

Suggested change:
=====================================
	public Set<URI> findAllResourceUris(String path, Predicate<URI> isValidPredicate) {
		File file = new File(path);
		if (!file.exists()) {
			return Sets.newHashSet();
		} else if (file.isDirectory()) {
			return traverseDir(file, isValidPredicate);
		} else if (file.isFile()) {
			return traverseArchive(file, isValidPredicate);
		}
		throw new IllegalArgumentException("Unsupported path : " + path + " (only folders and archives are supported).");
	}
=====================================
Comment 1 Sven Efftinge CLA 2011-08-18 15:53:01 EDT
I'd like to get an exception if the configuration is pointing to non existent files. 
Don't you get an error marker for that in your project as well?
Comment 2 Karsten Thoms CLA 2011-09-14 11:02:51 EDT
This happened when having the Maven Classpath Container on the classpath. There was no error marker in the IDE. The classpath container had a dependency to that artifact, and *would* resolve this jar. But at execution time it might actually not be there.

I think Maven IDE users will face this problem, and from the error message it is not that obvious. You could print out a warning if the file does not exist that is about to be traversed. But the exception is annoying, since it might not lead to an error, when some jars are unresolvable.
Comment 3 Sven Efftinge CLA 2012-11-23 02:37:08 EST
I fear a warning will be overseen and people get surprised if we just ignore an incomplete classpath. I think people should rather fix the classpath issue.