auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
public static void main(String[] args) { if (args.length != 3) printUsage(); try { Version version = parseVersionString(args[0]); if (version == null) { System.err.println( "Invalid version number format, must be \"x.y.z(-.*)?\""); System.exit(ExitCode.UNEXPECTED_ERROR.getValue()); } String rev = args[1]; if (rev == null || rev.trim().isEmpty()) { rev = "-1"; } else { rev = rev.trim(); } generateFile(new File("../../../target/generated-sources/java"), version, rev, args[2]); } catch (NumberFormatException e) { System.err.println( "All version-related parameters must be valid integers!"); throw e; } }

Target:
public static void main(String[] args) { if (args.length != 4) printUsage(); try { Version version = parseVersionString(args[0]); if (version == null) { System.err.println( "Invalid version number format, must be \"x.y.z(-.*)?\""); System.exit(ExitCode.UNEXPECTED_ERROR.getValue()); } String rev = args[1]; if (rev == null || rev.trim().isEmpty()) { rev = "-1"; } else { rev = rev.trim(); } generateFile(new File(args[3]), version, rev, args[2]); } catch (NumberFormatException e) { System.err.println( "All version-related parameters must be valid integers!"); throw e; } }
Source:
private Optional<Pair<ContainerPlacementMessage.StatusCode, String>> validatePlacementAction(ContainerPlacementRequestMessage requestMessage) { String errorMessagePrefix = String.format("ContainerPlacement request: %s is rejected due to", requestMessage); Boolean invalidAction = false; String errorMessage = null; if (standbyContainerManager.isPresent()) { errorMessage = String.format("%s not supported for host standby enabled", errorMessagePrefix); invalidAction = true; } else if (hasActiveContainerPlacementAction(requestMessage.getProcessorId())) { return Optional.empty(); } else if (!samzaApplicationState.runningProcessors.containsKey(requestMessage.getProcessorId()) || samzaApplicationState.pendingProcessors.containsKey(requestMessage.getProcessorId())) { return Optional.empty(); } else if (dequeuedActionsCache.containsKey(requestMessage.getUuid())) { errorMessage = String.format("%s duplicate UUID of the request, please retry", errorMessagePrefix); invalidAction = true; } else if (Integer.parseInt(requestMessage.getProcessorId()) >= samzaApplicationState.processorCount.get() ) { errorMessage = String.format("%s invalid processor id", errorMessagePrefix); invalidAction = true; } if (invalidAction) { LOG.info(errorMessage); return Optional.of(new ImmutablePair<>(ContainerPlacementMessage.StatusCode.BAD_REQUEST, errorMessage)); } return Optional.of(new ImmutablePair<>(ContainerPlacementMessage.StatusCode.ACCEPTED, "Request is accepted")); }

Target:
private Pair<ContainerPlacementMessage.StatusCode, String> validatePlacementAction(ContainerPlacementRequestMessage requestMessage) { String errorMessagePrefix = String.format("ContainerPlacement request: %s is rejected due to", requestMessage); Boolean invalidAction = false; String errorMessage = null; if (standbyContainerManager.isPresent()) { errorMessage = String.format("%s not supported for hot standby enabled", errorMessagePrefix); invalidAction = true; } else if (placementRequestsCache.containsKey(requestMessage.getUuid())) { errorMessage = String.format("%s duplicate UUID of the request, please retry", errorMessagePrefix); invalidAction = true; } else if (Integer.parseInt(requestMessage.getProcessorId()) >= samzaApplicationState.processorCount.get() ) { errorMessage = String.format("%s invalid processor id", errorMessagePrefix); invalidAction = true; } if (invalidAction) { LOG.info(errorMessage); return new ImmutablePair<>(ContainerPlacementMessage.StatusCode.BAD_REQUEST, errorMessage); } return new ImmutablePair<>(ContainerPlacementMessage.StatusCode.ACCEPTED, "Request is accepted"); }
Source:
public boolean testPermission(CommandSource source) { return source.hasPermission(this.permission); }

Target:
public boolean testPermission(CommandSource source) { return this.permission == null ? true : source.hasPermission(this.permission); }
Source:
private synchronized void tryLog() { if (shouldLog()) { if (distributionNotUniform()) { logNotUniform(); } else { logUniform(); } totalWrites.set(0); lastLoggedTime = System.currentTimeMillis(); } }

Target:
private synchronized void tryLog() { if (shouldLog()) { if (distributionNotUniform()) { logNotUniform(); } else { logUniform(); } writesSinceLastLog.set(0); lastLoggedTime = System.currentTimeMillis(); } }
Source:
private void tryInitializationLoop() { try { tryInitializeInternal(); log.info("Initialized on the attempt in milliseconds", SafeArg.of("className", getInitializingClassName()), SafeArg.of("numberOfAttempts", numberOfInitializationAttempts), SafeArg.of("initializationDuration", System.currentTimeMillis() - initializationStartTime)); } catch (Throwable throwable) { log.info("Failed to initialize on the attempt", SafeArg.of("className", getInitializingClassName()), SafeArg.of("numberOfAttempts", numberOfInitializationAttempts++), throwable); cleanUpOnInitFailure(); scheduleInitialization(); } }

Target:
private void tryInitializationLoop() { try { tryInitializeInternal(); log.info("Initialized on the attempt in milliseconds", SafeArg.of("className", getInitializingClassName()), SafeArg.of("numberOfAttempts", numberOfInitializationAttempts), SafeArg.of("initializationDuration", System.currentTimeMillis() - initializationStartTime)); } catch (Throwable throwable) { log.info("Failed to initialize on the attempt {}", SafeArg.of("className", getInitializingClassName()), SafeArg.of("numberOfAttempts", numberOfInitializationAttempts++), throwable); cleanUpOnInitFailure(); scheduleInitialization(); } }
Source:
boolean incrNumberRuns(List<KeyValue> column, HTable aggTable, AppAggregationKey appAggKey) throws IOException { Long expectedValueBeforePut = null; if (column.size() > 0) { try { expectedValueBeforePut = Bytes.toLong(column.get(0).getValue()); } catch (NumberFormatException e) { LOG.error("Could not read existing value for number of runs during aggregation" + appAggKey.toString()); return false; } } byte[] rowKey = aggConv.toBytes(appAggKey); long insertValue = 1L; byte[] expectedValueBeforePutBytes = null; if (expectedValueBeforePut != null) { insertValue = 1 + expectedValueBeforePut; expectedValueBeforePutBytes = Bytes.toBytes(expectedValueBeforePut); } byte[] insertValueBytes = Bytes.toBytes(insertValue); LOG.trace(" before statusCheckAndPut " + insertValue + " " + expectedValueBeforePut); return executeCheckAndPut(aggTable, rowKey, expectedValueBeforePutBytes, insertValueBytes, AggregationConstants.INFO_FAM_BYTES, AggregationConstants.NUMBER_RUNS_BYTES); }

