auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
public PagarMeResponse execute() throws PagarMeException { final StringBuilder builder = new StringBuilder(); int responseCode = -1; try { if (method.equalsIgnoreCase(HttpMethod.POST) || method.equalsIgnoreCase(HttpMethod.PUT) || method.equalsIgnoreCase(HttpMethod.DELETE)) { httpClient.setDoOutput(true); if (parameters.size() > 0) { String json = JSONUtils.getInterpreter().toJson(parameters); final byte[] payload = JSONUtils.getInterpreter().toJson(parameters).getBytes(); httpClient.addRequestProperty("Content-Type", "application/json"); httpClient.addRequestProperty("Content-Length", String.valueOf(payload.length)); final OutputStream os = httpClient.getOutputStream(); os.write(payload); os.flush(); } } try { is = httpClient.getInputStream(); responseCode = httpClient.getResponseCode(); } catch (IOException e) { is = httpClient.getErrorStream(); responseCode = httpClient.getResponseCode(); } final BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8")); String line; while ((line = reader.readLine()) != null) { builder.append(line); builder.append('\r'); } reader.close(); httpClient.disconnect(); return new PagarMeResponse(responseCode, JSONUtils.getInterpreter().fromJson(builder.toString(), JsonElement.class)); } catch (Exception e) { if (e instanceof JsonSyntaxException) { throw new PagarMeException(responseCode, url, method, builder.toString()); } throw PagarMeException.buildWithError(e); } }

Target:
public PagarMeResponse execute() throws PagarMeException { final StringBuilder builder = new StringBuilder(); int responseCode = -1; try { if (method.equalsIgnoreCase(HttpMethod.POST) || method.equalsIgnoreCase(HttpMethod.PUT) || method.equalsIgnoreCase(HttpMethod.DELETE)) { httpClient.setDoOutput(true); if (parameters.size() > 0) { final byte[] payload = JSONUtils.getInterpreter().toJson(parameters).getBytes(); httpClient.addRequestProperty("Content-Type", "application/json"); httpClient.addRequestProperty("Content-Length", String.valueOf(payload.length)); final OutputStream os = httpClient.getOutputStream(); os.write(payload); os.flush(); } } try { is = httpClient.getInputStream(); responseCode = httpClient.getResponseCode(); } catch (IOException e) { is = httpClient.getErrorStream(); responseCode = httpClient.getResponseCode(); } final BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8")); String line; while ((line = reader.readLine()) != null) { builder.append(line); builder.append('\r'); } reader.close(); httpClient.disconnect(); return new PagarMeResponse(responseCode, JSONUtils.getInterpreter().fromJson(builder.toString(), JsonElement.class)); } catch (Exception e) { if (e instanceof JsonSyntaxException) { throw new PagarMeException(responseCode, url, method, builder.toString()); } throw PagarMeException.buildWithError(e); } }
Source:
public void shouldSendRecordViaCorrectSourceTopic() { testDriver = new TopologyTestDriver(setupMultipleSourceTopology(SOURCE_TOPIC_1, SOURCE_TOPIC_2), config); final List<String> processedRecords1 = supplier.capturedProcessors(2).get(0).processed; final List<String> processedRecords2 = supplier.capturedProcessors(2).get(1).processed; testDriver.pipeInput(consumerRecord1); assertEquals(1, processedRecords1.size()); assertEquals(0, processedRecords2.size()); String record = processedRecords1.get(0); String expectedResult = MockProcessor.makeRecord(consumerRecord1.key(), consumerRecord1.value(), consumerRecord1.timestamp()); assertThat(record, equalTo(expectedResult)); testDriver.pipeInput(consumerRecord2); assertEquals(1, processedRecords1.size()); assertEquals(1, processedRecords2.size()); record = processedRecords2.get(0); expectedResult = MockProcessor.makeRecord(consumerRecord2.key(), consumerRecord2.value(), consumerRecord2.timestamp()); assertThat(record, equalTo(expectedResult)); }

Target:
public void shouldSendRecordViaCorrectSourceTopic() { testDriver = new TopologyTestDriver(setupMultipleSourceTopology(SOURCE_TOPIC_1, SOURCE_TOPIC_2), config); final List<Record> processedRecords1 = mockProcessors.get(0).processedRecords; final List<Record> processedRecords2 = mockProcessors.get(1).processedRecords; testDriver.pipeInput(consumerRecord1); assertEquals(1, processedRecords1.size()); assertEquals(0, processedRecords2.size()); Record record = processedRecords1.get(0); Record expectedResult = new Record(consumerRecord1, 0L); assertThat(record, equalTo(expectedResult)); testDriver.pipeInput(consumerRecord2); assertEquals(1, processedRecords1.size()); assertEquals(1, processedRecords2.size()); record = processedRecords2.get(0); expectedResult = new Record(consumerRecord2, 0L); assertThat(record, equalTo(expectedResult)); }
Source:
public List<Document> saveAll(final Table table, List<Document> documents) { if(documents == null || documents.isEmpty()) { throw FoxtrotExceptions.createBadRequestException(table.getName(), "null/empty document list not allowed"); } List<Put> puts = new ArrayList<>(); ImmutableList.Builder<Document> translatedDocuments = ImmutableList.builder(); List<String> errorMessages = new ArrayList<>(); try { for(int i = 0; i < documents.size(); i++) { Document document = documents.get(i); if(!isValidDocument(document, errorMessages, i)) { continue; } Document translatedDocument = translator.translate(table, document); puts.add(getPutForDocument(translatedDocument)); translatedDocuments.add(translatedDocument); } } catch (JsonProcessingException e) { throw FoxtrotExceptions.createBadRequestException(table, e); } if(!errorMessages.isEmpty()) { throw FoxtrotExceptions.createBadRequestException(table.getName(), errorMessages); } try (org.apache.hadoop.hbase.client.Table hTable = tableWrapper.getTable(table)) { hTable.put(puts); } catch (IOException e) { logger.error("Error occurred while ingesting event in HBase : {}", e, e.getCause(), e.getMessage()); throw FoxtrotExceptions.createConnectionException(table, e); } return translatedDocuments.build(); }

Target:
public List<Document> saveAll(final Table table, List<Document> documents) { if(documents == null || documents.isEmpty()) { throw FoxtrotExceptions.createBadRequestException(table.getName(), "null/empty document list not allowed"); } List<Put> puts = new ArrayList<>(); ImmutableList.Builder<Document> translatedDocuments = ImmutableList.builder(); List<String> errorMessages = new ArrayList<>(); try { for(int i = 0; i < documents.size(); i++) { Document document = documents.get(i); if(!isValidDocument(document, errorMessages, i)) { continue; } Document translatedDocument = translator.translate(table, document); puts.add(getPutForDocument(translatedDocument)); translatedDocuments.add(translatedDocument); } } catch (JsonProcessingException e) { throw FoxtrotExceptions.createBadRequestException(table, e); } if(!errorMessages.isEmpty()) { throw FoxtrotExceptions.createBadRequestException(table.getName(), errorMessages); } try (org.apache.hadoop.hbase.client.Table hTable = tableWrapper.getTable(table)) { hTable.put(puts); } catch (IOException e) { logger.error("Error occurred while ingesting event in HBase : ", e); throw FoxtrotExceptions.createConnectionException(table, e); } return translatedDocuments.build(); }
Source:
public void push(RowMap r) throws Exception { String value = r.toJSON(outputConfig); if (value == null) { return; } String routingKey = r.getDatabase() + "." + r.getTable(); channel.basicPublish(exchangeName, routingKey, null, value.getBytes()); if ( r.isTXCommit() ) { context.setPosition(r.getPosition()); } if ( LOGGER.isDebugEnabled()) { LOGGER.debug("-> routing key:" + routingKey + ", partition:" + value); } }

Target:
public void push(RowMap r) throws Exception { if ( !r.shouldOutput(outputConfig) ) { context.setPosition(r.getPosition()); return; } String value = r.toJSON(outputConfig); String routingKey = getRoutingKeyFromTemplate(r); channel.basicPublish(exchangeName, routingKey, null, value.getBytes()); if ( r.isTXCommit() ) { context.setPosition(r.getPosition()); } if ( LOGGER.isDebugEnabled()) { LOGGER.debug("-> routing key:" + routingKey + ", partition:" + value); } }
Source:
public void testResponseStreamIsReadable() throws Exception { final RestResponse response = getStreamTestResponse(); try (InputStream in = response.asInputStream()) { assertStreamTestResponseStreamIsValid(in); } catch (IOException e) { fail("The InputStream should be readable and an IOException should not have been thrown"); } catch (JSONException e) { fail("Valid JSON data should have been returned"); } finally { response.consumeQuietly(); } }

Target:
public void testResponseStreamIsReadable() throws Exception { final RestResponse response = getStreamTestResponse(); try { InputStream in = response.asInputStream(); assertStreamTestResponseStreamIsValid(in); } catch (IOException e) { fail("The InputStream should be readable and an IOException should not have been thrown"); } catch (JSONException e) { fail("Valid JSON data should have been returned"); } finally { response.consumeQuietly(); } }
Source:
private Object[] getCachedChildren(Object parent) { if (parent == null) { return new Object[0]; } Object[] children = m_childMap.get(parent); if (children == null || children.length == 0) { ITreeNode scoutNode = (ITreeNode) parent; children = scoutNode.getFilteredChildNodes(); m_childMap.put(parent, children); for (int i = 0; i < children.length; i++) { m_childIndexMap.put(children[i], i); } } return children; }

Target:
private Object[] getCachedChildren(Object parent) { Object[] children = m_childMap.get(parent); if (children == null || children.length == 0) { ITreeNode scoutNode = (ITreeNode) parent; children = scoutNode.getFilteredChildNodes(); m_childMap.put(parent, children); for (int i = 0; i < children.length; i++) { m_childIndexMap.put(children[i], i); } } return children; }
Source:
public TransformSpatialPredicates(Metadata metadata) { this.metadata = metadata; }

Target:
public TransformSpatialPredicates(Metadata metadata) { this.metadata = requireNonNull(metadata, "metadata is null"); }
Source:
public double[] solveFToD(float[] b) { RealVector bVec = new ArrayRealVector(b.length); for (int i = 0; i < b.length; i++) { bVec.setEntry(i, b[i]); } RealVector vec = solver.solve(bVec); double[] result = new double[b.length]; for (int i = 0; i < result.length; i++) { result[i] = vec.getEntry(i); } return result; }

Target:
public double[] solveFToD(float[] b) { RealVector bVec = new ArrayRealVector(b.length); for (int i = 0; i < b.length; i++) { bVec.setEntry(i, b[i]); } RealVector vec = solver.solve(bVec); return vec.toArray(); }
Source:
public void addFilter(@NonNull ViewerFilter filter) { fTimeGraphCtrl.addFilter(filter); refresh(); fTimeGraphCtrl.fireFilterApplied(); }

Target:
public void addFilter(@NonNull ViewerFilter filter) { fTimeGraphCtrl.addFilter(filter); refresh(); }
Source:
public void injectManagementContext(ManagementContext managementContext) { if (this.managementContext!=null && managementContext!=null && !this.managementContext.equals(managementContext)) throw new IllegalStateException("Cannot switch management context of "+this+"; from "+this.managementContext+" to "+managementContext); this.managementContext = managementContext; }

Target:
public void injectManagementContext(ManagementContext managementContext) { Preconditions.checkNotNull(managementContext, "management context"); if (this.managementContext!=null && managementContext!=this.managementContext) throw new IllegalStateException("Cannot switch management context, from "+this.managementContext+" to "+managementContext); this.managementContext = managementContext; }
Source:
public void setAssignmentMetadata(final Map<TaskId, Set<TopicPartition>> activeTasks, final Map<TaskId, Set<TopicPartition>> standbyTasks) { addedActiveTasks.clear(); for (final Map.Entry<TaskId, Set<TopicPartition>> entry : activeTasks.entrySet()) { if (!assignedActiveTasks.containsKey(entry.getKey())) { addedActiveTasks.put(entry.getKey(), entry.getValue()); } } addedStandbyTasks.clear(); for (final Map.Entry<TaskId, Set<TopicPartition>> entry : standbyTasks.entrySet()) { if (!assignedStandbyTasks.containsKey(entry.getKey())) { addedStandbyTasks.put(entry.getKey(), entry.getValue()); } } revokedActiveTasks.clear(); for (final Map.Entry<TaskId, Set<TopicPartition>> entry : assignedActiveTasks.entrySet()) { if (!activeTasks.containsKey(entry.getKey())) { revokedActiveTasks.put(entry.getKey(), entry.getValue()); } } revokedStandbyTasks.clear(); for (final Map.Entry<TaskId, Set<TopicPartition>> entry : assignedStandbyTasks.entrySet()) { if (!standbyTasks.containsKey(entry.getKey())) { revokedStandbyTasks.put(entry.getKey(), entry.getValue()); } } log.debug("Assigning metadata with activeTasks: {}. The updated active task states are: \n" + "\taddedActiveTasks {},\n" + "\tassignedActiveTasks {}", activeTasks, addedActiveTasks, assignedActiveTasks); this.assignedActiveTasks = activeTasks; this.assignedStandbyTasks = standbyTasks; }

Target:
public void setAssignmentMetadata(final Map<TaskId, Set<TopicPartition>> activeTasks, final Map<TaskId, Set<TopicPartition>> standbyTasks) { addedActiveTasks.clear(); for (final Map.Entry<TaskId, Set<TopicPartition>> entry : activeTasks.entrySet()) { if (!assignedActiveTasks.containsKey(entry.getKey())) { addedActiveTasks.put(entry.getKey(), entry.getValue()); } } addedStandbyTasks.clear(); for (final Map.Entry<TaskId, Set<TopicPartition>> entry : standbyTasks.entrySet()) { if (!assignedStandbyTasks.containsKey(entry.getKey())) { addedStandbyTasks.put(entry.getKey(), entry.getValue()); } } revokedActiveTasks.clear(); for (final Map.Entry<TaskId, Set<TopicPartition>> entry : assignedActiveTasks.entrySet()) { if (!activeTasks.containsKey(entry.getKey())) { revokedActiveTasks.put(entry.getKey(), entry.getValue()); } } revokedStandbyTasks.clear(); for (final Map.Entry<TaskId, Set<TopicPartition>> entry : assignedStandbyTasks.entrySet()) { if (!standbyTasks.containsKey(entry.getKey())) { revokedStandbyTasks.put(entry.getKey(), entry.getValue()); } } log.debug("Assigning metadata with: " + "\tactiveTasks: {},\n" + "\tstandbyTasks: {}\n" + "The updated active task states are: \n" + "\tassignedActiveTasks {},\n" + "\tassignedStandbyTasks {},\n" + "\taddedActiveTasks {},\n" + "\taddedStandbyTasks {},\n" + "\trevokedActiveTasks {},\n" + "\trevokedStandbyTasks {}", activeTasks, standbyTasks, assignedActiveTasks, assignedStandbyTasks, addedActiveTasks, addedStandbyTasks, revokedActiveTasks, revokedStandbyTasks); this.assignedActiveTasks = activeTasks; this.assignedStandbyTasks = standbyTasks; }
Source:
private synchronized JsonNode request(String method, String url, String payload, String payloadType, boolean retry) throws IOException, InvalidLoginException { logger.debug("Requsting URL {}", url); String dataString = executeUrl(method, url, header, payload == null ? null : IOUtils.toInputStream(payload), payloadType, 5000); logger.debug("Received MyQ JSON: {}", dataString); if (dataString == null) throw new IOException("Null response from MyQ server"); try { ObjectMapper mapper = new ObjectMapper(); JsonNode rootNode = mapper.readTree(dataString); int returnCode = rootNode.get("ReturnCode").asInt(); logger.debug("myq ReturnCode: {}", returnCode); MyQResponseCode rc = MyQResponseCode.fromCode(returnCode); switch (rc) { case OK: { return rootNode; } case ACCOUNT_INVALID: case ACCOUNT_NOT_FOUND: case ACCOUNT_LOCKED: case ACCOUNT_LOCKED_PENDING: throw new InvalidLoginException(rc.getDesc()); case LOGIN_ERROR: if (retry) { login(); return request(method, url, payload, payloadType, false); } default: throw new IOException("Request Failed: " + rc.getDesc()); } } catch (JsonProcessingException e) { throw new IOException("Could not parse response", e); } }

Target:
private synchronized JsonNode request(String method, String url, String payload, String payloadType, boolean retry) throws IOException, InvalidLoginException { logger.debug("Requsting URL {}", url); String dataString = executeUrl(method, url, header, payload == null ? null : IOUtils.toInputStream(payload), payloadType, timeout); logger.debug("Received MyQ JSON: {}", dataString); if (dataString == null) { throw new IOException("Null response from MyQ server"); } try { ObjectMapper mapper = new ObjectMapper(); JsonNode rootNode = mapper.readTree(dataString); int returnCode = rootNode.get("ReturnCode").asInt(); logger.debug("myq ReturnCode: {}", returnCode); MyQResponseCode rc = MyQResponseCode.fromCode(returnCode); switch (rc) { case OK: { return rootNode; } case ACCOUNT_INVALID: case ACCOUNT_NOT_FOUND: case ACCOUNT_LOCKED: case ACCOUNT_LOCKED_PENDING: throw new InvalidLoginException(rc.getDesc()); case LOGIN_ERROR: if (retry) { login(); return request(method, url, payload, payloadType, false); } default: throw new IOException("Request Failed: " + rc.getDesc()); } } catch (JsonProcessingException e) { throw new IOException("Could not parse response", e); } }
Source:
ReceivedPackStatistics build() { ReceivedPackStatistics s = new ReceivedPackStatistics(); s.numBytesRead = numBytesRead; s.numBytesTransferred = numBytesTransferred; s.numBytesDuplicated = numBytesDuplicated; s.numWholeCommit = numWholeCommit; s.numWholeTree = numWholeTree; s.numWholeBlob = numWholeBlob; s.numWholeTag = numWholeTag; s.numOfsDelta = numOfsDelta; s.numRefDelta = numRefDelta; s.numDeltaCommit = numDeltaCommit; s.numDeltaTree = numDeltaTree; s.numDeltaBlob = numDeltaBlob; s.numDeltaTag = numDeltaTag; return s; }

Target:
ReceivedPackStatistics build() { ReceivedPackStatistics s = new ReceivedPackStatistics(); s.numBytesRead = numBytesRead; s.numBytesTransferred = numBytesTransferred; s.numBytesDuplicated = numBytesDuplicated; s.numWholeCommit = numWholeCommit; s.numWholeTree = numWholeTree; s.numWholeBlob = numWholeBlob; s.numWholeTag = numWholeTag; s.numOfsDelta = numOfsDelta; s.numRefDelta = numRefDelta; s.numDeltaCommit = numDeltaCommit; s.numDeltaTree = numDeltaTree; s.numDeltaBlob = numDeltaBlob; s.numDeltaTag = numDeltaTag; s.numDuplicated = numDuplicated; return s; }
Source:
public SumcoinindexRateSource() { final ClientConfig config = new ClientConfig(); try { SSLContext sslcontext=SSLContext.getInstance("TLS"); sslcontext.init(null,null,null); final CompatSSLSocketFactory socketFactory = new CompatSSLSocketFactory(sslcontext.getSocketFactory()); config.setSslSocketFactory(socketFactory); config.setIgnoreHttpErrorCodes(true); api = RestProxyFactory.createProxy(ISumcoinindexAPI.class, "<LINK_1>", config); } catch (NoSuchAlgorithmException e) { log.error("Error", e); } catch (KeyManagementException e) { log.error("Error", e); } }

Target:
public SumcoinindexRateSource() { api = RestProxyFactory.createProxy(ISumcoinindexAPI.class, "<LINK_0>"); }
Source:
String toCsvString() { StringBuilder line = new StringBuilder(""); line.append('"').append(getCaseName()).append('"').append(','); line.append('"').append(getDataSourceName()).append('"').append(','); line.append('"').append(getType()).append('"').append(','); line.append('"').append(getValue()).append('"').append(','); line.append('"').append(getKnown().toString()).append('"').append(','); line.append('"').append(getFilePath()).append('"').append(','); line.append('"').append(getComment()).append('"').append(System.getProperty("line.separator")); return line.toString(); }

Target:
String toCsvString() { StringBuilder line = new StringBuilder("\""); line.append(getCaseName()).append(CSV_ITEM_SEPARATOR) .append(getDataSourceName()).append(CSV_ITEM_SEPARATOR) .append(getType()).append(CSV_ITEM_SEPARATOR) .append(getValue()).append(CSV_ITEM_SEPARATOR) .append(getKnown().toString()).append(CSV_ITEM_SEPARATOR) .append(getFilePath()).append(CSV_ITEM_SEPARATOR) .append(getComment()).append('"') .append(System.getProperty("line.separator")); return line.toString(); }
Source:
public static ImsServiceProxy create(Context context , int slotId) { ImsServiceProxy serviceProxy = new ImsServiceProxy(context, slotId, ImsFeature.MMTEL); IImsMMTelFeature b = getTelephonyManager(context).getImsMMTelFeatureAndListen(slotId, serviceProxy.getListener()); if (b != null) { serviceProxy.setBinder(b.asBinder()); serviceProxy.getFeatureStatus(); } else { Rlog.w(LOG_TAG, "getServiceProxy: b is null! Phone Id: " + slotId); } return serviceProxy; }

Target:
public static ImsServiceProxy create(Context context , int slotId) { ImsServiceProxy serviceProxy = new ImsServiceProxy(context, slotId, ImsFeature.MMTEL); TelephonyManager tm = getTelephonyManager(context); IImsMMTelFeature binder = tm != null ? tm.getImsMMTelFeatureAndListen(slotId, serviceProxy.getListener()) : null; if (binder != null) { serviceProxy.setBinder(binder.asBinder()); serviceProxy.getFeatureStatus(); } else { Rlog.w(TAG, "getServiceProxy: binder is null! Phone Id: " + slotId); } return serviceProxy; }
Source:
static Object invokeCallback(Object callable, Task<?> task) { if (callable instanceof Closure) return ((Closure<?>)callable).call(task); if (callable instanceof Callable) { try { return ((Callable<?>)callable).call(); } catch (Throwable t) { throw Throwables.propagate(t); } } if (callable instanceof Runnable) { ((Runnable)callable).run(); return null; } if (callable instanceof Function) { return ((Function)callable).apply(task); } if (callable==null) return null; throw new IllegalArgumentException("Cannot invoke unexpected callback object "+callable+" of type "+callable.getClass()+" on "+task); }

Target:
static Object invokeCallback(Object callable, Task<?> task) { if (callable instanceof Closure) return ((Closure<?>)callable).call(task); if (callable instanceof Callable) { try { return ((Callable<?>)callable).call(); } catch (Throwable t) { throw Exceptions.propagate(t); } } if (callable instanceof Runnable) { ((Runnable)callable).run(); return null; } if (callable instanceof Function) { return ((Function)callable).apply(task); } if (callable==null) return null; throw new IllegalArgumentException("Cannot invoke unexpected callback object "+callable+" of type "+callable.getClass()+" on "+task); }
Source:
public EntityModelCellTable(SelectionMode selectionMode, Resources resources, boolean hideCheckbox, boolean showSelectAllCheckbox) { super(DEFAULT_PAGESIZE, resources); this.editorAdapter = new HasDataListModelEditorAdapter<M, EntityModel>(this); switch (selectionMode) { case MULTIPLE: setSelectionModel(new MultiSelectionModel<EntityModel>(), DefaultSelectionEventManager.<EntityModel> createCheckboxManager(0)); break; case NONE: setSelectionModel(new NoSelectionModel<EntityModel>()); break; case SINGLE: default: setSelectionModel(new SingleSelectionModel<EntityModel>()); break; } setSelectionChangeHandler(); buildAddCheckBox(hideCheckbox, showSelectAllCheckbox); }

Target:
public EntityModelCellTable(SelectionMode selectionMode, Resources resources, boolean hideCheckbox, boolean showSelectAllCheckbox) { super(DEFAULT_PAGESIZE, resources); this.editorAdapter = new HasDataListModelEditorAdapter<M, EntityModel>(this); switch (selectionMode) { case MULTIPLE: setSelectionModel(new MultiSelectionModel<EntityModel>(), DefaultSelectionEventManager.<EntityModel> createCheckboxManager(0)); break; case NONE: setSelectionModel(new NoSelectionModel<EntityModel>()); break; case SINGLE: default: setSelectionModel(new SingleSelectionModel<EntityModel>()); break; } addSelectionChangeHandler(); addCheckBoxColumn(hideCheckbox, showSelectAllCheckbox); }
Source:
private static ClassLoader getPluginClassloader( String pluginType, String pluginId ) throws KettlePluginException { Class<? extends PluginTypeInterface> pluginTypeInterface = null; PluginRegistry pluginRegistry = PluginRegistry.getInstance(); int maxTries = 10000; while ( maxTries-- > 0 ) { if ( pluginTypeInterface == null ) { for ( Class<? extends PluginTypeInterface> potentialPluginTypeInterface : pluginRegistry.getPluginTypes() ) { if ( pluginType.equals( potentialPluginTypeInterface.getCanonicalName() ) ) { pluginTypeInterface = potentialPluginTypeInterface; } } } PluginInterface plugin = pluginRegistry.getPlugin( pluginTypeInterface, pluginId ); if ( plugin != null ) { return pluginRegistry.getClassLoader( plugin ); } try { Thread.sleep( 1000 ); } catch ( InterruptedException e ) { throw new KettlePluginException( e ); } } return null; }

Target:
private static ClassLoader getPluginClassloader( String pluginType, String pluginId ) throws KettlePluginException { Class<? extends PluginTypeInterface> pluginTypeInterface = null; PluginRegistry pluginRegistry = PluginRegistry.getInstance(); while ( true ) { synchronized ( pluginRegistry ) { if ( pluginTypeInterface == null ) { for ( Class<? extends PluginTypeInterface> potentialPluginTypeInterface : pluginRegistry.getPluginTypes() ) { if ( pluginType.equals( potentialPluginTypeInterface.getCanonicalName() ) ) { pluginTypeInterface = potentialPluginTypeInterface; } } } PluginInterface plugin = pluginRegistry.getPlugin( pluginTypeInterface, pluginId ); if ( plugin != null ) { return pluginRegistry.getClassLoader( plugin ); } try { pluginRegistry.wait(); } catch ( InterruptedException e ) { throw new KettlePluginException( e ); } } } }
Source:
protected String[] customCommandLineValidation() { final List<String> errs = new ArrayList<>(); if (OUTPUT != null) { IOUtil.assertFileIsWritable(OUTPUT); } MetricToAllowableRelativeChange = new HashMap<>(); if (METRIC_ALLOWABLE_RELATIVE_CHANGE != null) { for (String diffs : METRIC_ALLOWABLE_RELATIVE_CHANGE) { String[] pair = diffs.split(":"); if (pair.length == 2) { String name = pair[0]; try { double value = Double.parseDouble(pair[1]); if (value > 0) { MetricToAllowableRelativeChange.put(name, value); } else { errs.add("Value for numeric component of Argument 'METRIC_ALLOWABLE_RELATIVE_CHANGE' must be > 0.0"); } } catch (NumberFormatException ne) { errs.add("Invalid value for numeric component of Argument 'METRIC_ALLOWABLE_RELATIVE_CHANGE'"); } } else { errs.add("Invalid value for Argument 'METRIC_ALLOWABLE_RELATIVE_CHANGE'"); } } } if (errs.isEmpty()) { return null; } else { return errs.toArray(new String[0]); } }

Target:
protected String[] customCommandLineValidation() { final List<String> errs = new ArrayList<>(); if (OUTPUT != null) { IOUtil.assertFileIsWritable(OUTPUT); } if (METRIC_ALLOWABLE_RELATIVE_CHANGE != null) { for (String diffs : METRIC_ALLOWABLE_RELATIVE_CHANGE) { String[] pair = diffs.split(":"); if (pair.length == 2) { String name = pair[0]; try { double value = Double.parseDouble(pair[1]); if (value > 0) { MetricToAllowableRelativeChange.put(name, value); } else { errs.add("Value for numeric component of Argument 'METRIC_ALLOWABLE_RELATIVE_CHANGE' must be > 0.0"); } } catch (NumberFormatException ne) { errs.add("Invalid value for numeric component of Argument 'METRIC_ALLOWABLE_RELATIVE_CHANGE'"); } } else { errs.add("Invalid value for Argument 'METRIC_ALLOWABLE_RELATIVE_CHANGE'"); } } } if (errs.isEmpty()) { return null; } return errs.toArray(new String[0]); }
Source:
private CommunicationChannel getComChannel(boolean local, Event sourceEvent, Connection connection) { CommunicationChannel channel = communicationModel.getChannels().get(sourceEvent); if (channel == null) { if(connection instanceof EventConnection) { channel = new CommunicationChannel(); channel.setSourceEvent(sourceEvent); channel.setLocal(local); communicationModel.getChannels().put(sourceEvent, channel); } } else if (!local) { channel.setLocal(false); } return channel; }

Target:
private CommunicationChannel getComChannel(boolean local, Event sourceEvent, Connection connection) { CommunicationChannel channel = communicationModel.getChannels().get(sourceEvent); if (null == channel) { if(connection instanceof EventConnection) { channel = new CommunicationChannel(); channel.setSourceEvent(sourceEvent); channel.setLocal(local); communicationModel.getChannels().put(sourceEvent, channel); } } else if (!local) { channel.setLocal(false); } return channel; }
Source:
protected void configure() { install(new PacketComputeParserModule()); super.configure(); }

Target:
protected void configure() { super.configure(); bind(ImplicitLocationSupplier.class).to(FirstRegion.class).in(Scopes.SINGLETON); bind(new TypeLiteral<Function<Href, ListOptions>>() { }).to(LinkToListOptions.class); }
Source:
public XMLSerialization indented() { indented = environment.get(ENVIRONMENT_INDENTED_KEY, "true").equals("true"); return this; }

Target:
public XMLSerialization indented() { indented = true; return this; }
Source:
public static String getPropNameForAccessor(String accessorName) { int prefixLength = accessorName.startsWith("is") ? 2 : 3; if (accessorName.length() < prefixLength + 1) return accessorName; if (!isValidAccessorName(accessorName)) return accessorName; return String.valueOf(accessorName.charAt(prefixLength)).toLowerCase() + accessorName.substring(prefixLength + 1); }

Target:
public static String getPropNameForAccessor(String accessorName) { if (!isValidAccessorName(accessorName)) return accessorName; int prefixLength = accessorName.startsWith("is") ? 2 : 3; return String.valueOf(accessorName.charAt(prefixLength)).toLowerCase() + accessorName.substring(prefixLength + 1); }
Source:
public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == MENU_SAVE_SESSION) { DevSessionRestorer.saveSessionToPrefs(); } return super.onOptionsItemSelected(item); }

Target:
public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == MENU_SAVE_SESSION) { DevSessionRestorer.saveSessionToPrefs(); return true; } return super.onOptionsItemSelected(item); }
Source:
void refreshTable() { if (m_table != null) { m_beanItemContainer = WallboardProvider.getInstance().getBeanContainer(); m_table.setContainerDataSource(m_beanItemContainer); m_table.setVisibleColumns(new Object[]{"title", "Edit", "Remove", "Preview", "Default"}); m_table.setColumnHeader("title", "Title"); m_table.refreshRowCache(); } }

