auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
public void test() throws Exception { LocalMode lma = LocalMode.newInstance(); StreamingApplication app = new StreamingApplication() { @Override public void populateDAG(DAG dag, Configuration conf) { } }; DAG dag = lma.getDAG(); MyGenerator generator = dag.addOperator( OPERATOR.GENERATOR.name(), MyGenerator.class); generator.setTupleNum( TUPLE_NUM ); hbaseOutputOperator = dag.addOperator( OPERATOR.HBASEOUTPUT.name(), hbaseOutputOperator ); hbaseInputOperator = dag.addOperator(OPERATOR.HBASEINPUT.name(), hbaseInputOperator); TupleCacheOutputOperator output = dag.addOperator(OPERATOR.OUTPUT.name(), TupleCacheOutputOperator.class); dag.addStream("queue1", generator.outputPort, hbaseOutputOperator.input ).setLocality(DAG.Locality.NODE_LOCAL); dag.addStream("queue2", hbaseInputOperator.outputPort, output.inputPort ).setLocality(DAG.Locality.NODE_LOCAL); Configuration conf = new Configuration(false); lma.prepareDAG(app, conf); final LocalMode.Controller lc = lma.getController(); lc.runAsync(); while(true) { try { Thread.sleep(1000); } catch( Exception e ){} logger.info("Tuple row key: ", output.getReceivedTuples()); logger.info( "Received tuple number {}, instance is {}.", output.getReceivedTuples() == null ? 0 : output.getReceivedTuples().size(), System.identityHashCode( output ) ); if( output.getReceivedTuples() != null && output.getReceivedTuples().size() == TUPLE_NUM ) break; } lc.shutdown(); validate( generator.getTuples(), output.getReceivedTuples() ); }

Target:
public void test() throws Exception { LocalMode lma = LocalMode.newInstance(); StreamingApplication app = new StreamingApplication() { @Override public void populateDAG(DAG dag, Configuration conf) { } }; DAG dag = lma.getDAG(); MyGenerator generator = dag.addOperator( OPERATOR.GENERATOR.name(), MyGenerator.class); generator.setTupleNum( TUPLE_NUM ); hbaseOutputOperator = dag.addOperator( OPERATOR.HBASEOUTPUT.name(), hbaseOutputOperator ); hbaseInputOperator = dag.addOperator(OPERATOR.HBASEINPUT.name(), hbaseInputOperator); TupleCacheOutputOperator output = dag.addOperator(OPERATOR.OUTPUT.name(), TupleCacheOutputOperator.class); dag.addStream("queue1", generator.outputPort, hbaseOutputOperator.input ).setLocality(DAG.Locality.NODE_LOCAL); dag.addStream("queue2", hbaseInputOperator.outputPort, output.inputPort ).setLocality(DAG.Locality.NODE_LOCAL); Configuration conf = new Configuration(false); lma.prepareDAG(app, conf); final LocalMode.Controller lc = lma.getController(); lc.runAsync(); long start = System.currentTimeMillis(); while(true) { try { Thread.sleep(1000); } catch( Exception e ){} logger.info("Tuple row key: ", output.getReceivedTuples()); logger.info( "Received tuple number {}, instance is {}.", output.getReceivedTuples() == null ? 0 : output.getReceivedTuples().size(), System.identityHashCode( output ) ); if( output.getReceivedTuples() != null && output.getReceivedTuples().size() == TUPLE_NUM ) { break; } if(System.currentTimeMillis() - start > RUN_DURATION) { throw new RuntimeException("Testcase taking too long"); } } lc.shutdown(); validate( generator.getTuples(), output.getReceivedTuples() ); }
Source:
public void serialize(ProcessVariablesMap<String, Object> processVariablesMap, JsonGenerator gen, SerializerProvider serializers) throws IOException { HashMap<String, ProcessVariableValue> map = new HashMap<>(); for (Map.Entry<String, Object> entry: processVariablesMap.entrySet()) { String name = entry.getKey(); Object value = entry.getValue(); if(value != null) { Class<?> entryTypeClass = entry.getValue() .getClass(); Object entryObjectValue = entry.getValue(); String entryType; if (scalarTypes.contains(entryTypeClass)) { entryType = entryTypeClass.getName(); } else if (Map.class.isInstance(value)) { entryType = Map.class.getName(); } else if (JsonNode.class.isInstance(value)) { entryType = JsonNode.class.getName(); } else { entryType = Map.class.getName(); entryObjectValue = objectMapper.writeValueAsString(entryObjectValue); } String entryValue = conversionService.convert(entryObjectValue, String.class); ProcessVariableValue variableValue = new ProcessVariableValue(entryType, entryValue); map.put(name, variableValue); } else { map.put(name, null); } } gen.writeObject(map); }

Target:
public void serialize(ProcessVariablesMap<String, Object> processVariablesMap, JsonGenerator gen, SerializerProvider serializers) throws IOException { HashMap<String, ProcessVariableValue> map = new HashMap<>(); for (Map.Entry<String, Object> entry : processVariablesMap.entrySet()) { String name = entry.getKey(); Object value = entry.getValue(); map.put(name, buildProcessVariableValue(value)); } gen.writeObject(map); }
Source:
public void generate(final Ds3ApiSpec spec, final FileUtils fileUtils, final Path destDir) throws IOException { this.spec = spec; this.fileUtils = fileUtils; try { generateDs3_H(); generateDs3_C(); } catch (final TemplateException e) { e.printStackTrace(); } catch (final ParseException e) { e.printStackTrace(); } }

Target:
public void generate(final Ds3ApiSpec spec, final FileUtils fileUtils, final Path destDir) throws IOException { this.spec = spec; this.fileUtils = fileUtils; try { final ImmutableList<Enum> allEnums = getAllEnums(spec); final ImmutableList<Struct> allStructs = getStructsOrderedList(spec); final ImmutableList<Request> allRequests = getAllRequests(spec); generateHeader(allEnums, allStructs, allRequests); generateSource(allEnums, allStructs, allRequests); } catch (final ParseException e) { LOG.error("Caught exception: ", e); } }
Source:
public long getSize(File file) throws IOException { Path folder = Paths.get(file.getAbsolutePath()); return Files.walk(folder) .filter(p -> p.toFile().isFile()) .mapToLong(p -> p.toFile().length()) .sum(); }