Target:
boolean incrNumberRuns(List<KeyValue> column, HTable aggTable, AppAggregationKey appAggKey) throws IOException { long expectedValueBeforePut = 0L; if (column.size() > 0) { try { expectedValueBeforePut = Bytes.toLong(column.get(0).getValue()); } catch (NumberFormatException e) { LOG.error("Could not read existing value for number of runs during aggregation" + appAggKey.toString()); return false; } } byte[] rowKey = aggConv.toBytes(appAggKey); long insertValue = 1L; byte[] expectedValueBeforePutBytes = null; if (expectedValueBeforePut != 0L) { insertValue = 1 + expectedValueBeforePut; expectedValueBeforePutBytes = Bytes.toBytes(expectedValueBeforePut); } byte[] insertValueBytes = Bytes.toBytes(insertValue); if (LOG.isTraceEnabled()) { LOG.trace(" before statusCheckAndPut " + insertValue + " " + expectedValueBeforePut); } return executeCheckAndPut(aggTable, rowKey, expectedValueBeforePutBytes, insertValueBytes, AggregationConstants.INFO_FAM_BYTES, AggregationConstants.NUMBER_RUNS_BYTES); }
Source:
private void parseProfile() throws IOException, XMLStreamException, WrongProfileEncodingException { XMLInputFactory factory = XMLInputFactory.newInstance(); XMLStreamReader streamReader = factory.createXMLStreamReader(new FileInputStream(profile)); if (!"utf-8".equals(streamReader.getEncoding().toLowerCase())){ streamReader.close(); throw new WrongProfileEncodingException("The given profile has not utf-8 encoding: " + profile.getCanonicalPath()); } else { while (streamReader.hasNext()) { streamReader.next(); if (streamReader.isStartElement() && streamReader.getLocalName().equals("hash")) { Location location = streamReader.getLocation(); startOfHash = location.getCharacterOffset(); currentHashAsString = streamReader.getElementText().trim(); } if (streamReader.isEndElement() && streamReader.getLocalName().equals("hash")) { Location location = streamReader.getLocation(); endOfHash = location.getCharacterOffset(); if (endOfHash != startOfHash) { startOfHash -= "<hash>".length(); } else { startOfHash -= "<hash/>".length(); } } } } }

Target:
private void parseProfile() throws IOException, XMLStreamException, WrongProfileEncodingException { XMLInputFactory factory = XMLInputFactory.newInstance(); XMLStreamReader streamReader = factory.createXMLStreamReader(new FileInputStream(profile)); if (!UTF8.equals(streamReader.getEncoding().toLowerCase())){ streamReader.close(); throw new WrongProfileEncodingException("The given profile has not utf-8 encoding: " + profile.getCanonicalPath()); } else { while (streamReader.hasNext()) { streamReader.next(); if (streamReader.isStartElement() && streamReader.getLocalName().equals("hash")) { Location location = streamReader.getLocation(); startOfHash = location.getCharacterOffset(); currentHashAsString = streamReader.getElementText().trim(); } if (streamReader.isEndElement() && streamReader.getLocalName().equals("hash")) { Location location = streamReader.getLocation(); endOfHash = location.getCharacterOffset(); if (endOfHash != startOfHash) { startOfHash -= "<hash>".length(); } else { startOfHash -= "<hash/>".length(); } } } } }
Source:
public void init() { if (cacheContainer == null) { log.fine("Using default cache"); propertyCache = InfinispanCacheManager.getDefaultCache(CACHE_NAME); } else { log.fine("Using container provided cache"); propertyCache = cacheContainer.getCache(CACHE_NAME); } propertyCache.addListener(eventListener); }

Target:
public void init() { if (propertyCache != null) { return; } if (cacheContainer == null) { log.fine("Using default cache"); propertyCache = InfinispanCacheManager.getDefaultCache(CACHE_NAME); } else { log.fine("Using container provided cache"); propertyCache = cacheContainer.getCache(CACHE_NAME); } propertyCache.addListener(eventListener); }
Source:
public void configure(JTable table, TableRowSorter<TableModel> sorter, ColumnTreeCellRenderer renderer) { TableColumn column = table.getColumn(myName); column.setPreferredWidth(myWidth); final TableCellRenderer tableCellRenderer = table.getTableHeader().getDefaultRenderer(); column.setHeaderRenderer(new DefaultTableCellRenderer() { @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { Component component = tableCellRenderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); if (component instanceof JLabel) { JLabel label = (JLabel)component; label.setHorizontalAlignment(myHeaderAlignment); return label; } return component; } }); if (myComparator != null) { sorter.setComparator(column.getModelIndex(), myComparator); } else { sorter.setSortable(column.getModelIndex(), false); } assert myRenderer != null; renderer.add(myRenderer); }