Target:
void refreshTable() { if (m_table != null) { m_beanItemContainer = WallboardProvider.getInstance().getBeanContainer(); m_table.setContainerDataSource(m_beanItemContainer); m_table.setVisibleColumns(new Object[]{"title", "Edit", "Remove", "Preview", "Default"}); m_table.setColumnHeader("title", "Title"); m_table.sort(); m_table.refreshRowCache(); } }
Source:
public void done(IJobChangeEvent event) { if (event.getResult().isOK()) { lock.lock(); try { if (isFetchingGroup) { isFetchingGroup = false; pending = null; final Iterator<FetchListener> listenersIterator; if (listenerLeftToRun != null) { listenersIterator = listenerLeftToRun.iterator(); } else { listenersIterator = listeners.iterator(); } while (listenersIterator.hasNext()) { FetchListener listener = listenersIterator.next(); listener.doneFetching(); if (isFetchingGroup) { listenerLeftToRun = Lists.newArrayList(listenersIterator); return; } } final Iterator<CallbackHolder> callbacksIterator; if (callbacksLeftRun != null) { callbacksIterator = callbacksLeftRun.iterator(); } else { callbacksIterator = callbacks.iterator(); } while (callbacksIterator.hasNext()) { CallbackHolder callbackHolder = callbacksIterator.next(); run(callbackHolder.getCallback(), callbackHolder.getType()); if (isFetchingGroup) { listenerLeftToRun = Collections.emptyList(); callbacksLeftRun = Lists.newArrayList(callbacksIterator); return; } } listenerLeftToRun = null; callbacksLeftRun = null; callbacks.clear(); } } finally { lock.unlock(); } } }