Target:
public long getSize(File file) throws IOException { assertInDirectory(file); Path folder = Paths.get(file.getAbsolutePath()); return Files.walk(folder) .filter(p -> p.toFile().isFile()) .mapToLong(p -> p.toFile().length()) .sum(); }
Source:
public FEELFnResult<BigDecimal> invoke(@ParameterName( "number" ) BigDecimal number) { if ( number == null ) { return FEELFnResult.ofError( new InvalidParametersEvent( FEELEvent.Severity.ERROR, "number", "cannot be null" ) ); } if ( number.signum() < 0 ) { return FEELFnResult.ofError( new InvalidParametersEvent( FEELEvent.Severity.ERROR, "number", "is negative" ) ); } return FEELFnResult.ofResult( new BigDecimal( Math.sqrt( number.doubleValue() ) ) ); }

Target:
public FEELFnResult<BigDecimal> invoke(@ParameterName( "number" ) BigDecimal number) { if ( number == null ) { return FEELFnResult.ofError( new InvalidParametersEvent( FEELEvent.Severity.ERROR, "number", "cannot be null" ) ); } if ( number.signum() < 0 ) { return FEELFnResult.ofError( new InvalidParametersEvent( FEELEvent.Severity.ERROR, "number", "is negative" ) ); } return FEELFnResult.ofResult( sqrt( EvalHelper.getBigDecimalOrNull( number ) ) ); }
Source:
private static String getMessageClass(ReceiveCommand.Type type) { switch (type) { case CREATE: return "newBranch"; case UPDATE: return "modifyBranch"; case DELETE: return "deleteBranch"; default: return "errorBranch"; } }

Target:
private static String getMessageClass(ReceiveCommand.Type type) { switch (type) { case CREATE: return "newBranch"; case UPDATE: case UPDATE_NONFASTFORWARD: return "modifyBranch"; case DELETE: return "deleteBranch"; default: return "errorBranch"; } }
Source:
public void testEqualsDifferentTypes() { List<Object> a = MutableList.<Object>of("a", 1, "b", false); List<Object> b = Arrays.<Object>asList("a", 1, "b", false); Assert.assertEquals(a, b); }

Target:
public void testEqualsDifferentTypes() { List<Object> a = MutableList.<Object>of("a", 1, "b", false); List<Object> b = Arrays.<Object>asList("a", 1, "b", false); Assert.assertEquals(a, b); Assert.assertEquals(b, a); }
Source:
private void unifyWith(TypeInstance other) throws HaskellTypeError { if (this == other) { return; } if (this.isRigid && other.isRigid) { throw new HaskellTypeError("Can not unify a rigid type variable " + this.name + " with another rigid type variable " + other.name); } other.constraints.mergeConstraintsWith(this.constraints); if (this.isRigid && ! this.constraints.equals(other.constraints)) { throw new HaskellTypeError("Can not add extra constraints to a rigid type variable " + this.name); } other.unifiedVars.addAll(this.unifiedVars); for (ListIterator<WeakReference<TypeVar>> iter = this.unifiedVars.listIterator(); iter.hasNext();) { TypeVar referer = iter.next().get(); if (referer == null) { iter.remove(); } else { referer.instance = other; } } }

Target:
private void unifyWith(TypeInstance other) throws HaskellTypeError { if (this == other) { return; } if (this.isRigid && other.isRigid) { throw new HaskellTypeError("Can not unify a rigid type variable " + this.name + " with another rigid type variable " + other.name); } other.constraints.mergeConstraintsWith(this.constraints); if ((this.isRigid || other.isRigid) && ! this.constraints.equals(other.constraints)) { throw new HaskellTypeError("Can not add extra constraints to a rigid type variable " + this.name); } other.unifiedVars.addAll(this.unifiedVars); for (ListIterator<WeakReference<TypeVar>> iter = this.unifiedVars.listIterator(); iter.hasNext();) { TypeVar referer = iter.next().get(); if (referer == null) { iter.remove(); } else { referer.instance = other; } } }
Source:
public String produceDts(Compiler compiler) { Set<String> provides = new HashSet<>(); for (CompilerInput compilerInput : compiler.getInputsById().values()) { provides.addAll(compilerInput.getProvides()); } out = new StringWriter(); TypedScope topScope = compiler.getTopScope(); Iterable<TypedVar> allSymbols = topScope.getAllSymbols(); for (String provide : provides) { TypedVar symbol = topScope.getOwnSlot(provide); checkArgument(symbol != null, "goog.provide not defined: %s", provide); String namespace = provide; boolean isDefault = false; if (symbol.getType() != null) { if (!symbol.getType().isObject() || symbol.getType().isInterface() || symbol.getType().isFunctionType()) { int lastDot = symbol.getName().lastIndexOf('.'); namespace = lastDot >= 0 ? symbol.getName().substring(0, lastDot) : ""; isDefault = true; } } currentNamespace = namespace; declareNamespace(provide, symbol, isDefault, allSymbols); declareModule(provide, isDefault); } checkState(indent == 0, "indent must be zero after printing, but is %s", indent); return out.toString(); }

Target:
public String produceDts(Compiler compiler) { Set<String> provides = new HashSet<>(); for (CompilerInput compilerInput : compiler.getInputsById().values()) { provides.addAll(compilerInput.getProvides()); } out = new StringWriter(); TypedScope topScope = compiler.getTopScope(); Iterable<TypedVar> allSymbols = topScope.getAllSymbols(); for (String provide : provides) { TypedVar symbol = topScope.getOwnSlot(provide); checkArgument(symbol != null, "goog.provide not defined: %s", provide); checkArgument(symbol.getType() != null, "all symbols should have a type"); String namespace = provide; boolean isDefault = !symbol.getType().isObject() || symbol.getType().isInterface() || symbol.getType().isFunctionType(); if (isDefault) { int lastDot = symbol.getName().lastIndexOf('.'); namespace = lastDot >= 0 ? symbol.getName().substring(0, lastDot) : ""; } declareNamespace(namespace, provide, symbol, isDefault, allSymbols); declareModule(provide, isDefault); } checkState(indent == 0, "indent must be zero after printing, but is %s", indent); return out.toString(); }
Source:
public void testCreateKeyWithTTL() { String localKey = UUID.randomUUID().toString().replaceAll("-", ""); String localValue = UUID.randomUUID().toString().replaceAll("-", ""); Key createdKey = api().createKey(localKey, localValue, 1); assertNotNull(createdKey); assertNotNull(createdKey.node().expiration()); try { Thread.sleep(3000); } catch (InterruptedException e) { e.printStackTrace(); } createdKey = api().getKey(localKey); assertNull(createdKey); }

Target:
public void testCreateKeyWithTTL() { String localKey = randomString(); String localValue = randomString(); Key createdKey = api().createKey(localKey, localValue, 1); assertNotNull(createdKey); assertNotNull(createdKey.node().expiration()); assertTrue(createdKey.node().ttl() == 1); try { Thread.sleep(3000); } catch (InterruptedException e) { Throwables.propagate(e); } createdKey = api().getKey(localKey); assertNull(createdKey); }
Source:
public boolean isValid(String passportNumber) { return passportNumber.matches("^[CFGHJK][0-9]{8}$"); }

