Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fixes bug: 3214
Whenever a manager method gives rice to an Exception make sure the entire stacktrace is written to log at debug level so that we can debug even though not the entire stacktrace survives the trip through JavaScript.
  • Loading branch information
jonalv committed Jun 14, 2012
1 parent 4db767b commit 63f65f2
Showing 1 changed file with 73 additions and 58 deletions.
Expand Up @@ -12,6 +12,7 @@
import net.bioclipse.core.IResourcePathTransformer;
import net.bioclipse.core.ResourcePathTransformer;
import net.bioclipse.core.business.BioclipseException;
import net.bioclipse.core.util.LogUtils;
import net.bioclipse.jobs.BioclipseJob;
import net.bioclipse.jobs.BioclipseJobUpdateHook;
import net.bioclipse.jobs.BioclipseUIJob;
Expand Down Expand Up @@ -84,71 +85,85 @@ public Object getReturnValue() {

public Object invoke( MethodInvocation invocation ) throws Throwable {

IBioclipseManager manager = (IBioclipseManager) invocation.getThis();
try {
IBioclipseManager manager = (IBioclipseManager) invocation.getThis();

Method m = findMethodToRun(invocation);
if ( invocation.getMethod().getAnnotation( GuiAction.class ) != null ) {

Method m = findMethodToRun(invocation);
if ( invocation.getMethod().getAnnotation( GuiAction.class ) != null ) {
logger.debug( manager.getManagerName() + "."
+ invocation.getMethod().getName()
+ " has @GuiAction - running in gui thread" );
return doInvokeInGuiThread( (IBioclipseManager)invocation.getThis(),
m,
invocation.getArguments(),
invocation );
}

logger.debug( manager.getManagerName() + "."
+ invocation.getMethod().getName()
+ " has @GuiAction - running in gui thread" );
return doInvokeInGuiThread( (IBioclipseManager)invocation.getThis(),
m,
invocation.getArguments(),
invocation );
}

Object returnValue;
if ( ( !BioclipseJob.class
.isAssignableFrom( invocation.getMethod()
.getReturnType() )
&& invocation.getMethod().getReturnType() != void.class )
|| Arrays.asList( invocation.getMethod().getParameterTypes() )
.contains( IProgressMonitor.class ) ) {
if ( Arrays.asList( m.getParameterTypes() )
.contains( IProgressMonitor.class) &&
!(this instanceof JavaScriptManagerMethodDispatcher) ) {

int timeout = 120;
String warning = manager.getManagerName() + "."
+ invocation.getMethod().getName()
+ " is not void or returning a BioclipseJob."
+ " But implementation takes a progress "
+ "monitor. Can not run as Job. Running in "
+ "same thread. This message will not be "
+ "repeated withing the next " + timeout
+ " seconds";
if ( !lastWarningTimes.containsKey( warning ) ||
System.currentTimeMillis()
- lastWarningTimes.get( warning ) > 1000 * timeout ) {
Object returnValue;
if ( ( !BioclipseJob.class
.isAssignableFrom( invocation.getMethod()
.getReturnType() )
&& invocation.getMethod().getReturnType() != void.class )
|| Arrays.asList( invocation.getMethod().getParameterTypes() )
.contains( IProgressMonitor.class ) ) {
if ( Arrays.asList( m.getParameterTypes() )
.contains( IProgressMonitor.class) &&
!(this instanceof JavaScriptManagerMethodDispatcher) ) {

lastWarningTimes.put( warning, System.currentTimeMillis() );
logger.warn( warning );
int timeout = 120;
String warning = manager.getManagerName() + "."
+ invocation.getMethod().getName()
+ " is not void or returning a BioclipseJob."
+ " But implementation takes a progress "
+ "monitor. Can not run as Job. Running in "
+ "same thread. This message will not be "
+ "repeated withing the next " + timeout
+ " seconds";
if ( !lastWarningTimes.containsKey( warning ) ||
System.currentTimeMillis()
- lastWarningTimes.get( warning ) > 1000 * timeout ) {

lastWarningTimes.put( warning, System.currentTimeMillis() );
logger.warn( warning );
}
}

returnValue = doInvokeInSameThread( (IBioclipseManager)
invocation.getThis(),
m,
invocation.getArguments(),
invocation );
}

returnValue = doInvokeInSameThread( (IBioclipseManager)
invocation.getThis(),
m,
invocation.getArguments(),
invocation );
}
else {
returnValue = doInvoke( (IBioclipseManager)invocation.getThis(),
m,
invocation.getArguments(),
invocation,
invocation.getMethod()
.getReturnType()
!= ExtendedBioclipseJob.class );
else {
returnValue = doInvoke( (IBioclipseManager)invocation.getThis(),
m,
invocation.getArguments(),
invocation,
invocation.getMethod()
.getReturnType()
!= ExtendedBioclipseJob.class );
}

if ( returnValue instanceof IFile &&
invocation.getMethod().getReturnType() == String.class ) {
returnValue = ( (IFile) returnValue ).getLocationURI()
.getPath();
}
return returnValue;
}

if ( returnValue instanceof IFile &&
invocation.getMethod().getReturnType() == String.class ) {
returnValue = ( (IFile) returnValue ).getLocationURI()
.getPath();
catch (Throwable t) {
logger.debug(
"\n******** EXTRA DEBUG LOGGING ********\n"
+ "A " + t.getClass().getSimpleName()
+ " was detected by "
+ "net.bioclipse.managers.business"
+ ".AbstractManagerMethodDispatcher. "
+ "Here follows the stack trace:" );
LogUtils.debugTrace( logger, t );
logger.debug( "\n*************************************" );
throw t;
}
return returnValue;
}

private BioclipseUIJob<Object> getBioclipseUIJob(Object[] arguments) {
Expand Down

0 comments on commit 63f65f2

Please sign in to comment.