Target:
public void done(IJobChangeEvent event) { if (event.getResult().isOK()) { lock.lock(); try { if (isFetchingGroup) { isFetchingGroup = false; pending = null; final Iterator<FetchListener> listenersIterator; if (listenerLeftToRun != null) { listenersIterator = listenerLeftToRun.iterator(); } else { listenersIterator = listeners.iterator(); } while (listenersIterator.hasNext()) { FetchListener listener = listenersIterator.next(); listener.doneFetching(); if (isFetchingGroup) { listenerLeftToRun = Lists.newArrayList(listenersIterator); return; } } final Iterator<CallbackHolder> callbacksIterator = callbacks.iterator(); while (callbacksIterator.hasNext()) { CallbackHolder callbackHolder = callbacksIterator.next(); run(callbackHolder.getCallback(), callbackHolder.getType()); if (isFetchingGroup) { listenerLeftToRun = Collections.emptyList(); List<CallbackHolder> remainingCallBack = Lists.newArrayList(callbacksIterator); callbacks = new CopyOnWriteArrayList<EMFCompareStructureMergeViewerContentProvider.CallbackHolder>( remainingCallBack); return; } } listenerLeftToRun = null; callbacks.clear(); } } finally { lock.unlock(); } } }
Source:
public AttributeDefinition createAttribute(PerunSession sess, AttributeDefinition attribute) throws InternalErrorException, AttributeDefinitionExistsException { return createAttribute(sess, attribute, false); }