Target:
public boolean isValid(String passportNumber) { return passportNumber.matches(VALID_NUMBER_PATTERN); }
Source:
public XMLHighlighting(File file, Charset charset) throws Exception{ content = Files.toString(file, charset); highlightXML(new FileInputStream(file)); }

Target:
public XMLHighlighting(File file, Charset charset) throws Exception{ content = Files.toString(file, charset); highlightXML(new InputStreamReader(new FileInputStream(file), charset)); }
Source:
private void checkFileExistence(AssetFileIdentity fileIdentity, boolean expectedToExist) throws IOException { try (InputStream stream = contentRepoService.getLatestRepoObject(fileIdentity.getFilePath())) { assertNotNull(stream); assertTrue(expectedToExist); } catch (NotFoundException nfe) { throw entityNotFound(nfe.getMessage() + ": " + fileIdentity); } }

Target:
private void checkFileExistence(AssetFileIdentity fileIdentity, boolean expectedToExist) throws IOException { try (InputStream stream = contentRepoService.getLatestRepoObject(fileIdentity.getFilePath())) { assertNotNull(stream); assertTrue(expectedToExist); } catch (ContentRepoException e) { throw e; } catch (NotFoundException nfe) { assertFalse(expectedToExist); } }
Source:
public void GetByCourtIdSuccessful() throws NotFoundException { Court court = dao.getByCourtId(1L); assertThat(court, is(notNullValue())); assertThat(court.municipality, is("Ballwin")); }

Target:
public void GetByCourtIdSuccessful(){ Court court = dao.getByCourtId(1L); assertThat(court, is(notNullValue())); assertThat(court.municipality, is("Ballwin")); }
Source:
public ListenableFuture<?> truncateExportToTxnId(final long txnId) { RunnableWithES runnable = new RunnableWithES("truncateExportToTxnId") { @Override public void run() { try { if (m_mastershipAccepted.get()) { exportLog.info("Export generation " + getGeneration() + " Table " + getTableName() + " mastership already accepted for partition skipping truncation." + getPartitionId()); return; } m_committedBuffers.truncateToTxnId(txnId, m_nullArrayLength); if (m_committedBuffers.isEmpty() && m_endOfStream) { if (m_pollFuture != null) { m_pollFuture.set(null); m_pollFuture = null; } if (m_onDrain != null) { m_drainTraceForDebug = new Exception("Truncation txnId " + txnId); m_onDrain.run(); } } } catch (Throwable t) { VoltDB.crashLocalVoltDB("Error while trying to truncate export to txnid " + txnId, true, t); } } }; return stashOrSubmitTask(runnable, false, true); }

Target:
public ListenableFuture<?> truncateExportToTxnId(final long txnId) { RunnableWithES runnable = new RunnableWithES("truncateExportToTxnId") { @Override public void run() { try { if (m_mastershipAccepted.get()) { if (exportLog.isDebugEnabled()) { exportLog.debug("Export generation " + getGeneration() + " Table " + getTableName() + " mastership already accepted for partition skipping truncation." + getPartitionId()); } return; } m_committedBuffers.truncateToTxnId(txnId, m_nullArrayLength); if (m_committedBuffers.isEmpty() && m_endOfStream) { if (m_pollFuture != null) { m_pollFuture.set(null); m_pollFuture = null; } if (m_onDrain != null) { m_drainTraceForDebug = new Exception("Truncation txnId " + txnId); m_onDrain.run(); } } } catch (Throwable t) { VoltDB.crashLocalVoltDB("Error while trying to truncate export to txnid " + txnId, true, t); } } }; return stashOrSubmitTask(runnable, false, true); }
Source:
public JSONObject getSlaveAttributeForLabel(String labelName) { for (MesosSlaveInfo slaveInfo : slaveInfos) { if(labelName != null) { if (labelName.equals(slaveInfo.getLabelString())) { return slaveInfo.getSlaveAttributes(); } } else { if (slaveInfo.getLabelString() == null) { return slaveInfo.getSlaveAttributes(); } } } return null; }

Target:
public JSONObject getSlaveAttributeForLabel(String labelName) { for (MesosSlaveInfo slaveInfo : slaveInfos) { if (StringUtils.equals(labelName, slaveInfo.getLabelString())) { return slaveInfo.getSlaveAttributes(); } } return null; }
Source:
public String toString() { return Objects.toString(getFirst(), null) + '.' + Objects.toString(getSecond(), null); }

Target:
public String toString() { return Objects.toString(getFirst()) + '.' + Objects.toString(getSecond()); }
Source:
public int crateNodesCount() throws UnirestException { List<String> crateHosts = crateActiveHosts(); if (crateHosts.isEmpty()) { return 0; } JSONArray rows = Unirest.post(String.format("http://%s:4200/_sql", crateHosts.get(0))) .header("Content-Type", "application/json") .body("{\"stmt\": \"select count(*) from sys.nodes\"}") .asJson().getBody().getObject().getJSONArray("rows"); return rows.getJSONArray(0).getInt(0); }

Target:
public int crateNodesCount() throws UnirestException { List<String> crateHosts = crateActiveHosts(); if (crateHosts.isEmpty()) { return 0; } JSONArray rows = Unirest.post(String.format("http://%s:%d/_sql", crateHosts.get(0), HTTP_PORT)) .header("Content-Type", "application/json") .body("{\"stmt\": \"select count(*) from sys.nodes\"}") .asJson().getBody().getObject().getJSONArray("rows"); return rows.getJSONArray(0).getInt(0); }
Source:
public void onReceive(Context context, Intent intent) { if (Intent.ACTION_MEDIA_BUTTON.equals(intent.getAction())) { KeyEvent event = (KeyEvent) intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT); if (event.getAction() == KeyEvent.ACTION_UP) { int keycode = event.getKeyCode(); PendingIntent pendingIntent = null; if (keycode == KeyEvent.KEYCODE_MEDIA_NEXT) { pendingIntent = PendingIntent.getBroadcast(context, NOTIFICATION_ID, new Intent(ACTION_PLAY_NEXT), PendingIntent.FLAG_UPDATE_CURRENT); } else if (keycode == KeyEvent.KEYCODE_MEDIA_PREVIOUS) { pendingIntent = PendingIntent.getBroadcast(context, NOTIFICATION_ID, new Intent(ACTION_PLAY_PREVIOUS), PendingIntent.FLAG_UPDATE_CURRENT); } else if (keycode == KeyEvent.KEYCODE_HEADSETHOOK) { pendingIntent = PendingIntent.getBroadcast(context, NOTIFICATION_ID, new Intent(ACTION_PLAY_PAUSE), PendingIntent.FLAG_UPDATE_CURRENT); } if (pendingIntent != null) { try { pendingIntent.send(); } catch (Exception e) { Log.e(TAG, "Error Sending intent MediaButtonReceiver", e); } } } } }