Target:
public void configure(JTable table, TableRowSorter<TableModel> sorter, ColumnTreeCellRenderer renderer) { TableColumn column = table.getColumn(myName); column.setPreferredWidth(myWidth); final TableCellRenderer tableCellRenderer = table.getTableHeader().getDefaultRenderer(); column.setHeaderRenderer(new DefaultTableCellRenderer() { @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { Component component = tableCellRenderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); if (component instanceof JLabel) { ((JLabel)component).setHorizontalAlignment(myHeaderAlignment); } return component; } }); if (myComparator != null) { sorter.setComparator(column.getModelIndex(), myComparator); } else { sorter.setSortable(column.getModelIndex(), false); } assert myRenderer != null; renderer.add(myRenderer); }
Source:
public void testBasic() { try { CliConfiguration.set(null); Assert.fail(); } catch (NullPointerException e) { } CliConfiguration.set(new HashMap<>()); Map<String,String> expected = new HashMap<>(); expected.put(Property.TRACE_USER.getKey(), "test"); expected.put(Property.TSERV_CLIENTPORT.getKey(), "123"); CliConfiguration.set(expected); Assert.assertEquals("test", CliConfiguration.get(Property.TRACE_USER)); Map<String,String> results = new HashMap<>(); CliConfiguration.getProperties(results, p -> p.startsWith("trace")); Assert.assertEquals(1, results.size()); }

Target:
public void testBasic() { try { CliConfiguration.set(null); Assert.fail(); } catch (NullPointerException e) { } CliConfiguration.set(new HashMap<>()); Map<String,String> expected = new HashMap<>(); expected.put(Property.TRACE_USER.getKey(), "test"); expected.put(Property.TSERV_CLIENTPORT.getKey(), "123"); CliConfiguration.set(expected); Assert.assertEquals("test", CliConfiguration.get(Property.TRACE_USER)); Map<String,String> results = new HashMap<>(); CliConfiguration.getProperties(results, p -> p.startsWith("trace")); Assert.assertEquals(ImmutableMap.of(Property.TRACE_USER.getKey(), "test"), results); }
Source:
public void handle(Context withinContext) throws Exception { CreateTableMessage ctm = deserializer.getCreateTableMessage(event.getMessage()); LOG.info("Processing#{} CREATE_TABLE message : {}", fromEventId(), event.getMessage()); org.apache.hadoop.hive.metastore.api.Table tobj = ctm.getTableObj(); if (tobj == null) { LOG.debug("Event#{} was a CREATE_TABLE_EVENT with no table listed"); return; } Table qlMdTable = new Table(tobj); if (!Utils.shouldReplicate(withinContext.replicationSpec, qlMdTable, withinContext.hiveConf)) { return; } if (qlMdTable.isView()) { withinContext.replicationSpec.setIsMetadataOnly(true); } Path metaDataPath = new Path(withinContext.eventRoot, EximUtil.METADATA_NAME); EximUtil.createExportDump( metaDataPath.getFileSystem(withinContext.hiveConf), metaDataPath, qlMdTable, null, withinContext.replicationSpec, withinContext.hiveConf); Path dataPath = new Path(withinContext.eventRoot, "data"); Iterable<String> files = ctm.getFiles(); if (files != null) { try (BufferedWriter fileListWriter = writer(withinContext, dataPath)) { for (String file : files) { fileListWriter.write(file + "\n"); } } } DumpMetaData dmd = withinContext.createDmd(this); dmd.setPayload(event.getMessage()); dmd.write(); }

Target:
public void handle(Context withinContext) throws Exception { CreateTableMessage ctm = deserializer.getCreateTableMessage(event.getMessage()); LOG.info("Processing#{} CREATE_TABLE message : {}", fromEventId(), event.getMessage()); org.apache.hadoop.hive.metastore.api.Table tobj = ctm.getTableObj(); if (tobj == null) { LOG.debug("Event#{} was a CREATE_TABLE_EVENT with no table listed"); return; } Table qlMdTable = new Table(tobj); if (!Utils.shouldReplicate(withinContext.replicationSpec, qlMdTable, withinContext.hiveConf)) { return; } if (qlMdTable.isView()) { withinContext.replicationSpec.setIsMetadataOnly(true); } Path metaDataPath = new Path(withinContext.eventRoot, EximUtil.METADATA_NAME); EximUtil.createExportDump( metaDataPath.getFileSystem(withinContext.hiveConf), metaDataPath, qlMdTable, null, withinContext.replicationSpec, withinContext.hiveConf); Path dataPath = new Path(withinContext.eventRoot, "data"); Iterable<String> files = ctm.getFiles(); if (files != null) { try (BufferedWriter fileListWriter = writer(withinContext, dataPath)) { for (String file : files) { fileListWriter.write(file + "\n"); } } } withinContext.createDmd(this).write(); }
Source:
private void processResponse(@Nullable HttpResponse response) { if (response != null) { StatusLine statusLine = response.getStatusLine(); if (statusLine.getStatusCode() == HttpStatus.SC_OK) { printSuccessMessage(String.format("%nBackup of [%s] complete.%n", coreName)); } else { printErrorMessage(String.format("Error backing up Solr core: [%s]", coreName)); printErrorMessage( String.format( "Backup request failed: %d - %s %n", statusLine.getStatusCode(), statusLine.getReasonPhrase())); } } else { printErrorMessage(String.format("Could not communicate with Solr. %n")); } }

Target:
private void processResponse(@Nullable HttpResponse response) { if (response == null) { printErrorMessage(String.format("Could not communicate with Solr. %n")); return; } StatusLine statusLine = response.getStatusLine(); if (statusLine.getStatusCode() == HttpStatus.SC_OK) { printSuccessMessage(String.format("%nBackup of [%s] complete.%n", coreName)); } else { printErrorMessage(String.format("Error backing up Solr core: [%s]", coreName)); printErrorMessage( String.format( "Backup request failed: %d - %s %n", statusLine.getStatusCode(), statusLine.getReasonPhrase())); } }
Source:
private AsyncJobStatus processJobFailure(AsyncJobStatus status, EventSink eventSink, Exception exception, boolean retry) { status.setEndTime(new Date()); eventSink.rollback(); if (retry) { status = this.updateJobStatus(status, JobState.FAILED_WITH_RETRY, exception); log.warn("Job \"{}\" failed in {}ms; retrying...", status.getName(), this.getJobRuntime(status), exception); try { JobMessage message = new JobMessage(status.getId(), status.getJobKey()); this.dispatcher.sendJobMessage(message); } catch (Exception e) { log.error("Job \"{}\" could not be requeued; failed to dispatch message:", status.getName(), e); status = this.updateJobStatus(status, JobState.FAILED, exception); } } else { status = this.updateJobStatus(status, JobState.FAILED, exception); log.error("Job \"{}\" failed in {}ms", status.getName(), this.getJobRuntime(status), exception); } return status; }