Target:
public AttributeDefinition createAttribute(PerunSession sess, AttributeDefinition attribute) throws InternalErrorException, AttributeDefinitionExistsException { return createAttribute(sess, attribute, true); }
Source:
public void testFailedRefreshCallback() throws InterruptedException { AtomicReference<Set<LockRefreshToken>> failedTokens = new AtomicReference<>(); server.registerRefreshFailedCallback(failedTokens::set); LockRequest request = LockRequest.builder(ImmutableSortedMap.of(lock1, LockMode.WRITE)) .timeoutAfter(SimpleTimeDuration.of(5, TimeUnit.SECONDS)) .build(); LockResponse lock = server.lockWithFullLockResponse(LockClient.ANONYMOUS, request); internalServer.unlock(lock.getToken()); Thread.sleep(10000); assertThat(failedTokens.get()).containsExactlyInAnyOrder(lock.getLockRefreshToken()); }

Target:
public void testFailedRefreshCallback() throws InterruptedException { AtomicReference<Set<LockRefreshToken>> failedTokens = new AtomicReference<>(); server.registerRefreshFailedCallback(failedTokens::set); LockRequest request = LockRequest.builder(ImmutableSortedMap.of(lock1, LockMode.WRITE)) .timeoutAfter(SimpleTimeDuration.of(5, TimeUnit.SECONDS)) .build(); LockResponse lock = server.lockWithFullLockResponse(LockClient.ANONYMOUS, request); internalServer.unlock(lock.getToken()); Awaitility.waitAtMost(20, TimeUnit.SECONDS) .until(() -> failedTokens.get() != null); assertThat(failedTokens.get()).containsExactlyInAnyOrder(lock.getLockRefreshToken()); }
Source:
public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals("stopWait")) { queueDelayedUpdate(); } }