Target:
public void onReceive(Context context, Intent intent) { if (Intent.ACTION_MEDIA_BUTTON.equals(intent.getAction())) { KeyEvent event = (KeyEvent) intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT); if (event.getAction() == KeyEvent.ACTION_UP) { int keycode = event.getKeyCode(); PendingIntent pendingIntent = null; if (keycode == KeyEvent.KEYCODE_MEDIA_NEXT) { pendingIntent = PendingIntent.getBroadcast(context, NOTIFICATION_ID, new Intent(ACTION_PLAY_NEXT), PendingIntent.FLAG_UPDATE_CURRENT); } else if (keycode == KeyEvent.KEYCODE_MEDIA_PREVIOUS) { pendingIntent = PendingIntent.getBroadcast(context, NOTIFICATION_ID, new Intent(ACTION_PLAY_PREVIOUS), PendingIntent.FLAG_UPDATE_CURRENT); } else if (keycode == KeyEvent.KEYCODE_HEADSETHOOK || keycode == KeyEvent.KEYCODE_MEDIA_PAUSE || keycode == KeyEvent.KEYCODE_MEDIA_PLAY) { pendingIntent = PendingIntent.getBroadcast(context, NOTIFICATION_ID, new Intent(ACTION_PLAY_PAUSE), PendingIntent.FLAG_UPDATE_CURRENT); } else if (keycode == KeyEvent.KEYCODE_MEDIA_FAST_FORWARD) { pendingIntent = PendingIntent.getBroadcast(context, NOTIFICATION_ID, new Intent(ACTION_FAST_FORWARD), PendingIntent.FLAG_UPDATE_CURRENT); } else if (keycode == KeyEvent.KEYCODE_MEDIA_REWIND) { pendingIntent = PendingIntent.getBroadcast(context, NOTIFICATION_ID, new Intent(ACTION_FAST_REWIND), PendingIntent.FLAG_UPDATE_CURRENT); } if (pendingIntent != null) { try { pendingIntent.send(); } catch (Exception e) { Log.e(TAG, "Error Sending intent MediaButtonReceiver", e); } } } } }
Source:
public void testCommitMessage() { assertTrue("should not accept commit message with periods on end", !ACCEPTED_COMMIT_MESSAGE_PATTERN.matcher("minor: Test. Test.").matches()); assertTrue("should not accept commit message with spaces on end", !ACCEPTED_COMMIT_MESSAGE_PATTERN.matcher("minor: Test. ").matches()); assertTrue("should not accept commit message with tabs on end", !ACCEPTED_COMMIT_MESSAGE_PATTERN.matcher("minor: Test.\t").matches()); assertTrue("should not accept commit message with newline on end", !ACCEPTED_COMMIT_MESSAGE_PATTERN.matcher("minor: Test.\n").matches()); assertTrue("should not accept commit message with missing prefix", !ACCEPTED_COMMIT_MESSAGE_PATTERN.matcher("Test. Test").matches()); assertTrue("should accept commit message that ends properly", ACCEPTED_COMMIT_MESSAGE_PATTERN.matcher("minor: Test. Test").matches()); }

Target:
public void testCommitMessage() { assertFalse("should not accept commit message with periods on end", ACCEPTED_COMMIT_MESSAGE_PATTERN.matcher("minor: Test. Test.").matches()); assertFalse("should not accept commit message with spaces on end", ACCEPTED_COMMIT_MESSAGE_PATTERN.matcher("minor: Test. ").matches()); assertFalse("should not accept commit message with tabs on end", ACCEPTED_COMMIT_MESSAGE_PATTERN.matcher("minor: Test.\t").matches()); assertFalse("should not accept commit message with newline on end", ACCEPTED_COMMIT_MESSAGE_PATTERN.matcher("minor: Test.\n").matches()); assertFalse("should not accept commit message with missing prefix", ACCEPTED_COMMIT_MESSAGE_PATTERN.matcher("Test. Test").matches()); assertTrue("should accept commit message that ends properly", ACCEPTED_COMMIT_MESSAGE_PATTERN.matcher("minor: Test. Test").matches()); }
Source:
private void attemptConsensus(Layout layout) throws OutrankedException { try { runtime.getLayoutView().updateLayout(layout, prepareRank); prepareRank = 1L; } catch (OutrankedException oe) { log.error("Conflict in updating layout by attemptConsensus: {}", oe); prepareRank = oe.getNewRank() + 1; throw oe; } for (int x = 0; x < runtime.getParameters().getInvalidateRetry(); x++) { runtime.invalidateLayout(); if (runtime.getLayoutView().getLayout().equals(layout)) { log.info("New Layout Committed = {}", layout); return; } else { log.warn("Runtime recovered with a different layout = {}", runtime.getLayoutView().getLayout()); } log.warn("attemptConsensus: Checking if has been accepted, retry {}", layout, x); } throw new IllegalStateException(String.format("Layout %s was not accepted. " + "Accepted layout is %s", layout, runtime.getLayoutView().getLayout())); }

Target:
private void attemptConsensus(Layout layout) throws OutrankedException { try { runtime.getLayoutView().updateLayout(layout, prepareRank); prepareRank = 1L; } catch (OutrankedException oe) { log.error("Conflict in updating layout by attemptConsensus: {}", oe); prepareRank = oe.getNewRank() + 1; throw oe; } for (int x = 0; x < runtime.getParameters().getInvalidateRetry(); x++) { runtime.invalidateLayout(); if (runtime.getLayoutView().getLayout().equals(layout)) { log.info("New Layout Committed = {}", layout); return; } else { log.warn("Runtime recovered with a different layout = {}", runtime.getLayoutView().getLayout()); } log.warn("attemptConsensus: Checking if has been accepted, retry {}", layout, x); } }
Source:
protected Object invalidRemoteTxReturnValue() { TransactionTable.CompletedTransactionStatus txStatus = txTable.getCompletedTransactionStatus(globalTx); if (txStatus == TransactionTable.CompletedTransactionStatus.COMMITTED) { return null; } else if (txStatus == TransactionTable.CompletedTransactionStatus.ABORTED) { throw new CacheException("Remote transaction already rolled back: " + globalTx); } else if (txStatus == TransactionTable.CompletedTransactionStatus.EXPIRED) { throw new TimeoutException("Remote transaction status missing, please increase transaction.completedTxTimeout: " + globalTx); } else { throw new IllegalStateException("Remote transaction not found: " + globalTx); } }