Target:
private AsyncJobStatus processJobFailure(AsyncJobStatus status, EventSink eventSink, Exception exception, boolean retry) throws JobStateManagementException, JobMessageDispatchException { status.setEndTime(new Date()); eventSink.rollback(); if (retry) { status = this.updateJobStatus(status, JobState.FAILED_WITH_RETRY, exception); log.warn("Job \"{}\" failed in {}ms; retrying...", status.getName(), this.getJobRuntime(status), exception); this.postJobStatusMessage(status); } else { status = this.updateJobStatus(status, JobState.FAILED, exception); log.error("Job \"{}\" failed in {}ms", status.getName(), this.getJobRuntime(status), exception); } return status; }
Source:
public void setLocale(@Nullable String languageCode, @Nullable String regionCode) { Locale locale = null; if (!Strings.isNullOrEmpty(languageCode) && !Strings.isNullOrEmpty(regionCode)) { locale = Locale.forLanguageTag(String.join("/", languageCode, regionCode)); } else if (!Strings.isNullOrEmpty(languageCode)) { locale = Locale.forLanguageTag(languageCode); } else if (!Strings.isNullOrEmpty(regionCode)) { locale = Locale.forLanguageTag(String.join("/", UNDEFINED_LANGUAGE, regionCode)); } this.locale = locale; }

Target:
public void setLocale(@Nullable String languageCode, @Nullable String regionCode) { this.locale = new Locale.Builder().setLanguage(languageCode).setRegion(regionCode).build(); }
Source:
public static ISideEffectFactory createFactory(Widget disposableWidget) { ICompositeSideEffect compositeSideEffect = (ICompositeSideEffect) disposableWidget .getData(ICompositeSideEffect.class.getName()); if (compositeSideEffect == null) { ICompositeSideEffect newCompositeSideEffect = ICompositeSideEffect.create(); disposableWidget.setData(ICompositeSideEffect.class.getName(), newCompositeSideEffect); disposableWidget.addDisposeListener(e -> newCompositeSideEffect.dispose()); compositeSideEffect = newCompositeSideEffect; } return ISideEffectFactory.createFactory(compositeSideEffect::add); }

Target:
public static ISideEffectFactory createFactory(Widget disposableWidget) { CompositeSideEffect compositeSideEffect = (CompositeSideEffect) disposableWidget .getData(CompositeSideEffect.class.getName()); if (compositeSideEffect == null) { CompositeSideEffect newCompositeSideEffect = new CompositeSideEffect(); disposableWidget.setData(CompositeSideEffect.class.getName(), newCompositeSideEffect); disposableWidget.addDisposeListener(e -> newCompositeSideEffect.dispose()); compositeSideEffect = newCompositeSideEffect; } return ISideEffectFactory.createFactory(compositeSideEffect::add); }
Source:
public static double integrate(final DoubleFunction<Double> getIntegrand, final double lowerBound, final double upperBound, final int numPoints) { final GaussIntegrator integrator = integratorFactory.legendre(numPoints, lowerBound, upperBound); final double[] gaussIntegrationWeights = IntStream.range(0, numPoints).mapToDouble(integrator::getWeight).toArray(); final double[] gaussIntegrationAbscissas = IntStream.range(0, numPoints).mapToDouble(integrator::getPoint).toArray(); final double[] integrands = Arrays.stream(gaussIntegrationAbscissas).map(getIntegrand::apply).toArray(); return GATKProtectedMathUtils.dotProduct(gaussIntegrationWeights, integrands); }

Target:
public static double integrate(final DoubleFunction<Double> getIntegrand, final double lowerBound, final double upperBound, final int numPoints) { final GaussIntegrator integrator = integratorFactory.legendre(numPoints, lowerBound, upperBound); final double[] gaussIntegrationWeights = new IndexRange(0, numPoints).mapToDouble(integrator::getWeight); final double[] gaussIntegrationAbscissas = new IndexRange(0, numPoints).mapToDouble(integrator::getPoint); final double[] integrands = MathUtils.applyToArrayInPlace(gaussIntegrationAbscissas,getIntegrand::apply); return GATKProtectedMathUtils.dotProduct(gaussIntegrationWeights, integrands); }
Source:
public AuditLogType getAuditLogTypeValue() { if (getSucceeded()) return AuditLogType.GLUSTER_GEOREP_CONFIG_SET_DEFAULT; else return errorType == null ? AuditLogType.GLUSTER_GEOREP_CONFIG_SET_DEFAULT_FAILED : errorType; }

Target:
public AuditLogType getAuditLogTypeValue() { if (getSucceeded()) { return AuditLogType.GLUSTER_GEOREP_CONFIG_SET_DEFAULT; } else { return errorType == null ? AuditLogType.GLUSTER_GEOREP_CONFIG_SET_DEFAULT_FAILED : errorType; } }
Source:
public boolean addStaticListField(String fieldName, String fieldPrettyName, int size, boolean multiSelect, boolean relationalStorage, String values, String displayType, String separators, String defaultValue, String freeText, boolean largeStorage) { if (get(fieldName) == null) { StaticListClass list_class = new StaticListClass(); list_class.setName(fieldName); list_class.setPrettyName(fieldPrettyName); list_class.setSize(size); list_class.setMultiSelect(multiSelect); list_class.setRelationalStorage(relationalStorage); list_class.setValues(values); if (displayType != null) { list_class.setDisplayType(displayType); } if (separators != null) { list_class.setSeparators(separators); list_class.setSeparator(separators.substring(0, 1)); } if (defaultValue != null) { list_class.setDefaultValue(defaultValue); } list_class.setFreeText(freeText); if (!freeText.equals(ListClass.FREE_TEXT_FORBIDDEN)) { list_class.setPicker(true); } list_class.setLargeStorage(largeStorage); list_class.setObject(this); put(fieldName, list_class); return true; } return false; }