Target:
public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals(STOP_WAIT_PROPERTY_IDENTIFIER)) { queueDelayedUpdate(); } }
Source:
public void onApiConnected() { super.onApiConnected(); final View view = getView(); final Context context = getContext(); typeSpinner.setSelection(commandAdapter.getPosition(MissionItemType.WAYPOINT)); final NumericWheelAdapter delayAdapter = new NumericWheelAdapter(context, R.layout.wheel_text_centered, 0, 60, "%d s"); CardWheelHorizontalView<Integer> delayPicker = (CardWheelHorizontalView) view.findViewById(R.id .waypointDelayPicker); delayPicker.setViewAdapter(delayAdapter); delayPicker.addScrollListener(this); final LengthUnitProvider lengthUP = getLengthUnitProvider(); final LengthWheelAdapter altitudeAdapter = new LengthWheelAdapter(context, R.layout.wheel_text_centered, lengthUP.boxBaseValueToTarget(MIN_ALTITUDE), lengthUP.boxBaseValueToTarget(MAX_ALTITUDE)); CardWheelHorizontalView<LengthUnit> altitudePicker = (CardWheelHorizontalView) view.findViewById(R.id .altitudePicker); altitudePicker.setViewAdapter(altitudeAdapter); altitudePicker.addScrollListener(this); if(getMissionItems().size() > 0) { final Waypoint item = (Waypoint) getMissionItems().get(0); delayPicker.setCurrentValue((int) item.getDelay()); altitudePicker.setCurrentValue(lengthUP.boxBaseValueToTarget(item.getCoordinate().getAltitude())); } }

