Skip to content

Commit

Permalink
Another experiment
Browse files Browse the repository at this point in the history
  • Loading branch information
jonahgraham committed Nov 8, 2022
1 parent b109796 commit 90a3684
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,21 @@
*/
public class FailedToReAcquireLockException extends Exception {

public FailedToReAcquireLockException(InterruptedException e) {
super(e);
Assert.isNotNull(e);
public FailedToReAcquireLockException(Throwable t) {
super(t);
Assert.isNotNull(t);
}

public FailedToReAcquireLockException(OperationCanceledException e) {
super(e);
Assert.isNotNull(e);
}

public void reThrow() throws InterruptedException, OperationCanceledException {
public void reThrow() throws InterruptedException {
if (getCause() instanceof InterruptedException ie) {
throw ie;
}
if (getCause() instanceof OperationCanceledException oce) {
throw oce;
if (getCause() instanceof RuntimeException re) {
throw re;
}
if (getCause() instanceof Error er) {
throw er;
}
throw new RuntimeException("Unexpectedly the exception cause was none of the allowed types", this); //$NON-NLS-1$
throw new RuntimeException("Unexpectedly the exception cause was none of the allowed types", getCause()); //$NON-NLS-1$
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.pdom;

import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.internal.core.index.IWritableIndex;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;

/**
* Write lock on the index that can be yielded temporarily to unblock threads that need
Expand Down Expand Up @@ -67,10 +67,9 @@ public void yield() throws FailedToReAcquireLockException {
lastLockTime = 0;
try {
acquire();
} catch (OperationCanceledException e) {
throw new FailedToReAcquireLockException(e);
} catch (InterruptedException e) {
throw new FailedToReAcquireLockException(e);
} catch (Throwable t) {
CCorePlugin.log("Exception while reacquiring lock", t);
throw new FailedToReAcquireLockException(t);
}
}
}
Expand Down

0 comments on commit 90a3684

Please sign in to comment.