Target:
protected Object invalidRemoteTxReturnValue() { TransactionTable.CompletedTransactionStatus txStatus = txTable.getCompletedTransactionStatus(globalTx); switch (txStatus) { case COMMITTED: return null; case ABORTED: throw log.remoteTransactionAlreadyRolledBack(globalTx); case EXPIRED: throw log.remoteTransactionStatusMissing(globalTx); default: throw new IllegalStateException("Remote transaction not found: " + globalTx); } }
Source:
protected void pollRecords() { if (isPolled) { return; } try { if (isPollerPartition) { nextOffset = getRecordsCount(); while (lastOffset < nextOffset) { PreparedStatement preparedStatement = store.getConnection().prepareStatement(buildRangeQuery(lastOffset, rangeSize), TYPE_FORWARD_ONLY, CONCUR_READ_ONLY); insertResultsInQueue(preparedStatement); lastOffset = lastOffset + rangeSize; } lastOffset = nextOffset; } else { insertResultsInQueue(ps); } isPolled = true; } catch (SQLException ex) { execute = false; threadException = new AtomicReference<Throwable>(ex); } catch (InterruptedException e) { threadException = new AtomicReference<Throwable>(e); } finally { if (!isPollerPartition) { store.disconnect(); } } isPolled = true; }

Target:
protected void pollRecords() { if (isPolled) { return; } try { if (isPollerPartition) { int nextOffset = getRecordsCount(); while (lastOffset < nextOffset) { PreparedStatement preparedStatement = store.getConnection().prepareStatement(buildRangeQuery(lastOffset, resultLimit), TYPE_FORWARD_ONLY, CONCUR_READ_ONLY); insertDbDataInQueue(preparedStatement); lastOffset = lastOffset + resultLimit; } lastOffset = nextOffset; } else { insertDbDataInQueue(ps); } isPolled = true; } catch (SQLException ex) { execute = false; threadException = new AtomicReference<Throwable>(ex); } catch (InterruptedException e) { threadException = new AtomicReference<Throwable>(e); } finally { if (!isPollerPartition) { store.disconnect(); } } isPolled = true; }
Source:
public static boolean canVmsBePaused(List<VM> items) { boolean result = true; for (VM vm : items) { result &= AsyncDataProvider.isSuspendSupportedByArchitecture(vm.getClusterArch(), vm.getVdsGroupCompatibilityVersion()); } return result; }

Target:
public static boolean canVmsBePaused(List<VM> items) { for (VM vm : items) { if (!AsyncDataProvider.isSuspendSupportedByArchitecture(vm.getClusterArch(), vm.getVdsGroupCompatibilityVersion())) { return false; } } return true; }
Source:
public void invalidateConnectionState() { for (InputAnchor input : ((InputBlock) this).getAllInputs()) { if (!input.isPrimaryConnected() || !getPane().getErrorOccured()) { input.setErrorState(false); } } }

Target:
public void invalidateConnectionState() { for (InputAnchor input : this.getAllInputs()) { if (!input.isPrimaryConnected()) { input.setErrorState(false); } else if (!getPane().getErrorOccured()) { input.setErrorState(false); } } }
Source:
private void handle(ReturnIpMsg msg) { ReturnIpReply reply = new ReturnIpReply(); UsedIpVO ipvo = dbf.findByUuid(msg.getUsedIpUuid(), UsedIpVO.class); if(ipvo != null){ dbf.remove(ipvo); logger.debug(String.format("Successfully released used ip[%s]", msg.getUsedIpUuid())); }else { logger.debug(String.format("used ip[%s] has been released, skip it", msg.getUsedIpUuid())); } bus.reply(msg, reply); }

Target:
private void handle(ReturnIpMsg msg) { ReturnIpReply reply = new ReturnIpReply(); SQL.New(UsedIpVO.class).eq(UsedIpVO_.uuid, msg.getUsedIpUuid()).hardDelete(); logger.debug(String.format("Successfully released used ip[%s]", msg.getUsedIpUuid())); bus.reply(msg, reply); }
Source:
public AbfsInputStream( final AbfsClient client, final Statistics statistics, final String path, final long contentLength, final AbfsInputStreamContext abfsInputStreamContext, final String eTag) { this.client = client; this.statistics = statistics; this.path = path; this.contentLength = contentLength; this.bufferSize = abfsInputStreamContext.getReadBufferSize(); this.readAheadQueueDepth = abfsInputStreamContext.getReadAheadQueueDepth(); this.tolerateOobAppends = abfsInputStreamContext.isTolerateOobAppends(); this.eTag = eTag; this.readAheadEnabled = true; this.alwaysReadBufferSize = abfsInputStreamContext.shouldReadBufferSizeAlways(); this.cachedSasToken = new CachedSASToken( abfsInputStreamContext.getSasTokenRenewPeriodForStreamsInSeconds()); this.streamStatistics = abfsInputStreamContext.getStreamStatistics(); readAheadBlockSize = abfsInputStreamContext.getReadAheadBlockSize(); if (this.bufferSize > readAheadBlockSize) { LOG.debug( "fs.azure.read.request.size[={}] is configured for higher size than " + "fs.azure.read.readahead.blocksize[={}]. Auto-align " + "readAhead block size to be same as readRequestSize.", bufferSize, readAheadBlockSize); readAheadBlockSize = this.bufferSize; } ReadBufferManager.setReadBufferManagerConfigs(readAheadBlockSize); }

Target:
public AbfsInputStream( final AbfsClient client, final Statistics statistics, final String path, final long contentLength, final AbfsInputStreamContext abfsInputStreamContext, final String eTag) { this.client = client; this.statistics = statistics; this.path = path; this.contentLength = contentLength; this.bufferSize = abfsInputStreamContext.getReadBufferSize(); this.readAheadQueueDepth = abfsInputStreamContext.getReadAheadQueueDepth(); this.tolerateOobAppends = abfsInputStreamContext.isTolerateOobAppends(); this.eTag = eTag; this.readAheadEnabled = true; this.alwaysReadBufferSize = abfsInputStreamContext.shouldReadBufferSizeAlways(); this.cachedSasToken = new CachedSASToken( abfsInputStreamContext.getSasTokenRenewPeriodForStreamsInSeconds()); this.streamStatistics = abfsInputStreamContext.getStreamStatistics(); readAheadBlockSize = abfsInputStreamContext.getReadAheadBlockSize(); ReadBufferManager.setReadBufferManagerConfigs(readAheadBlockSize); }
Source:
public void saveForm_wontRunMultipleSavesAtOnce() { viewModel.saveForm(Uri.parse("file://form"), true, "", false); LiveData<FormSaveViewModel.SaveResult> saveResult1 = viewModel.getSavedResult(); assertThat(saveResult1.getValue().getState(), equalTo(SAVING)); viewModel.saveForm(Uri.parse("file://form"), true, "", false); LiveData<FormSaveViewModel.SaveResult> saveResult2 = viewModel.getSavedResult(); assertThat(saveResult2.getValue().getState(), equalTo(ALREADY_SAVING)); assertThat(Robolectric.getBackgroundThreadScheduler().size(), equalTo(1)); whenFormSaverFinishes(SaveFormToDisk.SAVED); assertThat(saveResult1.getValue().getState(), equalTo(SAVED)); }