Target:
public boolean addStaticListField(String fieldName, String fieldPrettyName, int size, boolean multiSelect, boolean relationalStorage, String values, String displayType, String separators, String defaultValue, String freeText, boolean largeStorage) { if (get(fieldName) == null) { StaticListClass list_class = new StaticListClass(); list_class.setName(fieldName); list_class.setPrettyName(fieldPrettyName); list_class.setSize(size); list_class.setMultiSelect(multiSelect); list_class.setRelationalStorage(relationalStorage); list_class.setValues(values); if (displayType != null) { list_class.setDisplayType(displayType); } if (separators != null) { list_class.setSeparators(separators); list_class.setSeparator(separators.substring(0, 1)); } if (defaultValue != null) { list_class.setDefaultValue(defaultValue); } list_class.setFreeText(freeText); if (!ListClass.FREE_TEXT_FORBIDDEN.equals(freeText)) { list_class.setPicker(true); } list_class.setLargeStorage(largeStorage); list_class.setObject(this); put(fieldName, list_class); return true; } return false; }
Source:
public static int compareRanges(byte[] left, int leftOffset, int leftLength, byte[] right, int rightOffset, int rightLength) { long leftAddress = ARRAY_BYTE_BASE_OFFSET + leftOffset; long rightAddress = ARRAY_BYTE_BASE_OFFSET + rightOffset; int compareLength = min(leftLength, rightLength); while (compareLength >= SIZE_OF_LONG) { long leftLong = unsafe.getLong(left, leftAddress); long rightLong = unsafe.getLong(right, rightAddress); if (leftLong != rightLong) { return longBytesToLong(leftLong) < longBytesToLong(rightLong) ? -1 : 1; } leftAddress += SIZE_OF_LONG; rightAddress += SIZE_OF_LONG; compareLength -= SIZE_OF_LONG; } while (compareLength > 0) { byte leftByte = unsafe.getByte(left, leftAddress); byte rightByte = unsafe.getByte(right, rightAddress); int compareResult = compareUnsignedBytes(leftByte, rightByte); if (compareResult != 0) { return compareResult; } leftAddress++; rightAddress++; compareLength--; } return Integer.compare(leftLength, rightLength); }

Target:
public static int compareRanges(byte[] left, int leftOffset, int leftLength, byte[] right, int rightOffset, int rightLength) { long leftAddress = ARRAY_BYTE_BASE_OFFSET + leftOffset; long rightAddress = ARRAY_BYTE_BASE_OFFSET + rightOffset; int lengthToCompare = min(leftLength, rightLength); while (lengthToCompare >= SIZE_OF_LONG) { long leftLong = unsafe.getLong(left, leftAddress); long rightLong = unsafe.getLong(right, rightAddress); if (leftLong != rightLong) { return longBytesToLong(leftLong) < longBytesToLong(rightLong) ? -1 : 1; } leftAddress += SIZE_OF_LONG; rightAddress += SIZE_OF_LONG; lengthToCompare -= SIZE_OF_LONG; } while (lengthToCompare > 0) { int compareResult = compareUnsignedBytes(unsafe.getByte(left, leftAddress), unsafe.getByte(right, rightAddress)); if (compareResult != 0) { return compareResult; } leftAddress++; rightAddress++; lengthToCompare--; } return Integer.compare(leftLength, rightLength); }
Source:
public void init() { explorerMode = ( ( Window.Location.getParameterMap().containsKey( "explorer_mode" ) ) ? Window.Location.getParameterMap().get( "explorer_mode" ).get( 0 ) : "" ).trim(); projectPathString = ( ( ( Window.Location.getParameterMap().containsKey( "path" ) ) ? Window.Location.getParameterMap().get( "path" ).get( 0 ) : "" ) ).trim(); projectEditorDisableBuild = Window.Location.getParameterMap().containsKey( "no_build" ); final PlaceRequest placeRequest = generateProjectExplorerPlaceRequest(); docks.setup("AuthoringPerspective", placeRequest); }

Target:
public void init() { explorerMode = ( ( Window.Location.getParameterMap().containsKey( "explorer_mode" ) ) ? Window.Location.getParameterMap().get( "explorer_mode" ).get( 0 ) : "" ).trim(); projectPathString = ( ( ( Window.Location.getParameterMap().containsKey( "path" ) ) ? Window.Location.getParameterMap().get( "path" ).get( 0 ) : "" ) ).trim(); projectEditorDisableBuild = Window.Location.getParameterMap().containsKey( "no_build" ); final PlaceRequest placeRequest = generateProjectExplorerPlaceRequest(); docks.setup(PerspectiveIds.AUTHORING, placeRequest); }
Source:
public void emptySessionKeys() throws ConfigurationException { PipeForward forw = new PipeForward("lessthan", "/Users/apollo11/Desktop/iaf2/core/src/test/resources/Pipes"); pipe.registerForward(forw); pipe.setSessionKey1(""); pipe.setSessionKey2(""); pipe.configure(); }

Target:
public void emptySessionKeys() throws ConfigurationException { pipe.setSessionKey1(""); pipe.setSessionKey2(""); pipe.configure(); }
Source:
public void insertWorkerTransaction(long transactionId, long nodeId) { ShardWriterDao dao = shardDbi.get(getNodeShard(nodeId)).onDemand(ShardWriterDao.class); dao.insertWorkerTransaction(transactionId, nodeId, System.currentTimeMillis()); }

Target:
public void insertWorkerTransaction(long transactionId, long nodeId) { ShardWriterDao dao = shardDbi.get(getTableShard(nodeId)).onDemand(ShardWriterDao.class); dao.insertWorkerTransaction(transactionId, nodeId, System.currentTimeMillis()); }
Source:
public boolean validateUuid(String uuid) { if (StringUtils.isEmpty(uuid)) { return false; } if (useHyphens && uuid.length() == 32) { return hexPattern.matcher(uuid).matches(); } else if (!useHyphens && uuid.length() == 36) { return hexPatternWithHypens.matcher(uuid).matches(); } return false; }

