Buggy code:
public class Hook extends WebCommandHandler { protected ConcurrentHashMap < Integer , Hook . StoredValue > store ; protected Class clazz = null ; protected Object current = null ; protected String className = "" ; protected String commandName ; public Hook ( ) { } public Object execute ( Command cmd ) { } protected < T > String createLocalObject ( Class < T > clazz , Object [ ] args ) throws Exception { } protected void determineClass ( String ref , int index , String [ ] values ) throws Exception { } protected Object findAndCallMethod ( String ref , String s , Object [ ] args ) throws Exception { } protected void parseAndExecuteMethod ( Method m , Object [ ] args ) throws Exception { Class < ? > [ ] types = m . getParameterTypes ( ) ; if ( ( ( types != null ) && ( ( types . length ) != 0 ) ) && ( ( ( ( types . length ) > 0 ) && ( args == null ) ) || ( ( types . length ) != ( args . length ) ) ) ) { Logger . getLogger ( getClass ( ) ) . info ( ( "Hook<seq2seq4repair_space>call<seq2seq4repair_space>made<seq2seq4repair_space>with<seq2seq4repair_space>incorrect<seq2seq4repair_space>number<seq2seq4repair_space>of<seq2seq4repair_space>arguments:<seq2seq4repair_space>" + ( commandName ) ) ) ; current = new CommandException ( ( ( "Illegal<seq2seq4repair_space>number<seq2seq4repair_space>of<seq2seq4repair_space>arguments<seq2seq4repair_space>in<seq2seq4repair_space>" + ( m . getName ( ) ) ) + "<seq2seq4repair_space>call" ) , commandName ) ; } else if ( args != null ) { for ( int j = 0 ; j < ( types . length ) ; j ++ ) { Class < ? > type = types [ j ] ; Object value = args [ j ] ; if ( ( ! ( value instanceof String ) ) || ( String . class . isAssignableFrom ( type ) ) ) { continue ; } String str = value . toString ( ) ; if ( str . startsWith ( "LocalRef:" ) ) { Integer localRef = Integer . parseInt ( str . substring ( ( ( str . indexOf ( ":" ) ) + 1 ) ) ) ; if ( ! ( store . containsKey ( localRef ) ) ) { current = new CommandException ( "Local<seq2seq4repair_space>object<seq2seq4repair_space>reference<seq2seq4repair_space>does<seq2seq4repair_space>not<seq2seq4repair_space>exist" , commandName ) ; } args [ j ] = store . get ( localRef ) . value ; } else { args [ j ] = APIUtil . deserializeToTargetType ( value , type ) ; } } } try { if ( Modifier . isStatic ( m . getModifiers ( ) ) ) { current = m . invoke ( null , ( ( Object [ ] ) ( args ) ) ) ; } else { if ( ( current ) == null ) { throw new IllegalArgumentException ( "Instance<seq2seq4repair_space>method<seq2seq4repair_space>called<seq2seq4repair_space>as<seq2seq4repair_space>a<seq2seq4repair_space>static<seq2seq4repair_space>method." ) ; } m . setAccessible ( true ) ; current = m . invoke ( current , ( ( Object [ ] ) ( args ) ) ) ; } } catch ( InvocationTargetException ex ) { if ( ( ex . getCause ( ) ) == null ) { Logger . getLogger ( getClass ( ) ) . info ( "Failed<seq2seq4repair_space>to<seq2seq4repair_space>invoke<seq2seq4repair_space>method" , ex ) ; current = new CommandException ( ex , commandName ) ; } else { Logger . getLogger ( getClass ( ) ) . info ( "Hook<seq2seq4repair_space>call<seq2seq4repair_space>threw<seq2seq4repair_space>Exception" , ex . getCause ( ) ) ; if ( ( ex . getCause ( ) ) instanceof BadAPICallException ) { <START_BUG> current = new DetailedCommandException ( commandName , ( ( BadAPICallException ) ( ex . getCause ( ) ) ) . getErrorName ( ) ) ; <END_BUG> } else { current = new CommandException ( ex . getCause ( ) , commandName ) ; } } } } protected Object executeInstruction ( String command , String ref , Object [ ] args ) { } public static class APICall { public String ref ; public Object [ ] args ; } public static class StoredValue { public long lastAccess = System . currentTimeMillis ( ) ; public Object value ; public StoredValue ( Object value ) { } } protected class Housekeeper implements Runnable { @ Override public void run ( ) { } } }

Fix:
current = new DetailedCommandException ( commandName , ( ( BadAPICallException ) ( ex . getCause ( ) ) ) ) ;