Target:
public void saveForm_wontRunMultipleSavesAtOnce() { viewModel.saveForm(Uri.parse("file://form"), true, "", false); viewModel.saveForm(Uri.parse("file://form"), true, "", false); whenFormSaverFinishes(SaveFormToDisk.SAVED); verify(formSaver).save(any(), any(), anyBoolean(), anyBoolean(), any(), any()); Robolectric.getBackgroundThreadScheduler().advanceToLastPostedRunnable(); verify(formSaver, times(1)).save(any(), any(), anyBoolean(), anyBoolean(), any(), any()); }
Source:
public static <A> Strategy<A> errorStrategy(final Strategy<A> s, final Effect1<Error> e) { return s.comap(a -> new P1<A>() { public A _1() { try { return a._1(); } catch (Throwable t) { final Error error = new Error(t); e.f(error); throw error; } } }); }

Target:
public static <A> Strategy<A> errorStrategy(final Strategy<A> s, final Effect1<Error> e) { return s.comap(a -> P.lazy(u -> { try { return a._1(); } catch (Throwable t) { final Error error = new Error(t); e.f(error); throw error; } }) ); }
Source:
protected void sendEvent(Event event) { if (traceEnabled) { trace.info(afterTracerPrefix + event); } if (statisticsEnabled) { statisticsMonitor.incrementRequest(); } if ((!(mode == Mode.Distributed) || !isEventDuplicatedInCluster || EventReceiverServiceValueHolder.getCarbonEventReceiverManagementService().isReceiverCoordinator()) && !isManagerNode) { this.inputEventDispatcher.onEvent(event); } }

Target:
protected void sendEvent(Event event) { if (traceEnabled) { trace.info(afterTracerPrefix + event); } if (statisticsEnabled) { statisticsMonitor.incrementRequest(); } if (sufficientToSend || (!isManagerNode && EventReceiverServiceValueHolder.getCarbonEventReceiverManagementService().isReceiverCoordinator())) { this.inputEventDispatcher.onEvent(event); } }
Source:
public static List<String> getActualPropertyName(final SimpleFeatureType featureType, final List<String> propertyNames) { assert featureType != null : "featureType cannot be null"; assert propertyNames != null : "propertyName != cannot be null"; List<String> nameList = new LinkedList<String>(); for (String property : propertyNames) { String name = getActualPropertyName(featureType, property); if (name != null) { nameList.add(name); } } return nameList; }

Target:
public static List<String> getActualPropertyName(final SimpleFeatureType featureType, final List<String> propertyNames) { if (featureType == null) { throw new IllegalArgumentException("featureType cannot be null"); } if (propertyNames == null) { throw new IllegalArgumentException("propertyName cannot be null"); } List<String> nameList = new LinkedList<String>(); for (String property : propertyNames) { String name = getActualPropertyName(featureType, property); if (name != null) { nameList.add(name); } } return nameList; }
Source:
private void validateKeys(final PublicKey pubKey, final PrivateKey privKey) { if (pubKey.getAlgorithm() != privKey.getAlgorithm()) { throw new IllegalArgumentException("Public and private key have different algorithms"); } if (pubKey.getAlgorithm() != "RSA") { return; } try { final String data = "ENCRYPT_DATA"; final SecureRandom random = new SecureRandom(); final Cipher cipher = Cipher.getInstance(pubKey.getAlgorithm()); cipher.init(Cipher.ENCRYPT_MODE, privKey, random); final byte[] encryptedData = cipher.doFinal(data.getBytes()); cipher.init(Cipher.DECRYPT_MODE, pubKey, random); final String decreptedData = new String(cipher.doFinal(encryptedData)); if (!decreptedData.equals(data)) { throw new IllegalArgumentException("Bad public-private key"); } } catch (final BadPaddingException e) { throw new IllegalArgumentException("Bad public-private key", e); } catch (final IllegalBlockSizeException e) { throw new IllegalArgumentException("Bad public-private key", e); } catch (final NoSuchPaddingException e) { throw new IllegalArgumentException("Bad public-private key", e); } catch (final InvalidKeyException e) { throw new IllegalArgumentException("Invalid public-private key", e); } catch (final NoSuchAlgorithmException e) { throw new IllegalArgumentException("Invalid algorithm for public-private key", e); } }

Target:
private void validateKeys(final PublicKey pubKey, final PrivateKey privKey) { Preconditions.checkNotNull(pubKey); Preconditions.checkNotNull(privKey); if (!pubKey.getAlgorithm().equals(privKey.getAlgorithm())) { throw new IllegalArgumentException("Public and private key have different algorithms"); } if (pubKey.getAlgorithm() != "RSA") { return; } try { final String data = "ENCRYPT_DATA"; final SecureRandom random = new SecureRandom(); final Cipher cipher = Cipher.getInstance(pubKey.getAlgorithm()); cipher.init(Cipher.ENCRYPT_MODE, privKey, random); final byte[] encryptedData = cipher.doFinal(data.getBytes()); cipher.init(Cipher.DECRYPT_MODE, pubKey, random); final String decreptedData = new String(cipher.doFinal(encryptedData)); if (!decreptedData.equals(data)) { throw new IllegalStateException("Bad public-private key"); } } catch (final BadPaddingException | IllegalBlockSizeException | InvalidKeyException | NoSuchPaddingException e) { throw new IllegalStateException("Bad public-private key", e); } catch (final NoSuchAlgorithmException e) { throw new IllegalStateException("Invalid algorithm for public-private key", e); } }
Source:
public void onError(Session session, Throwable ex) { if (ex instanceof SecureWebSocketException) { SecurityLogger.audit("Received WebSockets request for user that is not logged in."); handleMessage( session, ((SecureWebSocketException) ex).getWsMessage(), (message, id) -> error(NOT_LOGGED_IN_ERROR, ex.getMessage())); } else { } }

