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 163463 Details for
Bug 294894
Workspace lock not released leading to deadlock
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
test take 3
bug_294894.patch (text/plain), 6.23 KB, created by
James Blackburn
on 2010-03-30 19:33:21 EDT
(
hide
)
Description:
test take 3
Filename:
MIME Type:
Creator:
James Blackburn
Created:
2010-03-30 19:33:21 EDT
Size:
6.23 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.ui.tests >Index: Eclipse UI Tests/org/eclipse/ui/tests/concurrency/Bug_294894.java >=================================================================== >RCS file: Eclipse UI Tests/org/eclipse/ui/tests/concurrency/Bug_294894.java >diff -N Eclipse UI Tests/org/eclipse/ui/tests/concurrency/Bug_294894.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ Eclipse UI Tests/org/eclipse/ui/tests/concurrency/Bug_294894.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,194 @@ >+/******************************************************************************* >+ * Copyright (c) 2009 Broadcom Coporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * James Blackburn (Broadcom Corp.) - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.ui.tests.concurrency; >+ >+import java.io.IOException; >+import java.io.OutputStream; >+ >+import java.io.PrintStream; >+ >+import junit.framework.AssertionFailedError; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IStatus; >+ >+import java.io.*; >+import junit.framework.TestCase; >+import org.eclipse.core.resources.*; >+import org.eclipse.core.runtime.*; >+import org.eclipse.core.runtime.jobs.Job; >+import org.eclipse.swt.widgets.Display; >+ >+/** >+ * Test case for resources plugin lock-up >+ */ >+public class Bug_294894 extends TestCase { >+ >+ /** >+ * Fails the test due to the given throwable. >+ */ >+ public static void fail(String message, Throwable e) { >+ // If the exception is a CoreException with a multistatus >+ // then print out the multistatus so we can see all the info. >+ if (e instanceof CoreException) { >+ IStatus status = ((CoreException) e).getStatus(); >+ //if the status does not have an exception, print the stack for this one >+ if (status.getException() == null) >+ e.printStackTrace(); >+ write(status, 0); >+ } else >+ e.printStackTrace(); >+ AssertionFailedError assertFail = new AssertionFailedError(message + ": " + e); >+ assertFail.initCause(e); >+ throw assertFail; >+ } >+ >+ private static void indent(OutputStream output, int indent) { >+ for (int i = 0; i < indent; i++) >+ try { >+ output.write("\t".getBytes()); >+ } catch (IOException e) { >+ // ignore >+ } >+ } >+ private static void write(IStatus status, int indent) { >+ PrintStream output = System.out; >+ indent(output, indent); >+ output.println("Severity: " + status.getSeverity()); >+ >+ indent(output, indent); >+ output.println("Plugin ID: " + status.getPlugin()); >+ >+ indent(output, indent); >+ output.println("Code: " + status.getCode()); >+ >+ indent(output, indent); >+ output.println("Message: " + status.getMessage()); >+ >+ if (status.getException() != null) { >+ indent(output, indent); >+ output.print("Exception: "); >+ status.getException().printStackTrace(output); >+ } >+ >+ if (status.isMultiStatus()) { >+ IStatus[] children = status.getChildren(); >+ for (int i = 0; i < children.length; i++) >+ write(children[i], indent + 1); >+ } >+ } >+ >+ public void appendContentsWithException(IProject project) { >+ int count = 5; >+ final IFile targets[] = new IFile[count]; >+ for (int i = 0; i < count; i++) >+ targets[i] = project.getFile("file" + i); >+ try { >+ for (int i = 0; i < count; i++) >+ if (!targets[i].exists()) >+ targets[i].create(getContents("abc"), false, null); >+ } catch (CoreException e) { >+ fail("1.0"); >+ } >+ >+ // Run [count] failing append content jobs >+ Job[] js = new Job[count]; >+ for (int i = 0; i < count; i++) { >+ final int j = i; >+ js[i] = new Job("bad append") { >+ protected IStatus run(IProgressMonitor monitor) { >+ try { >+ targets[j].appendContents(new InputStream() { >+ public int read() throws IOException { >+ throw new IOException("Stream closed"); >+ } >+ }, false, false, null); >+ } catch (CoreException e) { >+ //expected to fail due to invalid input stream >+ } >+ return Status.OK_STATUS; >+ } >+ }; >+ js[i].schedule(); >+ } >+ } >+ >+ public InputStream getContents(String text) { >+ return new ByteArrayInputStream(text.getBytes()); >+ } >+ >+ public void testDeadLockFail() throws Exception { >+ final String proj = "testProject"; >+ >+ final IWorkspace workspace = ResourcesPlugin.getWorkspace(); >+ final IProject project = workspace.getRoot().getProject(proj); >+ final IFile file = project.getFile("foo"); >+ workspace.run(new IWorkspaceRunnable() { >+ public void run(IProgressMonitor monitor) throws CoreException { >+ project.create(null); >+ project.open(null); >+ file.create(new ByteArrayInputStream(new byte[] {'a'}), true, null); >+ } >+ }, null); >+ >+ for (int i = 0; i < 10000; i++) { >+ // Run this in a job holding the appropriate scheduling rule >+ Job j = new Job("jobwithfilelock") { >+ >+ protected IStatus run(IProgressMonitor monitor) { >+ >+ // Job to deadlock with this: Display -> Resource Lock >+ Job j2 = new Job("Workspace refresh") { >+ protected IStatus run(IProgressMonitor monitor) { >+ Display.getDefault().syncExec(new Runnable() { >+ public void run() { >+ try { >+ appendContentsWithException(project); >+ workspace.getRoot().refreshLocal(IResource.DEPTH_INFINITE, null); >+ } catch (Exception e) { >+ fail("refresh run", e); >+ } >+ } >+ }); >+ return Status.OK_STATUS; >+ } >+ }; >+ >+ j2.schedule(); >+ try { >+ Thread.sleep(1); >+ } catch (Exception e) { >+ fail("Sleep failed", e); >+ } >+ >+ // Grab Display and refresh the file... [Resource -> Display ] >+ Display.getDefault().syncExec(new Runnable() { >+ public void run() { >+ try { >+ file.refreshLocal(IResource.DEPTH_ONE, null); >+ } catch (Exception e) { >+ fail("syncExec fail", e); >+ } >+ } >+ }); >+ return Status.OK_STATUS; >+ } >+ }; >+ j.setRule(file); >+ j.schedule(); >+ j.join(); >+ >+ // Now try to append to the file >+ file.appendContents(new ByteArrayInputStream(new byte[] {'a'}), IResource.FORCE, null); >+ } >+ } >+ >+} >\ No newline at end of file
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 Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 294894
:
151953
|
151954
|
152020
|
152022
|
152031
|
152084
|
152085
|
163428
|
163433
| 163463