Target:
public void onApiConnected() { super.onApiConnected(); final View view = getView(); final Context context = getContext(); typeSpinner.setSelection(commandAdapter.getPosition(MissionItemType.WAYPOINT)); final NumericWheelAdapter delayAdapter = new NumericWheelAdapter(context, R.layout.wheel_text_centered, 0, 60, "%d s"); CardWheelHorizontalView<Integer> delayPicker = (CardWheelHorizontalView) view.findViewById(R.id .waypointDelayPicker); delayPicker.setViewAdapter(delayAdapter); delayPicker.addScrollListener(this); final LengthUnitProvider lengthUP = getLengthUnitProvider(); final LengthWheelAdapter altitudeAdapter = new LengthWheelAdapter(context, R.layout.wheel_text_centered, lengthUP.boxBaseValueToTarget(MIN_ALTITUDE), lengthUP.boxBaseValueToTarget(MAX_ALTITUDE)); CardWheelHorizontalView<LengthUnit> altitudePicker = (CardWheelHorizontalView) view.findViewById(R.id .altitudePicker); altitudePicker.setViewAdapter(altitudeAdapter); altitudePicker.addScrollListener(this); final Waypoint item = (Waypoint) getMissionItems().get(0); delayPicker.setCurrentValue((int) item.getDelay()); altitudePicker.setCurrentValue(lengthUP.boxBaseValueToTarget(item.getCoordinate().getAltitude())); }
Source:
private static OriginalType getOriginalType(ConvertedType type) { switch (type) { case UTF8: return OriginalType.UTF8; case MAP: return OriginalType.MAP; case MAP_KEY_VALUE: return OriginalType.MAP_KEY_VALUE; case LIST: return OriginalType.LIST; case ENUM: return OriginalType.ENUM; case DECIMAL: return OriginalType.DECIMAL; case DATE: return OriginalType.DATE; case TIME_MILLIS: return OriginalType.TIME_MILLIS; case TIMESTAMP_MILLIS: return OriginalType.TIMESTAMP_MILLIS; case INTERVAL: return OriginalType.INTERVAL; case INT_8: return OriginalType.INT_8; case INT_16: return OriginalType.INT_16; case INT_32: return OriginalType.INT_32; case INT_64: return OriginalType.INT_64; case UINT_8: return OriginalType.UINT_8; case UINT_16: return OriginalType.UINT_16; case UINT_32: return OriginalType.UINT_32; case UINT_64: return OriginalType.UINT_64; case JSON: return OriginalType.JSON; case BSON: return OriginalType.BSON; case TIMESTAMP_MICROS: return OriginalType.TIMESTAMP_MICROS; default: throw new IllegalArgumentException("Unknown converted type " + type); } }