Target:
public void onError(Session session, Throwable ex) { if (ex instanceof WebSocketAuthenticationException) { SecurityLogger.audit("Received WebSockets request for user that is not logged in."); handleMessage( session, ((WebSocketAuthenticationException) ex).getWsMessage(), (message, id) -> error(NOT_LOGGED_IN_ERROR, ex.getMessage())); } else { } }
Source:
public List<FeedbackSessionAttributes> getFeedbackSessionsWithinTimeRange(Instant rangeStart, Instant rangeEnd) { List<FeedbackSession> lst = new LinkedList<>(); List<FeedbackSession> startEntities = load() .filter("startTime >=", rangeStart) .filter("startTime <", rangeEnd) .list(); List<FeedbackSession> endEntities = load() .filter("endTime >=", rangeStart) .filter("endTime <", rangeEnd) .list(); List<FeedbackSession> resultsVisibleEntities = load() .filter("resultsVisibleFromTime >", rangeStart) .filter("resultsVisibleFromTime <=", rangeEnd) .list(); endEntities.removeAll(startEntities); resultsVisibleEntities.removeAll(startEntities); resultsVisibleEntities.removeAll(endEntities); lst.addAll(startEntities); lst.addAll(endEntities); lst.addAll(resultsVisibleEntities); return makeAttributes(lst).stream() .sorted(Comparator.comparing(FeedbackSessionAttributes::getStartTime)) .filter(fs -> !fs.isSessionDeleted()) .collect(Collectors.toList()); }

Target:
public List<FeedbackSessionAttributes> getFeedbackSessionsWithinTimeRange(Instant rangeStart, Instant rangeEnd) { List<FeedbackSession> feedbackSessionList = new LinkedList<>(); List<FeedbackSession> startEntities = load() .filter("startTime >=", rangeStart) .filter("startTime <", rangeEnd) .list(); List<FeedbackSession> endEntities = load() .filter("endTime >=", rangeStart) .filter("endTime <", rangeEnd) .list(); List<FeedbackSession> resultsVisibleEntities = load() .filter("resultsVisibleFromTime >", rangeStart) .filter("resultsVisibleFromTime <=", rangeEnd) .list(); endEntities.removeAll(startEntities); resultsVisibleEntities.removeAll(startEntities); resultsVisibleEntities.removeAll(endEntities); feedbackSessionList.addAll(startEntities); feedbackSessionList.addAll(endEntities); feedbackSessionList.addAll(resultsVisibleEntities); return makeAttributes(feedbackSessionList).stream() .sorted(Comparator.comparing(FeedbackSessionAttributes::getStartTime)) .filter(fs -> !fs.isSessionDeleted()) .collect(Collectors.toList()); }
Source:
public Statement apply(Statement base, Description description) { if (description.getAnnotation(SuppressUndeliverable.class) != null) { return new Statement() { @Override public void evaluate() throws Throwable { try { RxJavaPlugins.setErrorHandler(new Consumer<Throwable>() { @Override public void accept(Throwable throwable) throws Throwable { if (!(throwable instanceof UndeliverableException)) { RxJavaPlugins.getDefaultErrorHandler().accept(throwable); } } }); base.evaluate(); } finally { RxJavaPlugins.setErrorHandler(null); } } }; } else { return base; } }

Target:
public Statement apply(Statement base, Description description) { if (description.getAnnotation(SuppressUndeliverable.class) != null) { return new Statement() { @Override public void evaluate() throws Throwable { try { RxJavaPlugins.setErrorHandler(throwable -> { if (!(throwable instanceof UndeliverableException)) { throwable.printStackTrace(); Thread currentThread = Thread.currentThread(); currentThread.getUncaughtExceptionHandler().uncaughtException(currentThread, throwable); } }); base.evaluate(); } finally { RxJavaPlugins.setErrorHandler(null); } } }; } else { return base; } }
Source:
public AsyncContext startAsync() throws IllegalStateException { throw new UnsupportedOperationException(); }

Target:
public AsyncContext startAsync() { throw new UnsupportedOperationException(); }
Source:
public void testRoundRobinLocationSelectorStrategy() throws Exception { List<StorageLocation> storageLocations = new ArrayList<>(); final File localStorageFolder1 = tmpFolder.newFolder("local_storage_folder_1"); final File localStorageFolder2 = tmpFolder.newFolder("local_storage_folder_2"); final File localStorageFolder3 = tmpFolder.newFolder("local_storage_folder_3"); storageLocations.add(new StorageLocation(localStorageFolder1, 10000000000L, null)); storageLocations.add(new StorageLocation(localStorageFolder2, 10000000000L, null)); storageLocations.add(new StorageLocation(localStorageFolder3, 10000000000L, null)); StorageLocationSelectorStrategy roundRobinStrategy = new RoundRobinStorageLocationSelectorStrategy(storageLocations); Iterator<StorageLocation> locations = roundRobinStrategy.getLocations(); StorageLocation loc1 = locations.next(); Assert.assertTrue("The next element of the iterator should point to path local_storage_folder_1", loc1.getPath().equals(localStorageFolder1)); StorageLocation loc2 = locations.next(); Assert.assertTrue("The next element of the iterator should point to path local_storage_folder_2", loc2.getPath().equals(localStorageFolder2)); StorageLocation loc3 = locations.next(); Assert.assertTrue("The next element of the iterator should point to path local_storage_folder_3", loc3.getPath().equals(localStorageFolder3)); StorageLocation loc4 = locations.next(); Assert.assertTrue("The next element of the iterator should point to path local_storage_folder_1", loc4.getPath().equals(localStorageFolder1)); }

