diff options
author | Curtis Windatt | 2014-04-22 18:09:57 +0000 |
---|---|---|
committer | Curtis Windatt | 2014-04-22 18:09:57 +0000 |
commit | 6c379044b0776f466dc4a9a987b84f0b2afccdd9 (patch) | |
tree | 0a15c1c57f23075b424923f2430db26d688ea1cd /apitools | |
parent | 4b40337cc84017185f8900607466e531fd2bfd27 (diff) | |
download | eclipse.pde.ui-6c379044b0776f466dc4a9a987b84f0b2afccdd9.tar.gz eclipse.pde.ui-6c379044b0776f466dc4a9a987b84f0b2afccdd9.tar.xz eclipse.pde.ui-6c379044b0776f466dc4a9a987b84f0b2afccdd9.zip |
Bug 432917 - API Tools Use Scans of jarred bundles throw IOExceptions
with folder on bundle-classpath
Change-Id: I50e31e58f4796fb719962728a848f393cdeba88d
Diffstat (limited to 'apitools')
2 files changed, 90 insertions, 88 deletions
diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/model/BundleComponent.java b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/model/BundleComponent.java index 51a9d7bf3a..a8bcea742d 100644 --- a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/model/BundleComponent.java +++ b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/model/BundleComponent.java @@ -566,39 +566,39 @@ public class BundleComponent extends Component { @Override protected synchronized List<IApiTypeContainer> createApiTypeContainers() throws CoreException { List<IApiTypeContainer> containers = new ArrayList<IApiTypeContainer>(5); - try { - List<IApiComponent> all = new ArrayList<IApiComponent>(); - // build the classpath from bundle and all fragments - all.add(this); - boolean considerFragments = true; - if (Util.ORG_ECLIPSE_SWT.equals(getSymbolicName())) { - // if SWT is a project to be built/analyzed don't consider its - // fragments - considerFragments = !isApiEnabled(); - } - if (considerFragments) { - BundleDescription[] fragments = getBundleDescription().getFragments(); - IApiComponent component = null; - for (int i = 0; i < fragments.length; i++) { - if (!fragments[i].isResolved()) { - continue; - } - component = getBaseline().getApiComponent(fragments[i].getSymbolicName()); - if (component != null) { - // force initialization of the fragment so we can - // retrieve its class file containers - component.getApiTypeContainers(); - all.add(component); - } + List<IApiComponent> all = new ArrayList<IApiComponent>(); + // build the classpath from bundle and all fragments + all.add(this); + boolean considerFragments = true; + if (Util.ORG_ECLIPSE_SWT.equals(getSymbolicName())) { + // if SWT is a project to be built/analyzed don't consider its + // fragments + considerFragments = !isApiEnabled(); + } + if (considerFragments) { + BundleDescription[] fragments = getBundleDescription().getFragments(); + IApiComponent component = null; + for (int i = 0; i < fragments.length; i++) { + if (!fragments[i].isResolved()) { + continue; + } + component = getBaseline().getApiComponent(fragments[i].getSymbolicName()); + if (component != null) { + // force initialization of the fragment so we can + // retrieve its class file containers + component.getApiTypeContainers(); + all.add(component); } } - Iterator<IApiComponent> iterator = all.iterator(); - Set<String> entryNames = new HashSet<String>(5); - BundleComponent other = null; - while (iterator.hasNext()) { - BundleComponent component = (BundleComponent) iterator.next(); - Map<String, String> manifest = component.getManifest(); - if (manifest != null) { + } + Iterator<IApiComponent> iterator = all.iterator(); + Set<String> entryNames = new HashSet<String>(5); + BundleComponent other = null; + while (iterator.hasNext()) { + BundleComponent component = (BundleComponent) iterator.next(); + Map<String, String> manifest = component.getManifest(); + if (manifest != null) { + try { String[] paths = getClasspathEntries(manifest); for (int i = 0; i < paths.length; i++) { String path = paths[i]; @@ -625,12 +625,11 @@ public class BundleComponent extends Component { } } } + } catch (BundleException e) { + abort("Unable to parse bundle-classpath entry of manifest for bundle at " + component.getLocation(), e); //$NON-NLS-1$ } + } - } catch (BundleException e) { - abort("Unable to parse bundle classpath", e); //$NON-NLS-1$ - } catch (IOException e) { - abort("Unable to initialize class file containers", e); //$NON-NLS-1$ } return containers; } @@ -680,64 +679,68 @@ public class BundleComponent extends Component { * @throws CoreException if something goes wrong while creating the * container */ - protected IApiTypeContainer createApiTypeContainer(String path) throws IOException, CoreException { - File bundle = new File(fLocation); - if (bundle.isDirectory()) { - // bundle is folder - File entry = new File(bundle, path); - if (entry.exists()) { - if (entry.isFile()) { - return new ArchiveApiTypeContainer(this, entry.getCanonicalPath()); - } else { - return new DirectoryApiTypeContainer(this, entry.getCanonicalPath()); + protected IApiTypeContainer createApiTypeContainer(String path) throws CoreException { + try { + File bundle = new File(fLocation); + if (bundle.isDirectory()) { + // bundle is folder + File entry = new File(bundle, path); + if (entry.exists()) { + if (entry.isFile()) { + return new ArchiveApiTypeContainer(this, entry.getCanonicalPath()); + } else { + return new DirectoryApiTypeContainer(this, entry.getCanonicalPath()); + } } - } - } else { - // bundle is jar'd - ZipFile zip = null; - try { - if (path.equals(".")) { //$NON-NLS-1$ - return new ArchiveApiTypeContainer(this, fLocation); - } else { - // classpath element can be jar or folder - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=279729 - zip = new ZipFile(fLocation); - ZipEntry entry = zip.getEntry(path); - if (entry != null) { - File tmpfolder = new File(System.getProperty("java.io.tmpdir")); //$NON-NLS-1$ - if (entry.isDirectory()) { - // extract the dir and all children - File dir = Util.createTempFile(TMP_API_FILE_PREFIX, TMP_API_FILE_POSTFIX); - // hack to create a temp directory - // see - // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4735419 - if (dir.delete()) { - dir.mkdir(); - FileManager.getManager().recordTempFileRoot(dir.getCanonicalPath()); - } - extractDirectory(zip, entry.getName(), dir); - if (dir.isDirectory() && dir.exists()) { - return new DirectoryApiTypeContainer(this, dir.getCanonicalPath()); - } - } else { - File file = extractEntry(zip, entry, tmpfolder); - if (Util.isArchive(file.getName())) { - File parent = file.getParentFile(); - if (!parent.equals(tmpfolder)) { - FileManager.getManager().recordTempFileRoot(parent.getCanonicalPath()); - } else { - FileManager.getManager().recordTempFileRoot(file.getCanonicalPath()); + } else { + // bundle is jar'd + ZipFile zip = null; + try { + if (path.equals(".")) { //$NON-NLS-1$ + return new ArchiveApiTypeContainer(this, fLocation); + } else { + // classpath element can be jar or folder + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=279729 + zip = new ZipFile(fLocation); + ZipEntry entry = zip.getEntry(path); + if (entry != null) { + File tmpfolder = new File(System.getProperty("java.io.tmpdir")); //$NON-NLS-1$ + if (entry.isDirectory()) { + // extract the dir and all children + File dir = Util.createTempFile(TMP_API_FILE_PREFIX, TMP_API_FILE_POSTFIX); + // hack to create a temp directory + // see + // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4735419 + if (dir.delete()) { + dir.mkdir(); + FileManager.getManager().recordTempFileRoot(dir.getCanonicalPath()); + } + extractDirectory(zip, entry.getName(), dir); + if (dir.isDirectory() && dir.exists()) { + return new DirectoryApiTypeContainer(this, dir.getCanonicalPath()); + } + } else { + File file = extractEntry(zip, entry, tmpfolder); + if (Util.isArchive(file.getName())) { + File parent = file.getParentFile(); + if (!parent.equals(tmpfolder)) { + FileManager.getManager().recordTempFileRoot(parent.getCanonicalPath()); + } else { + FileManager.getManager().recordTempFileRoot(file.getCanonicalPath()); + } + return new ArchiveApiTypeContainer(this, file.getCanonicalPath()); } - return new ArchiveApiTypeContainer(this, file.getCanonicalPath()); } } } - } - } finally { - if (zip != null) { - zip.close(); + } finally { + if (zip != null) { + zip.close(); + } } } + } catch (IOException e) { + abort("Problem creating api type container for path " + path + " in bundle at " + fLocation, e); //$NON-NLS-1$ //$NON-NLS-2$ } return null; } diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/model/ProjectComponent.java b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/model/ProjectComponent.java index 62b3f88ceb..b19224959c 100644 --- a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/model/ProjectComponent.java +++ b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/model/ProjectComponent.java @@ -10,7 +10,6 @@ *******************************************************************************/ package org.eclipse.pde.api.tools.internal.model; -import java.io.IOException; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; @@ -373,7 +372,7 @@ public class ProjectComponent extends BundleComponent { * createApiTypeContainer(java.lang.String) */ @Override - protected IApiTypeContainer createApiTypeContainer(String path) throws IOException, CoreException { + protected IApiTypeContainer createApiTypeContainer(String path) throws CoreException { if (this.fPathToOutputContainers == null) { baselineDisposed(getBaseline()); } |