Target:
private static OriginalType getOriginalType(ConvertedType type) { switch (type) { case UTF8: return OriginalType.UTF8; case MAP: return OriginalType.MAP; case MAP_KEY_VALUE: return OriginalType.MAP_KEY_VALUE; case LIST: return OriginalType.LIST; case ENUM: return OriginalType.ENUM; case DECIMAL: return OriginalType.DECIMAL; case DATE: return OriginalType.DATE; case TIME_MILLIS: return OriginalType.TIME_MILLIS; case TIMESTAMP_MILLIS: return OriginalType.TIMESTAMP_MILLIS; case INTERVAL: return OriginalType.INTERVAL; case INT_8: return OriginalType.INT_8; case INT_16: return OriginalType.INT_16; case INT_32: return OriginalType.INT_32; case INT_64: return OriginalType.INT_64; case UINT_8: return OriginalType.UINT_8; case UINT_16: return OriginalType.UINT_16; case UINT_32: return OriginalType.UINT_32; case UINT_64: return OriginalType.UINT_64; case JSON: return OriginalType.JSON; case BSON: return OriginalType.BSON; default: throw new IllegalArgumentException("Unknown converted type " + type); } }
Source:
public void started() { Context.getService(HtmlFormEntryService.class).addHandler("encounterProviderAndRole", new EncounterProviderAndRoleTagHandler()); log.info("Started HTML Form Entry Module"); }

Target:
public void started() { log.info("Started HTML Form Entry Module"); }
Source:
public void send(Message<?> message, ScopeDescriptor scopeDescription) throws Exception { if (scopeDescription instanceof AggregateDescriptor) { load(((AggregateDescriptor) scopeDescription).getIdentifier().toString()).handle(message); } }

Target:
public void send(Message<?> message, ScopeDescriptor scopeDescription) throws Exception { CompletableFuture future = new CompletableFuture(); send(message, scopeDescription, future); try { future.get(); } catch (ExecutionException e) { if (e.getCause() instanceof Exception) { throw (Exception) e.getCause(); } throw e; } }
Source:
protected ReconnectingChannel createReconnectingChannel(final InetSocketAddress host) throws IOException { return new ReconnectingChannel(options.getTimeoutMs(), new ReconnectingChannel.Factory() { @Override public Channel createChannel() throws IOException { return NettyChannelBuilder .forAddress(host) .sslContext(createSslContext()) .eventLoopGroup(elg) .executor(batchPool) .negotiationType(NegotiationType.TLS) .flowControlWindow(1 << 20) .build(); } @Override public Closeable createClosable(final Channel channel) { return new Closeable() { @Override public void close() throws IOException { ChannelImpl channelImpl = (ChannelImpl) channel; channelImpl.shutdown(); try { channelImpl.awaitTermination(CHANNEL_TERMINATE_WAIT_MS, TimeUnit.MILLISECONDS); } catch (InterruptedException e) { Thread.interrupted(); throw new IOException("Interrupted while sleeping for close", e); } if (!channelImpl.isTerminated()) { throw new IOException("Could not close the channel. "); } } }; } }); }

Target:
protected ReconnectingChannel createReconnectingChannel(final InetSocketAddress host) throws IOException { return new ReconnectingChannel(options.getTimeoutMs(), new ReconnectingChannel.Factory() { @Override public Channel createChannel() throws IOException { return NettyChannelBuilder .forAddress(host) .sslContext(createSslContext()) .eventLoopGroup(elg) .executor(batchPool) .negotiationType(NegotiationType.TLS) .flowControlWindow(1 << 20) .build(); } @Override public Closeable createClosable(final Channel channel) { return new Closeable() { @Override public void close() throws IOException { ChannelImpl channelImpl = (ChannelImpl) channel; channelImpl.shutdown(); try { channelImpl.awaitTermination(options.getTimeoutMs(), TimeUnit.MILLISECONDS); } catch (InterruptedException e) { Thread.interrupted(); throw new IOException("Interrupted while sleeping for close", e); } if (!channelImpl.isTerminated()) { throw new IOException("Could not close the channel after " + options.getTimeoutMs() + " ms."); } } }; } }); }
Source:
protected void doService(ToolPageContext page) throws IOException, ServletException { String typeId = page.param(String.class, "typeId"); Class<?> rteClass = ObjectType.getInstance(UUID.fromString(typeId)).getObjectClass(); RichTextElement rte = (RichTextElement) TypeDefinition.getInstance(rteClass).newInstance(); rte.fromAttributes((Map<String, String>) ObjectUtils.fromJson(page.param(String.class, "attributes"))); try { rte.writePreviewHtml(page); } catch (RuntimeException error) { } }