Target:
public void testRoundRobinLocationSelectorStrategy() throws Exception { List<StorageLocation> storageLocations = new ArrayList<>(); final File localStorageFolder1 = tmpFolder.newFolder("local_storage_folder_1"); final File localStorageFolder2 = tmpFolder.newFolder("local_storage_folder_2"); final File localStorageFolder3 = tmpFolder.newFolder("local_storage_folder_3"); storageLocations.add(new StorageLocation(localStorageFolder1, 10000000000L, null)); storageLocations.add(new StorageLocation(localStorageFolder2, 10000000000L, null)); storageLocations.add(new StorageLocation(localStorageFolder3, 10000000000L, null)); StorageLocationSelectorStrategy roundRobinStrategy = new RoundRobinStorageLocationSelectorStrategy(storageLocations); iterateLocs(localStorageFolder1, localStorageFolder2, localStorageFolder3, roundRobinStrategy); iterateLocs(localStorageFolder1, localStorageFolder2, localStorageFolder3, roundRobinStrategy); iterateLocs(localStorageFolder1, localStorageFolder2, localStorageFolder3, roundRobinStrategy); iterateLocs(localStorageFolder1, localStorageFolder2, localStorageFolder3, roundRobinStrategy); iterateLocs(localStorageFolder1, localStorageFolder2, localStorageFolder3, roundRobinStrategy); }
Source:
static Map<String, String> getHeaders(RequestOptions options) { Map<String, String> headers = new HashMap<String, String>(); String apiVersion = options.getStripeVersion(); headers.put("Accept-Charset", CHARSET); headers.put("User-Agent", String.format("Stripe/v1 JavaBindings/%s", Stripe.VERSION)); headers.put("Authorization", String.format("Bearer %s", options.getApiKey())); String[] propertyNames = { "os.name", "os.version", "os.arch", "java.version", "java.vendor", "java.vm.version", "java.vm.vendor" }; Map<String, String> propertyMap = new HashMap<String, String>(); for (String propertyName : propertyNames) { propertyMap.put(propertyName, System.getProperty(propertyName)); } propertyMap.put("bindings.version", Stripe.VERSION); propertyMap.put("lang", "Java"); propertyMap.put("publisher", "Stripe"); headers.put("X-Stripe-Client-User-Agent", GSON.toJson(propertyMap)); if (apiVersion != null) { headers.put("Stripe-Version", apiVersion); } if (options.getIdempotentRequest()!= null) { headers.put("Idempotent-Request", options.getIdempotentRequest()); } return headers; }

Target:
static Map<String, String> getHeaders(RequestOptions options) { Map<String, String> headers = new HashMap<String, String>(); String apiVersion = options.getStripeVersion(); headers.put("Accept-Charset", CHARSET); headers.put("User-Agent", String.format("Stripe/v1 JavaBindings/%s", Stripe.VERSION)); headers.put("Authorization", String.format("Bearer %s", options.getApiKey())); String[] propertyNames = { "os.name", "os.version", "os.arch", "java.version", "java.vendor", "java.vm.version", "java.vm.vendor" }; Map<String, String> propertyMap = new HashMap<String, String>(); for (String propertyName : propertyNames) { propertyMap.put(propertyName, System.getProperty(propertyName)); } propertyMap.put("bindings.version", Stripe.VERSION); propertyMap.put("lang", "Java"); propertyMap.put("publisher", "Stripe"); headers.put("X-Stripe-Client-User-Agent", GSON.toJson(propertyMap)); if (apiVersion != null) { headers.put("Stripe-Version", apiVersion); } if (options.getIdempotencyKey() != null) { headers.put("Idempotency-Key", options.getIdempotencyKey()); } return headers; }
Source:
public boolean preNext(MethodInvocation curElement) { if (curElement.arguments().size() == 2) { Expression target = (Expression) curElement.arguments().get(1); String targetName = target.toString(); compiler.activateLifeline(targetName); return true; } Expression sender = (Expression) curElement.arguments().get(0); String senderName = sender.toString(); Expression target = (Expression) curElement.arguments().get(2); String targetName = target.toString(); Expression signal = (Expression) curElement.arguments().get(1); String signalExpr = signal.resolveTypeBinding().getQualifiedName(); compiler.println(senderName + "->" + targetName + " : " + signalExpr); compiler.activateLifeline(targetName); return true; }

Target:
public boolean preNext(MethodInvocation curElement) { if (curElement.arguments().size() == 2) { return true; } Expression sender = (Expression) curElement.arguments().get(0); String senderName = sender.toString(); Expression target = (Expression) curElement.arguments().get(2); String targetName = target.toString(); Expression signal = (Expression) curElement.arguments().get(1); String signalExpr = signal.resolveTypeBinding().getQualifiedName(); compiler.println(senderName + "->" + targetName + " : " + signalExpr); return true; }
Source:
public void endLatency(Object latencyId, String service, String stormIdName, String stormIdValue, Throwable er) { if(startTimestampPerId.containsKey(latencyId)) { long elapsed = NANOSECONDS.toMillis(System.nanoTime() - startTimestampPerId.get(latencyId)); if(stormIdName != null && stormIdValue != null) { eventSender.send(new LatencyEvent(elapsed) .service(service) .error(er) .attribute(stormIdName, stormIdValue)); } else { eventSender.send(new LatencyEvent(elapsed).service(service).error(er)); } startTimestampPerId.remove(latencyId); if (logger.isDebugEnabled()) { logger.debug("Monitored latency for key {}", elapsed, latencyId); } } else { eventSender.send(new ExceptionEvent("Latency monitor doesn't recognize key.").service(service)); if (er == null) { logger.warn("Latency monitor doesn't recognize key {}.", latencyId); } else { eventSender.send(new ExceptionEvent(er).service(service)); logger.warn("Latency monitor doesn't recognize key {}. Swallowed exception {}", latencyId, er); } } }

Target:
public void endLatency(Object latencyId, String service, String stormIdName, String stormIdValue, Throwable er) { if(startTimestampPerId.containsKey(latencyId)) { long elapsed = NANOSECONDS.toMillis(System.nanoTime() - startTimestampPerId.get(latencyId)); LatencyEvent event = new LatencyEvent(elapsed).service(service).error(er); if(stormIdName != null && stormIdValue != null) { event.attribute(stormIdName, stormIdValue); } eventSender.send(event); startTimestampPerId.remove(latencyId); if (logger.isDebugEnabled()) { logger.debug("Monitored latency for key {}", elapsed, latencyId); } } else { eventSender.send(new ExceptionEvent("Latency monitor doesn't recognize key.").service(service)); if (er == null) { logger.warn("Latency monitor doesn't recognize key {}.", latencyId); } else { eventSender.send(new ExceptionEvent(er).service(service)); logger.warn("Latency monitor doesn't recognize key {}. Swallowed exception {}", latencyId, er); } } }
Source:
public void visitNode(AstNode node) { if (node.is(PythonGrammar.ATTRIBUTE_REF, PythonGrammar.ATOM)) { checkQuestionableHashingAlgorithm(node); } else if (node.is(PythonGrammar.EXPRESSION_STMT)) { checkOverwriteDjangoHashers(node); } else if (node.is(PythonGrammar.CLASSDEF)) { checkCreatingCustomHasher(node); } else if (node.is(PythonGrammar.CALL_EXPR)) { super.visitNode(node); } }

Target:
public void visitNode(AstNode node) { PythonGrammar nodeType = (PythonGrammar) node.getType(); switch (nodeType) { case ATTRIBUTE_REF: case ATOM: checkQuestionableHashingAlgorithm(node); break; case EXPRESSION_STMT: checkOverwriteDjangoHashers(node); break; case CLASSDEF: checkCreatingCustomHasher(node); break; case CALL_EXPR: super.visitNode(node); default: } }