Target:
public boolean validateUuid(String uuid) { if (StringUtils.isEmpty(uuid)) { return false; } if (!useHyphens && uuid.length() == 32) { return hexPattern.matcher(uuid).matches(); } else if (useHyphens && uuid.length() == 36) { return hexPatternWithHypens.matcher(uuid).matches(); } return false; }
Source:
public void initializeWithProjectsTest() { doReturn( true ).when( libraryService ).thereIsAProjectInTheWorkbench(); libraryMonitor.initialize(); assertTrue( libraryMonitor.thereIsAtLeastOneProjectAccessible() ); verify( workbench ).addStartupBlocker( LibraryMonitor.class ); verify( workbench ).removeStartupBlocker( LibraryMonitor.class ); }

Target:
public void initializeWithProjectsTest() { thereIsAProjectInTheWorkbench( true ); }
Source:
public Entity newInstance(World world) { try { return (Entity)this.ctr.newInstance(world); } catch (Exception e) { FMLLog.log.error("Encountered an exception while constructing entity '" + this.getRegistryName() + '\'', e); return null; } }

Target:
public Entity newInstance(World world) { return this.factory.apply(world); }
Source:
@Override public boolean isMergeEnabled() { return true; }

Target:
public boolean isMergeEnabled() { return true; }
Source:
public static final boolean isSingleColumnTreeTable(final TableConfiguration tableConfiguration) { TableDisplayStyle style = (TableDisplayStyle) tableConfiguration.getStyle(NattablestylePackage.eINSTANCE.getTableDisplayStyle()); Assert.isNotNull(style); final DisplayStyle displayStyle = style.getDisplayStyle(); return DisplayStyle.HIERARCHIC_SINGLE_TREE_COLUMN.equals(displayStyle); }

Target:
public static final boolean isSingleColumnTreeTable(final TableConfiguration tableConfiguration) { final TableDisplayStyle style = (TableDisplayStyle) tableConfiguration.getStyle(NattablestylePackage.eINSTANCE.getTableDisplayStyle()); Assert.isNotNull(style); final DisplayStyle displayStyle = style.getDisplayStyle(); return DisplayStyle.HIERARCHIC_SINGLE_TREE_COLUMN.equals(displayStyle); }
Source:
public PackFile openPack(final File pack) throws IOException { final String p = pack.getName(); if (p.length() != 50 || !p.startsWith("pack-") || !p.endsWith(".pack")) throw new IOException(MessageFormat.format(JGitText.get().notAValidPack, pack)); final List<PackExt> extensions = new ArrayList<PackExt>( PackExt.values().length); extensions.add(PACK); extensions.add(INDEX); final String base = p.substring(0, p.length() - 4); for (PackExt ext : PackExt.values()) { if (ext != PACK && ext != INDEX) { final String name = base + ext.getExtension(); if (new File(pack.getParentFile(), name).exists()) extensions.add(ext); } } PackFile res = new PackFile(pack, extensions); insertPack(res); return res; }

Target:
public PackFile openPack(final File pack) throws IOException { final String p = pack.getName(); if (p.length() != 50 || !p.startsWith("pack-") || !p.endsWith(".pack")) throw new IOException(MessageFormat.format(JGitText.get().notAValidPack, pack)); int extensions = 1 << PACK.getPosition() | 1 << INDEX.getPosition(); final String base = p.substring(0, p.length() - 4); for (PackExt ext : PackExt.values()) { int mask = 1 << ext.getPosition(); if ((extensions & mask) == 0) { final String name = base + ext.getExtension(); if (new File(pack.getParentFile(), name).exists()) extensions |= mask; } } PackFile res = new PackFile(pack, extensions); insertPack(res); return res; }
Source:
public T next() { init(); try { final T retVal = objectCodec.readValue(jp, typeRef); jp.nextToken(); return retVal; } catch (IOException e) { throw Throwables.propagate(e); } }

Target:
public T next() { if (!hasNext()) { throw new NoSuchElementException("No more objects to read!"); } try { final T retVal = objectCodec.readValue(jp, typeRef); jp.nextToken(); return retVal; } catch (IOException e) { throw new RuntimeException(e); } }
Source:
protected void onLoad() { enableForm(false); super.onLoad(); Util.PROJECT_SVC.projectDetail(projectName, new GerritCallback<ProjectDetail>() { public void onSuccess(final ProjectDetail result) { com.google.gerrit.client.account.Util.ACCOUNT_SEC.myGroups(new GerritCallback<List<AccountGroup>>() { public void onSuccess(List<AccountGroup> myGroups) { boolean hasOwnRights = Util.hasOwnRight(result, myGroups); enableForm(true); display(result, !hasOwnRights); addPanel.setVisible(hasOwnRights); delRight.setVisible(hasOwnRights); } }); } }); }

Target:
protected void onLoad() { enableForm(false); super.onLoad(); Util.PROJECT_SVC.projectDetail(projectName, new GerritCallback<ProjectDetail>() { public void onSuccess(final ProjectDetail result) { enableForm(true); display(result); addPanel.setVisible(result.canModifyData); delRight.setVisible(result.canModifyData); } }); }
Source:
public CompletableFuture<List<Multihash>> put(PublicSigningKey writer, List<byte[]> blocks) { return CompletableFuture.completedFuture(blocks.stream() .map(b -> { byte[] hash = hash(b); Multihash multihash = new Multihash(Multihash.Type.sha2_256, hash); Cid cid = new Cid(1, Cid.Codec.DagCbor, multihash); put(cid, b); return cid; }).collect(Collectors.toList())); }

Target:
public CompletableFuture<List<Multihash>> put(PublicSigningKey writer, List<byte[]> blocks) { return CompletableFuture.completedFuture(blocks.stream() .map(b -> { byte[] hash = hash(b); Multihash multihash = new Multihash(Multihash.Type.sha2_256, hash); Cid cid = new Cid(CID_V1, Cid.Codec.DagCbor, multihash); put(cid, b); return cid; }).collect(Collectors.toList())); }
Source:
public String retrieve(VeluxBridgeProvider bridge) { logger.trace("retrieve() called."); logger.trace("retrieve() About to query device status."); BCgetDeviceStatus.Response response = bridge.bridgeCommunicate(new BCgetDeviceStatus()); if ((response == null) || (!response.getResult())) { logger.trace("retrieve() finished with failure."); return null; } else { logger.trace("retrieve() finished successfully with result {}.", response.getDeviceStatus()); return response.getDeviceStatus(); } }

