Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 5207 Details for
Bug 39007
Infinite loop trying to index a non-existing external jar
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Proposed patch for AddJarFileToIndex.execute()
a.txt (text/plain), 6.23 KB, created by
Philipe Mulet
on 2003-06-17 07:09:26 EDT
(
hide
)
Description:
Proposed patch for AddJarFileToIndex.execute()
Filename:
MIME Type:
Creator:
Philipe Mulet
Created:
2003-06-17 07:09:26 EDT
Size:
6.23 KB
patch
obsolete
> > public boolean execute(IProgressMonitor progressMonitor) { > > if (progressMonitor != null && progressMonitor.isCanceled()) return true; > IIndex index = null; > try { > // if index is already cached, then do not perform any check > // MUST reset the IndexManager if a jar file is changed > index = (IIndex) manager.getIndex(this.indexPath, false, /*do not reuse index file*/ false /*do not create if none*/); > if (index != null) { > if (JobManager.VERBOSE) > JobManager.verbose("-> no indexing required (index already exists) for " + this.indexPath); //$NON-NLS-1$ > return true; > } > > index = manager.getIndex(this.indexPath, true, /*reuse index file*/ true /*create if none*/); > if (index == null) { > if (JobManager.VERBOSE) > JobManager.verbose("-> index could not be created for " + this.indexPath); //$NON-NLS-1$ > return true; > } > ReadWriteMonitor monitor = manager.getMonitorFor(index); > if (monitor == null) { > if (JobManager.VERBOSE) > JobManager.verbose("-> index for " + this.indexPath + " just got deleted"); //$NON-NLS-1$//$NON-NLS-2$ > return true; // index got deleted since acquired > } > ZipFile zip = null; > try { > // this path will be a relative path to the workspace in case the zipfile in the workspace otherwise it will be a path in the > // local file system > Path zipFilePath = null; > > monitor.enterWrite(); // ask permission to write > if (resource != null) { > IPath location = this.resource.getLocation(); > if (location == null) return false; > if (JavaModelManager.ZIP_ACCESS_VERBOSE) > System.out.println("(" + Thread.currentThread() + ") [AddJarFileToIndex.execute()] Creating ZipFile on " + location); //$NON-NLS-1$ //$NON-NLS-2$ > zip = new ZipFile(location.toFile()); > zipFilePath = (Path) this.resource.getFullPath().makeRelative(); > // absolute path relative to the workspace > } else { > if (JavaModelManager.ZIP_ACCESS_VERBOSE) > System.out.println("(" + Thread.currentThread() + ") [AddJarFileToIndex.execute()] Creating ZipFile on " + this.indexPath); //$NON-NLS-1$ //$NON-NLS-2$ > zip = new ZipFile(this.indexPath.toFile()); > zipFilePath = (Path) this.indexPath; > // path is already canonical since coming from a library classpath entry > } > > if (JobManager.VERBOSE) > JobManager.verbose("-> indexing " + zip.getName()); //$NON-NLS-1$ > long initialTime = System.currentTimeMillis(); > > IQueryResult[] results = index.queryInDocumentNames(""); // all file names //$NON-NLS-1$ > int max = results == null ? 0 : results.length; > if (max != 0) { > /* check integrity of the existing index file > * if the length is equal to 0, we want to index the whole jar again > * If not, then we want to check that there is no missing entry, if > * one entry is missing then we recreate the index > */ > String EXISTS = "OK"; //$NON-NLS-1$ > String DELETED = "DELETED"; //$NON-NLS-1$ > SimpleLookupTable indexedFileNames = new SimpleLookupTable(max == 0 ? 33 : max + 11); > for (int i = 0; i < max; i++) > indexedFileNames.put(results[i].getPath(), DELETED); > for (Enumeration e = zip.entries(); e.hasMoreElements();) { > // iterate each entry to index it > ZipEntry ze = (ZipEntry) e.nextElement(); > if (Util.isClassFileName(ze.getName())) { > JarFileEntryDocument entryDocument = new JarFileEntryDocument(ze, null, zipFilePath); > indexedFileNames.put(entryDocument.getName(), EXISTS); > } > } > boolean needToReindex = indexedFileNames.elementSize != max; // a new file was added > if (!needToReindex) { > Object[] valueTable = indexedFileNames.valueTable; > for (int i = 0, l = valueTable.length; i < l; i++) { > if (valueTable[i] == DELETED) { > needToReindex = true; // a file was deleted so re-index > break; > } > } > if (!needToReindex) { > if (JobManager.VERBOSE) > JobManager.verbose("-> no indexing required (index is consistent with library) for " //$NON-NLS-1$ > + zip.getName() + " (" //$NON-NLS-1$ > + (System.currentTimeMillis() - initialTime) + "ms)"); //$NON-NLS-1$ > return true; > } > } > } > > /* > * Index the jar for the first time or reindex the jar in case the previous index file has been corrupted > */ > // index already existed: recreate it so that we forget about previous entries > index = manager.recreateIndex(this.indexPath); > for (Enumeration e = zip.entries(); e.hasMoreElements();) { > if (this.isCancelled) { > if (JobManager.VERBOSE) > JobManager.verbose("-> indexing of " + zip.getName() + " has been cancelled"); //$NON-NLS-1$ //$NON-NLS-2$ > return false; > } > > // iterate each entry to index it > ZipEntry ze = (ZipEntry) e.nextElement(); > if (Util.isClassFileName(ze.getName())) { > byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getZipEntryByteContent(ze, zip); > // Add the name of the file to the index > index.add( > new JarFileEntryDocument(ze, classFileBytes, zipFilePath), > new BinaryIndexer(true)); > } > } > this.manager.saveIndex(index); > if (JobManager.VERBOSE) > JobManager.verbose("-> done indexing of " //$NON-NLS-1$ > + zip.getName() + " (" //$NON-NLS-1$ > + (System.currentTimeMillis() - initialTime) + "ms)"); //$NON-NLS-1$ > } finally { > if (zip != null) { > if (JavaModelManager.ZIP_ACCESS_VERBOSE) > System.out.println("(" + Thread.currentThread() + ") [AddJarFileToIndex.execute()] Closing ZipFile " + zip); //$NON-NLS-1$ //$NON-NLS-2$ > zip.close(); > } > monitor.exitWrite(); // free write lock > } > } catch (IOException e) { > if (JobManager.VERBOSE) { > JobManager.verbose("-> failed to index " + this.indexPath + " because of the following exception:"); //$NON-NLS-1$ //$NON-NLS-2$ > e.printStackTrace(); > } > if (index != null && e instanceof ZipException) { // if zip couldn't be found or read properly; ignore so as to avoid infinite doomed attempts > try { > this.manager.saveIndex(index); > } catch(IOException ex) { > } > return true; > } > manager.removeIndex(this.indexPath); > return false; > } > return true; > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 39007
: 5207