Buggy code:
public class ZAProxyScanner implements ScanningProxy , Spider { Logger log = Logger . getLogger ( ZAProxyScanner . class . getName ( ) ) ; private static final String MINIMUM_ZAP_DAILY_VERSION = "D-2013-11-17" ; private static final String MINIMUM_ZAP_VERSION = "2.3" ; private final ClientApi clientApi ; private final Proxy seleniumProxy ; private final String apiKey ; public ZAProxyScanner ( String host , int port , String apiKey ) throws IllegalArgumentException , ProxyException { } private static void validateHost ( String host ) { } private static void validatePort ( int port ) { } private void validateMinimumRequiredZapVersion ( ) throws ProxyException { } @ Override public void setScannerAttackStrength ( String scannerId , String strength ) throws ProxyException { } @ Override public void setScannerAlertThreshold ( String scannerId , String threshold ) throws ProxyException { } @ Override public void setEnableScanners ( String ids , boolean enabled ) throws ProxyException { } @ Override public void disableAllScanners ( ) throws ProxyException { } @ Override public void enableAllScanners ( ) throws ProxyException { } @ Override public void setEnablePassiveScan ( boolean enabled ) throws ProxyException { } public List < Alert > getAlerts ( ) throws ProxyException { } public void deleteAlerts ( ) throws ProxyException { } public byte [ ] getXmlReport ( ) { } public List < Alert > getAlerts ( int start , int count ) throws ProxyException { } public int getAlertsCount ( ) throws ProxyException { } public void scan ( String url ) throws ProxyException { } public int getScanProgress ( int id ) throws ProxyException { } public void clear ( ) throws ProxyException { try { <START_BUG> clientApi . ascan . removeAllScans ( null ) ; <END_BUG> clientApi . core . newSession ( apiKey , "" , "" ) ; } catch ( ClientApiException e ) { e . printStackTrace ( ) ; throw new ProxyException ( e ) ; } } public List < HarEntry > getHistory ( ) throws ProxyException { } public List < HarEntry > getHistory ( int start , int count ) throws ProxyException { } public int getHistoryCount ( ) throws ProxyException { } public List < HarEntry > findInResponseHistory ( String regex , List < HarEntry > entries ) { } public List < HarEntry > findInRequestHistory ( String regex ) throws ProxyException { } public List < HarEntry > findInResponseHistory ( String regex ) throws ProxyException { } public List < HarEntry > makeRequest ( HarRequest request , boolean followRedirect ) throws ProxyException { } public Proxy getSeleniumProxy ( ) throws UnknownHostException { } private static int compareZapVersions ( String version , String otherVersion ) { } @ Override public void spider ( String url ) { } @ Override public void excludeFromSpider ( String regex ) { } @ Override public void excludeFromScanner ( String regex ) { } @ Override public void setMaxDepth ( int depth ) { } @ Override public void setPostForms ( boolean post ) { } @ Override public void setThreadCount ( int threads ) { } @ Override public int getLastSpiderScanId ( ) { } @ Override public int getLastScannerScanId ( ) { } @ Override public int getSpiderProgress ( int id ) { } @ Override public List < String > getSpiderResults ( int id ) { } private static class ClientApiUtils { private ClientApiUtils ( ) { } public static int getInteger ( ApiResponse response ) throws ClientApiException { } public static String convertHarRequestToString ( HarRequest request ) throws ClientApiException { } public static HarLog createHarLog ( byte [ ] bytesHarLog ) throws ClientApiException { } public static List < HarEntry > getHarEntries ( byte [ ] bytesHarLog ) throws ClientApiException { } } }

Fix:
clientApi . ascan . removeAllScans ( apiKey ) ;