Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 299053
Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java (-1 / +55 lines)
Lines 18-23 Link Here
18
import org.eclipse.core.resources.IncrementalProjectBuilder;
18
import org.eclipse.core.resources.IncrementalProjectBuilder;
19
import org.eclipse.core.runtime.CoreException;
19
import org.eclipse.core.runtime.CoreException;
20
import org.eclipse.core.runtime.IPath;
20
import org.eclipse.core.runtime.IPath;
21
import org.eclipse.core.runtime.IProgressMonitor;
21
import org.eclipse.core.runtime.Path;
22
import org.eclipse.core.runtime.Path;
22
import org.eclipse.jdt.core.*;
23
import org.eclipse.jdt.core.*;
23
import org.eclipse.jdt.core.compiler.CharOperation;
24
import org.eclipse.jdt.core.compiler.CharOperation;
Lines 25-33 Link Here
25
26
26
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
27
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
27
import org.eclipse.jdt.internal.core.ClassFile;
28
import org.eclipse.jdt.internal.core.ClassFile;
29
import org.eclipse.jdt.internal.core.JavaModelManager;
28
import org.eclipse.jdt.internal.core.SourceMethod;
30
import org.eclipse.jdt.internal.core.SourceMethod;
29
import org.eclipse.jdt.internal.core.search.AbstractSearchScope;
31
import org.eclipse.jdt.internal.core.search.AbstractSearchScope;
30
import org.eclipse.jdt.internal.core.search.indexing.IIndexConstants;
32
import org.eclipse.jdt.internal.core.search.indexing.IIndexConstants;
33
import org.eclipse.jdt.internal.core.search.indexing.IndexManager;
34
import org.eclipse.jdt.internal.core.search.indexing.IndexRequest;
31
import org.eclipse.jdt.internal.core.search.matching.MatchLocator;
35
import org.eclipse.jdt.internal.core.search.matching.MatchLocator;
32
import org.eclipse.jdt.internal.core.search.matching.PatternLocator;
36
import org.eclipse.jdt.internal.core.search.matching.PatternLocator;
33
import org.eclipse.jdt.internal.core.search.matching.TypeDeclarationPattern;
37
import org.eclipse.jdt.internal.core.search.matching.TypeDeclarationPattern;
Lines 8146-8150 Link Here
8146
	search(method, REFERENCES);
8150
	search(method, REFERENCES);
8147
	assertSearchResults("");
8151
	assertSearchResults("");
8148
}
8152
}
8149
8153
/**
8154
 * @bug 296343: OOM error caused by java indexing referencing classloader from threadLocal
8155
 * @test Ensure that indexing thread context class loader is not the application class loader
8156
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=296343"
8157
 */
8158
public void testBug296343() throws Exception {
8159
	simulateExit();
8160
	class TestClassLoader extends ClassLoader {
8161
		TestClassLoader(ClassLoader parent) {
8162
			super(parent);
8163
		}
8164
	}
8165
	TestClassLoader tcl = new TestClassLoader(this.getClass().getClassLoader());
8166
	ClassLoader cl = Thread.currentThread().getContextClassLoader();
8167
	try {
8168
		// set the thread context class loader
8169
		Thread.currentThread().setContextClassLoader(tcl);
8170
		simulateRestart();
8171
		
8172
		// get the indexing thread
8173
		class TestIndexRequest extends IndexRequest {
8174
			public Thread indexingThread = null;
8175
			public boolean executed = false;
8176
			public boolean execute(IProgressMonitor progressMonitor) {
8177
				this.indexingThread = Thread.currentThread();
8178
				this.executed = true;
8179
				return true;
8180
			}
8181
			TestIndexRequest(Path containerPath, IndexManager indexManager) {
8182
				super(containerPath, indexManager);
8183
			}
8184
		}
8185
		IndexManager indexManager = JavaModelManager.getJavaModelManager().getIndexManager();
8186
		TestIndexRequest tir = new TestIndexRequest(new Path(""), indexManager );
8187
		indexManager.request(tir);
8188
		int counter = 0;
8189
		// wait until the Index request gets executed
8190
		while (!tir.executed) {
8191
			try {
8192
				Thread.sleep(100);
8193
			}
8194
			catch (InterruptedException ie) {
8195
				// skip
8196
			}
8197
			assertTrue("Index request should have got executed within a 10s delay!", counter++ < 100);
8198
		}
8199
		assertFalse(tir.indexingThread.getContextClassLoader() == tcl);
8200
	} finally {
8201
		Thread.currentThread().setContextClassLoader(cl);
8202
	}	
8203
}
8150
}
8204
}
(-)search/org/eclipse/jdt/internal/core/search/processing/JobManager.java (+3 lines)
Lines 320-325 Link Here
320
			this.processingThread.setDaemon(true);
320
			this.processingThread.setDaemon(true);
321
			// less prioritary by default, priority is raised if clients are actively waiting on it
321
			// less prioritary by default, priority is raised if clients are actively waiting on it
322
			this.processingThread.setPriority(Thread.NORM_PRIORITY-1); 
322
			this.processingThread.setPriority(Thread.NORM_PRIORITY-1); 
323
			// https://bugs.eclipse.org/bugs/show_bug.cgi?id=296343
324
			// set the context loader to avoid leaking the current context loader
325
			this.processingThread.setContextClassLoader(this.getClass().getClassLoader());
323
			this.processingThread.start();
326
			this.processingThread.start();
324
		}
327
		}
325
	}
328
	}

Return to bug 299053