|
Lines 22-27
Link Here
|
| 22 |
import org.eclipse.core.resources.IncrementalProjectBuilder; |
22 |
import org.eclipse.core.resources.IncrementalProjectBuilder; |
| 23 |
import org.eclipse.core.runtime.CoreException; |
23 |
import org.eclipse.core.runtime.CoreException; |
| 24 |
import org.eclipse.core.runtime.IPath; |
24 |
import org.eclipse.core.runtime.IPath; |
|
|
25 |
import org.eclipse.core.runtime.IProgressMonitor; |
| 25 |
import org.eclipse.core.runtime.Path; |
26 |
import org.eclipse.core.runtime.Path; |
| 26 |
import org.eclipse.jdt.core.*; |
27 |
import org.eclipse.jdt.core.*; |
| 27 |
import org.eclipse.jdt.core.compiler.CharOperation; |
28 |
import org.eclipse.jdt.core.compiler.CharOperation; |
|
Lines 35-40
Link Here
|
| 35 |
import org.eclipse.jdt.internal.core.index.Index; |
36 |
import org.eclipse.jdt.internal.core.index.Index; |
| 36 |
import org.eclipse.jdt.internal.core.search.AbstractSearchScope; |
37 |
import org.eclipse.jdt.internal.core.search.AbstractSearchScope; |
| 37 |
import org.eclipse.jdt.internal.core.search.indexing.IIndexConstants; |
38 |
import org.eclipse.jdt.internal.core.search.indexing.IIndexConstants; |
|
|
39 |
import org.eclipse.jdt.internal.core.search.indexing.IndexRequest; |
| 38 |
import org.eclipse.jdt.internal.core.search.matching.AndPattern; |
40 |
import org.eclipse.jdt.internal.core.search.matching.AndPattern; |
| 39 |
import org.eclipse.jdt.internal.core.search.indexing.IndexManager; |
41 |
import org.eclipse.jdt.internal.core.search.indexing.IndexManager; |
| 40 |
import org.eclipse.jdt.internal.core.search.matching.MatchLocator; |
42 |
import org.eclipse.jdt.internal.core.search.matching.MatchLocator; |
|
Lines 10290-10293
Link Here
|
| 10290 |
removeClasspathEntry(JAVA_PROJECT, new Path("/JavaSearchBugs/lib/b266582b.jar")); |
10292 |
removeClasspathEntry(JAVA_PROJECT, new Path("/JavaSearchBugs/lib/b266582b.jar")); |
| 10291 |
} |
10293 |
} |
| 10292 |
} |
10294 |
} |
|
|
10295 |
/** |
| 10296 |
* @bug 296343: OOM error caused by java indexing referencing classloader from threadLocal |
| 10297 |
* @test Ensure that indexing thread context class loader is not the application class loader |
| 10298 |
* @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=296343" |
| 10299 |
*/ |
| 10300 |
public void testBug296343() throws Exception { |
| 10301 |
simulateExit(); |
| 10302 |
class TestClassLoader extends ClassLoader { |
| 10303 |
TestClassLoader(ClassLoader parent) { |
| 10304 |
super(parent); |
| 10305 |
} |
| 10306 |
} |
| 10307 |
TestClassLoader tcl = new TestClassLoader(this.getClass().getClassLoader()); |
| 10308 |
ClassLoader cl = Thread.currentThread().getContextClassLoader(); |
| 10309 |
try { |
| 10310 |
// set the thread context class loader |
| 10311 |
Thread.currentThread().setContextClassLoader(tcl); |
| 10312 |
simulateRestart(); |
| 10313 |
|
| 10314 |
// get the indexing thread |
| 10315 |
class TestIndexRequest extends IndexRequest { |
| 10316 |
public Thread indexingThread = null; |
| 10317 |
public boolean executed = false; |
| 10318 |
public boolean execute(IProgressMonitor progressMonitor) { |
| 10319 |
this.indexingThread = Thread.currentThread(); |
| 10320 |
this.executed = true; |
| 10321 |
return true; |
| 10322 |
} |
| 10323 |
TestIndexRequest(Path containerPath, IndexManager indexManager) { |
| 10324 |
super(containerPath, indexManager); |
| 10325 |
} |
| 10326 |
} |
| 10327 |
IndexManager indexManager = JavaModelManager.getIndexManager(); |
| 10328 |
TestIndexRequest tir = new TestIndexRequest(new Path(""), indexManager ); |
| 10329 |
indexManager.request(tir); |
| 10330 |
int counter = 0; |
| 10331 |
// wait until the Index request gets executed |
| 10332 |
while (!tir.executed) { |
| 10333 |
try { |
| 10334 |
Thread.sleep(100); |
| 10335 |
} |
| 10336 |
catch (InterruptedException ie) { |
| 10337 |
// skip |
| 10338 |
} |
| 10339 |
assertTrue("Index request should have got executed within a 10s delay!", counter++ < 100); |
| 10340 |
} |
| 10341 |
assertFalse(tir.indexingThread.getContextClassLoader() == tcl); |
| 10342 |
} finally { |
| 10343 |
Thread.currentThread().setContextClassLoader(cl); |
| 10344 |
} |
| 10345 |
} |
| 10293 |
} |
10346 |
} |