Target:
protected void doService(ToolPageContext page) throws IOException, ServletException { UUID typeId = page.param(UUID.class, "typeId"); Class<?> rteClass = ObjectType.getInstance(typeId).getObjectClass(); RichTextElement rte = (RichTextElement) TypeDefinition.getInstance(rteClass).newInstance(); rte.fromAttributes((Map<String, String>) ObjectUtils.fromJson(page.param(String.class, "attributes"))); try { rte.writePreviewHtml(page); } catch (RuntimeException error) { } }
Source:
public String[] importArchive(InputStream in, final String name) throws Exception { File tempCache = new File(getLocalCacheDir(), System.currentTimeMillis()+""); List<String> importedTargetTranslationSlugs = new ArrayList<>(); try { tempCache.mkdirs(); Zip.unzipFromStream(in, tempCache); importArchiveFromTempCache(tempCache, importedTargetTranslationSlugs); } catch (Exception e) { throw e; } finally { IOUtils.closeQuietly(in); FileUtils.deleteQuietly(tempCache); } String[] translationSlugs = importedTargetTranslationSlugs.toArray(new String[importedTargetTranslationSlugs.size()]); boolean success = TargetTranslationMigrator.migrate(tempCache,translationSlugs); return translationSlugs; }

Target:
public String[] importArchive(InputStream in, final String name) throws Exception { File tempCache = new File(getLocalCacheDir(), System.currentTimeMillis()+""); List<String> importedTargetTranslationSlugs = new ArrayList<>(); try { tempCache.mkdirs(); Zip.unzipFromStream(in, tempCache); importArchiveFromTempCache(tempCache, importedTargetTranslationSlugs); } catch (Exception e) { throw e; } finally { IOUtils.closeQuietly(in); FileUtils.deleteQuietly(tempCache); } return importedTargetTranslationSlugs.toArray(new String[importedTargetTranslationSlugs.size()]); }
Source:
protected void init() { proxy = null; }

Target:
protected void init() { proxy = null; this.getFieldsPanel(); ProxiesParamProxy paramProxy = new ProxiesParamProxy(true); proxyPanel.setProxy(paramProxy); }
Source:
public void cancel() { objPeakDetection.cancel(); }

Target:
public void cancel() { if (objPeakDetection != null) { objPeakDetection.cancel(); canceled = true; } }
Source:
public CosmosDBAccountImpl withIpRangeFilter(String ipRangeFilter) { List<IpAddressOrRange> rules = new ArrayList<>(); for (String ip : ipRangeFilter.split(",")) { rules.add(new IpAddressOrRange().withIpAddressOrRange(ip)); } this.innerModel().withIpRules(rules); return this; }

Target:
public CosmosDBAccountImpl withIpRangeFilter(String ipRangeFilter) { List<IpAddressOrRange> rules = new ArrayList<>(); if (!CoreUtils.isNullOrEmpty(ipRangeFilter)) { for (String ip : ipRangeFilter.split(",")) { rules.add(new IpAddressOrRange().withIpAddressOrRange(ip)); } } this.innerModel().withIpRules(rules); return this; }
Source:
public Object[][] provideScenarios() { try { List<Object[]> scenarios = new ArrayList<Object[]>(); List<CucumberFeature> features = getFeatures(); for (CucumberFeature feature : features) { List<PickleEvent> pickles = runtime.compileFeature(feature); for (PickleEvent pickle : pickles) { scenarios.add(new Object[]{new PickleEventWrapper(pickle), new CucumberFeatureWrapperImpl(feature)}); } } return scenarios.toArray(new Object[][]{}); } catch (CucumberException e) { return new Object[][]{new Object[]{new CucumberExceptionWrapper(e)}}; } }

Target:
public Object[][] provideScenarios() { try { List<Object[]> scenarios = new ArrayList<Object[]>(); List<CucumberFeature> features = getFeatures(); for (CucumberFeature feature : features) { List<PickleEvent> pickles = runtime.compileFeature(feature); for (PickleEvent pickle : pickles) { if (runtime.matchesFilters(pickle)) { scenarios.add(new Object[]{new PickleEventWrapper(pickle), new CucumberFeatureWrapperImpl(feature)}); } } } return scenarios.toArray(new Object[][]{}); } catch (CucumberException e) { return new Object[][]{new Object[]{new CucumberExceptionWrapper(e)}}; } }
Source:
public static byte[] unescape(byte[] in) { int escapeCount = 0; for (int i = 0; i < in.length; i++) { if (in[i] == 0x01) { escapeCount++; i++; } } if (escapeCount == 0) return in; byte ret[] = new byte[in.length - escapeCount]; int index = 0; for (int i = 0; i < in.length; i++) { if (in[i] == 0x01) { i++; if (i >= in.length) { return in; } ret[index++] = (byte) (in[i] - 1); } else { ret[index++] = in[i]; } } return ret; }

Target:
public static byte[] unescape(byte[] in) { int escapeCount = 0; for (int i = 0; i < in.length; i++) { if (in[i] == 0x01) { escapeCount++; i++; } } if (escapeCount == 0) return in; byte[] ret = new byte[in.length - escapeCount]; int index = 0; for (int i = 0; i < in.length; i++) { if (in[i] == 0x01) { i++; if (i >= in.length) { throw new IllegalArgumentException("Bad bytes when attempting to unescape. Expected " + "more bytes after last byte " + String.format("x%02x", in[in.length - 1])); } ret[index++] = (byte) (in[i] - 1); } else { ret[index++] = in[i]; } } return ret; }
Source:
public StoreKeyConverter getStoreKeyConverter() { return new MockStoreKeyConverter(); }

Target:
public MockStoreKeyConverter getStoreKeyConverter() { return new MockStoreKeyConverter(new HashMap<>(conversionMap)); }