Target:
public String retrieve(VeluxBridgeProvider bridge) { logger.trace("retrieve() called."); logger.trace("retrieve() About to query device status."); BCgetDeviceStatus.Response response = bridge.bridgeCommunicate(new BCgetDeviceStatus()); if ((response == null) || (!response.getResult())) { logger.trace("retrieve() finished with failure."); return null; } logger.trace("retrieve() finished successfully with result {}.", response.getDeviceStatus()); return response.getDeviceStatus(); }
Source:
public void refresh() { try { if (this.client == null) { SustainedConnectionWorker.this.totalMetadataConnections.incrementAndGet(); this.client = AdminClient.create(this.props); } this.client.describeCluster().nodes().get(); } catch (Throwable e) { this.closeQuietly(); SustainedConnectionWorker.this.totalMetadataConnections.decrementAndGet(); SustainedConnectionWorker.this.totalMetadataFailedConnections.incrementAndGet(); SustainedConnectionWorker.log.error("Error while refreshing sustained AdminClient connection", e.getMessage()); } this.nextUpdate = System.currentTimeMillis() + this.refreshRate; this.inUse = false; }

Target:
public void refresh() { try { if (this.client == null) { SustainedConnectionWorker.this.totalMetadataConnections.incrementAndGet(); this.client = AdminClient.create(this.props); } this.client.describeCluster().nodes().get(); } catch (Throwable e) { this.closeQuietly(); SustainedConnectionWorker.this.totalMetadataConnections.decrementAndGet(); SustainedConnectionWorker.this.totalMetadataFailedConnections.incrementAndGet(); SustainedConnectionWorker.log.error("Error while refreshing sustained AdminClient connection", e); } this.completeRefresh(); }
Source:
private T invokeHandlerMethod(HandlerMethod handlerMethod, ParametersWrapper parameters) throws Exception { try { return (T) handlerMethod.invoke(parameters); } catch (MethodArgumentResolutionException | MessageConversionException | IllegalStateException e) { if (e instanceof MessageConversionException) { if (e.getCause() instanceof ConversionFailedException && !(e.getCause().getCause() instanceof ConverterNotFoundException)) { throw e; } } else if (e instanceof IllegalStateException) { if (e.getCause() instanceof IllegalArgumentException && (!"argument type mismatch".equals(e.getCause().getMessage()) && !e.getCause().getMessage().startsWith("java.lang.ClassCastException@"))) { throw e; } } Expression expression = handlerMethod.expression; if (++handlerMethod.failedAttempts == FAILED_ATTEMPTS_THRESHOLD) { handlerMethod.spelOnly = true; if (logger.isInfoEnabled()) { logger.info("Failed to invoke [ " + handlerMethod.invocableHandlerMethod + "] with provided arguments [ " + parameters + " ]. \n" + "Falling back to SpEL invocation for expression [ " + expression.getExpressionString() + " ]"); } } return invokeExpression(expression, parameters); } }

Target:
private T invokeHandlerMethod(HandlerMethod handlerMethod, ParametersWrapper parameters) throws Exception { try { return (T) handlerMethod.invoke(parameters); } catch (MethodArgumentResolutionException | MessageConversionException | IllegalStateException e) { if (e instanceof MessageConversionException) { if (e.getCause() instanceof ConversionFailedException && !(e.getCause().getCause() instanceof ConverterNotFoundException)) { throw e; } } else if (e instanceof IllegalStateException) { if (!(e.getCause() instanceof IllegalArgumentException) || !e.getStackTrace()[0].getClassName().equals(InvocableHandlerMethod.class.getName()) || (!"argument type mismatch".equals(e.getCause().getMessage()) && !e.getCause().getMessage().startsWith("java.lang.ClassCastException@"))) { throw e; } } Expression expression = handlerMethod.expression; if (++handlerMethod.failedAttempts >= FAILED_ATTEMPTS_THRESHOLD) { handlerMethod.spelOnly = true; if (logger.isInfoEnabled()) { logger.info("Failed to invoke [ " + handlerMethod.invocableHandlerMethod + "] with provided arguments [ " + parameters + " ]. \n" + "Falling back to SpEL invocation for expression [ " + expression.getExpressionString() + " ]"); } } return invokeExpression(expression, parameters); } }
Source:
public String enqueueUpdateDeviceCdmaSettingsRequest(final String organisationIdentification, final String deviceIdentification, final CdmaSettings cdmaSettings) throws FunctionalException { final Organisation organisation = this.domainHelperService.findOrganisation(organisationIdentification); final Device device = this.deviceDomainService.searchDevice(deviceIdentification); this.domainHelperService.isAllowed(organisation, device, DeviceFunction.UPDATE_DEVICE_CDMA_SETTINGS); LOGGER.debug( "enqueueUpdateDeviceCdmaSettingsRequest called with organisation {}, deviceIdentifcation {}, and {}", organisationIdentification, deviceIdentification, cdmaSettings); final String correlationUid = this.correlationIdProviderService.getCorrelationId(organisationIdentification, deviceIdentification); final DeviceMessageMetadata deviceMessageMetadata = new DeviceMessageMetadata(deviceIdentification, organisationIdentification, correlationUid, CommonRequestMessageType.UPDATE_DEVICE_CDMA_SETTINGS.name()); final CommonRequestMessage message = new CommonRequestMessage.Builder() .deviceMessageMetadata(deviceMessageMetadata).request(cdmaSettings).build(); this.commonRequestMessageSender.send(message); return correlationUid; }

Target:
public String enqueueUpdateDeviceCdmaSettingsRequest(final String organisationIdentification, final String deviceIdentification, final CdmaSettings cdmaSettings) throws FunctionalException { final Organisation organisation = this.domainHelperService.findOrganisation(organisationIdentification); final Device device = this.deviceDomainService.searchDevice(deviceIdentification); this.domainHelperService.isAllowed(organisation, device, DeviceFunction.UPDATE_DEVICE_CDMA_SETTINGS); LOGGER.debug( "enqueueUpdateDeviceCdmaSettingsRequest called with organisation {}, deviceIdentification {}, and {}", organisationIdentification, deviceIdentification, cdmaSettings); final String correlationUid = this.correlationIdProviderService.getCorrelationId(organisationIdentification, deviceIdentification); final DeviceMessageMetadata deviceMessageMetadata = new DeviceMessageMetadata(deviceIdentification, organisationIdentification, correlationUid, CommonRequestMessageType.UPDATE_DEVICE_CDMA_SETTINGS.name()); final CommonRequestMessage message = new CommonRequestMessage.Builder() .deviceMessageMetadata(deviceMessageMetadata).request(cdmaSettings).build(); this.commonRequestMessageSender.send(message); return correlationUid; }
Source:
public int hashCode() { int result = _domainUuid != null ? _domainUuid.hashCode() : 0; result = 31 * result + (_networkUuid != null ? _networkUuid.hashCode() : 0); result = 31 * result + (_isL3Network ? 1 : 0); result = 31 * result + (_isSharedNetwork ? 1 : 0); result = 31 * result + (_vpcUuid != null ? _vpcUuid.hashCode() : 0); result = 31 * result + (_domainTemplateName != null ? _domainTemplateName.hashCode() : 0); return result; }

Target:
public int hashCode() { int result = super.hashCode(); result = 31 * result + (_domainUuid != null ? _domainUuid.hashCode() : 0); result = 31 * result + (_networkUuid != null ? _networkUuid.hashCode() : 0); result = 31 * result + (_isL3Network ? 1 : 0); result = 31 * result + (_isSharedNetwork ? 1 : 0); result = 31 * result + (_vpcUuid != null ? _vpcUuid.hashCode() : 0); result = 31 * result + (_domainTemplateName != null ? _domainTemplateName.hashCode() : 0); return result; }
Source:
public void onScrollingEnded(CardWheelHorizontalView cardWheel, Object startValue, Object endValue) { switch (cardWheel.getId()) { case R.id.anglePicker: case R.id.altitudePicker: case R.id.overlapPicker: case R.id.sidelapPicker: final Drone drone = getDrone(); try { final List<T> surveyList = getMissionItems(); if (!surveyList.isEmpty()) { for (final T survey : surveyList) { SurveyDetail surveyDetail = survey.getSurveyDetail(); surveyDetail.setAltitude(mAltitudePicker.getCurrentValue().toBase().getValue()); surveyDetail.setAngle(mAnglePicker.getCurrentValue()); surveyDetail.setOverlap(mOverlapPicker.getCurrentValue()); surveyDetail.setSidelap(mSidelapPicker.getCurrentValue()); } final MissionItem.ComplexItem<T>[] surveys = surveyList .toArray(new MissionItem.ComplexItem[surveyList.size()]); drone.buildMissionItemsAsync(surveys, this); System.out.println("nothing"); } } catch (Exception e) { Log.e(TAG, "Error while building the survey.", e); } break; } }

Target:
public void onScrollingEnded(CardWheelHorizontalView cardWheel, Object startValue, Object endValue) { switch (cardWheel.getId()) { case R.id.anglePicker: case R.id.altitudePicker: case R.id.overlapPicker: case R.id.sidelapPicker: final Drone drone = getDrone(); try { final List<T> surveyList = getMissionItems(); if (!surveyList.isEmpty()) { for (final T survey : surveyList) { SurveyDetail surveyDetail = survey.getSurveyDetail(); surveyDetail.setAltitude(mAltitudePicker.getCurrentValue().toBase().getValue()); surveyDetail.setAngle(mAnglePicker.getCurrentValue()); surveyDetail.setOverlap(mOverlapPicker.getCurrentValue()); surveyDetail.setSidelap(mSidelapPicker.getCurrentValue()); } final MissionItem.ComplexItem<T>[] surveys = surveyList .toArray(new MissionItem.ComplexItem[surveyList.size()]); drone.buildMissionItemsAsync(surveys, this); } } catch (Exception e) { Log.e(TAG, "Error while building the survey.", e); } break; } }
Source:
public SetClockConfigurationRequestData(final short timeZoneOffset, final CosemDateTime daylightSavingsBegin, final CosemDateTime daylightSavingsEnd, final byte daylightSavingsDeviation, final boolean daylightSavingsEnabled) { this.timeZoneOffset = timeZoneOffset; this.daylightSavingsBegin = new CosemDateTime(daylightSavingsBegin); this.daylightSavingsEnd = new CosemDateTime(daylightSavingsEnd); this.daylightSavingsDeviation = daylightSavingsDeviation; this.daylightSavingsEnabled = daylightSavingsEnabled; }

Target:
public SetClockConfigurationRequestData(final short timeZoneOffset, final CosemDateTime daylightSavingsBegin, final CosemDateTime daylightSavingsEnd, final byte daylightSavingsDeviation, final boolean daylightSavingsEnabled) { this.timeZoneOffset = timeZoneOffset; this.daylightSavingsBegin = daylightSavingsBegin; this.daylightSavingsEnd = daylightSavingsEnd; this.daylightSavingsDeviation = daylightSavingsDeviation; this.daylightSavingsEnabled = daylightSavingsEnabled; }
Source:
protected Map<String, String> getFileSystemProperties(BatchSourceContext context) { Map<String, String> properties = new HashMap<>(config.getFileSystemProperties()); if (config.shouldCopyHeader()) { properties.put(PathTrackingInputFormat.COPY_HEADER, "true"); } Pattern pattern = config.getFilePattern(); properties.put(INPUT_REGEX_CONFIG, pattern == null ? ".*" : pattern.toString()); properties.put("mapreduce.input.pathFilter.class", BatchFileFilter.class.getName()); return properties; }

Target:
protected Map<String, String> getFileSystemProperties(BatchSourceContext context) { Map<String, String> properties = new HashMap<>(config.getFileSystemProperties()); if (config.shouldCopyHeader()) { properties.put(PathTrackingInputFormat.COPY_HEADER, "true"); } return properties; }
Source:
public int getAverageTemp() { return averageTemperature; }

Target:
public int getAverageTemp() { averageTemperature = AstronomicalBodyHelper.getAverageTemperature(this.getStar(), this.getSolarOrbitalDistance(), this.getAtmosphereDensity()); return averageTemperature; }