auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
@Test public void testPushAggregateThroughtOuterJoin16() { final HepProgram preProgram = new HepProgramBuilder() .addRuleInstance(AggregateProjectMergeRule.INSTANCE) .build(); final HepProgram program = new HepProgramBuilder() .addRuleInstance(AggregateJoinTransposeRule.EXTENDED) .build(); final String sql = "select e.job\n" + "from (select * from sales.emp where empno = 10) as e\n" + "left outer join sales.dept as d on e.job = d.name\n" + "and e.deptno + e.empno = d.deptno + 5\n" + "group by e.job"; checkPlanning(tester, preProgram, new HepPlanner(program), sql); }

Target:
@Test public void testPushAggregateThroughtOuterJoin16() { final HepProgram preProgram = new HepProgramBuilder() .addRuleInstance(AggregateProjectMergeRule.INSTANCE) .build(); final HepProgram program = new HepProgramBuilder() .addRuleInstance(AggregateJoinTransposeRule.EXTENDED) .build(); final String sql = "select e.job\n" + "from (select * from sales.emp where empno = 10) as e\n" + "full outer join sales.dept as d on e.job = d.name\n" + "and e.deptno + e.empno = d.deptno + 5\n" + "group by e.job"; checkPlanning(tester, preProgram, new HepPlanner(program), sql); }
Source:
public static long getTxIfoCacheTimeout(FluoConfiguration conf, TimeUnit tu) { int minutes = getTxInfoCacheTimeout(conf); return tu.toMillis((long) minutes); }

Target:
public static long getTxIfoCacheTimeout(FluoConfiguration conf, TimeUnit tu) { long millis = conf.getLong(TX_INFO_CACHE_TIMEOUT, TX_INFO_CACHE_TIMEOUT_DEFAULT); if (millis <= 0) { throw new IllegalArgumentException("Timeout must positive for " + TX_INFO_CACHE_TIMEOUT); } return tu.convert(millis, TimeUnit.MILLISECONDS); }
Source:
public void setNotification(TransientNotification notification) { titleLabel.setText(notification.getTitle()); messageLabel.setText(notification.getText()); messageLabel.setWrapText(true); messageLabel.setMinHeight(Region.USE_PREF_SIZE); imageView.setImage(notification.getImage()); action = notification.getActionCallback(); }

Target:
public void setNotification(TransientNotification notification) { titleLabel.setText(notification.getTitle()); messageLabel.setText(notification.getText()); imageView.setImage(notification.getImage()); action = notification.getActionCallback(); }
Source:
private void addFolderToZip(String path, String srcFolder, ZipOutputStream zip) { File folder = new File(srcFolder); String[] fileList = folder.list(); try { if (fileList != null) { int i = 0; while (true) { if (fileList.length == i) break; String newPath = folder.getName(); if (!path.equalsIgnoreCase("")) { newPath = path + "/" + newPath; } if (new File(folder, fileList[i]).isDirectory()) { zip.putNextEntry(new ZipEntry(newPath + "/" + fileList[i] + "/")); } addToZip(newPath, srcFolder + "/" + fileList[i], zip); i++; } } } catch (Exception ex) { getLog().error("Error occurred while creating CAR file. " + ex); } }

Target:
private void addFolderToZip(String path, String srcFolder, ZipOutputStream zip) throws ArchiveException { File folder = new File(srcFolder); String[] fileList = folder.list(); if (fileList == null) { return; } try { int i = 0; while (true) { if (fileList.length == i) break; String newPath = folder.getName(); if (!path.equalsIgnoreCase(Constants.EMPTY_STRING)) { newPath = path + File.separator + newPath; } if (new File(folder, fileList[i]).isDirectory()) { zip.putNextEntry(new ZipEntry(newPath + File.separator + fileList[i] + File.separator)); } addToZip(newPath, srcFolder + File.separator + fileList[i], zip); i++; } } catch (IOException ex) { throw new ArchiveException(Constants.ARCHIVE_EXCEPTION_MSG, ex); } }
Source:
protected String createSearchPattern(Collection<RegisterVmData> entities) { String vm_guidKey = "ID ="; String vm_nameKey = "NAME ="; String orKey = " or "; StringBuilder searchPattern = new StringBuilder(); searchPattern.append("VM: "); for (RegisterVmData vmData : entities) { VM vm = vmData.getVm(); searchPattern.append(vm_guidKey); searchPattern.append(vm.getId().toString()); searchPattern.append(orKey); searchPattern.append(vm_nameKey); searchPattern.append(vm.getName()); searchPattern.append(orKey); } return searchPattern.substring(0, searchPattern.length() - orKey.length()); }

Target:
protected String createSearchPattern(Collection<RegisterVmData> entities) { String vm_guidKey = "ID = "; String vm_nameKey = "NAME = "; String orKey = " or "; String prefix = "VM: "; StringJoiner sj = new StringJoiner(orKey, prefix, ""); entities.stream().map(ImportVmData::getVm).forEach(vm -> { sj.add(vm_guidKey + vm.getId().toString()); sj.add(vm_nameKey + vm.getName()); }); return sj.toString(); }
Source:
private Map<String, Properties> getBundleDefaultProperties(long bundleId) throws IOException { Bundle bundle = bundleContext.getBundle(bundleId); Enumeration<URL> enumeration = bundle.findEntries("", "*.properties", false); Map<String, Properties> allDefaultProperties = new LinkedHashMap<>(); if (CollectionUtils.isNotEmpty(Collections.list(enumeration))) { while (enumeration.hasMoreElements()) { InputStream is = null; URL url = enumeration.nextElement(); try { is = url.openStream(); Properties defaultBundleProperties = new Properties(); defaultBundleProperties.load(is); if (!url.getFile().isEmpty()) { allDefaultProperties.put(url.getFile().substring(1), defaultBundleProperties); } } catch (IOException e) { LOGGER.error("Error while reading or retrieving default properties", e); } finally { IOUtils.closeQuietly(is); } } } return allDefaultProperties; }

Target:
private Map<String, Properties> getBundleDefaultProperties(long bundleId) throws IOException { Bundle bundle = bundleContext.getBundle(bundleId); Enumeration<URL> enumeration = bundle.findEntries("", "*.properties", false); Map<String, Properties> allDefaultProperties = new LinkedHashMap<>(); if (enumeration != null) { while (enumeration.hasMoreElements()) { InputStream is = null; URL url = enumeration.nextElement(); try { is = url.openStream(); Properties defaultBundleProperties = new Properties(); defaultBundleProperties.load(is); if (!url.getFile().isEmpty()) { allDefaultProperties.put(url.getFile().substring(1), defaultBundleProperties); } } catch (IOException e) { LOGGER.error("Error while reading or retrieving default properties", e); } finally { IOUtils.closeQuietly(is); } } } return allDefaultProperties; }
Source:
public List<String> getPKStrings() { ArrayList<String> list = new ArrayList<>(); String pkString = "db:" + table.getDatabase().getName() + "/" + "tbl:" + table.getName() + "/"; for ( Row r : filteredRows()) { list.add(pkString + getPKStringForRow(r)); } return list; }

Target:
public List<String> getPKStrings() { ArrayList<String> list = new ArrayList<>(); for ( Row r : filteredRows()) { list.add(new MaxwelllPKJSONObject(table.getDatabase().getName(), table.getName(), getPKMapForRow(r)).toString()); } return list; }
Source:
public void accountSession(String username, String password) throws TmdbInvalidParametersException { if (username == null || password==null) throw new TmdbInvalidParametersException(401,"Username and Password may not be null"); this.username = username; this.password = password; hasAccountSession = true; }

Target:
public void accountSession(String username, String password) throws TmdbInvalidParametersException { if (username == null || password == null) { throw new TmdbInvalidParametersException(401, "Username and Password may not be null"); } this.username = username; this.password = password; hasAccountSession = true; }
Source:
public byte[] getUuidBytesArray() { ByteBuffer uuidBuf; switch (version) { case BLOB_ID_V1: case BLOB_ID_V2: case BLOB_ID_V3: case BLOB_ID_V4: case BLOB_ID_V5: byte[] uuidBytes = getUuid().getBytes(); uuidBuf = ByteBuffer.allocate(UUID_SIZE_FIELD_LENGTH_IN_BYTES + (short) uuidBytes.length); uuidBuf.putInt(uuidBytes.length); uuidBuf.put(uuidBytes); break; case BLOB_ID_V6: uuidBuf = ByteBuffer.allocate(UuidSerDe.SIZE_IN_BYTES); UuidSerDe.serialize(uuid, uuidBuf); break; default: throw new IllegalArgumentException("blobId version=" + version + " not supported"); } return uuidBuf.array(); }

Target:
public byte[] getUuidBytesArray() { ByteBuffer uuidBuf; switch (version) { case BLOB_ID_V1: case BLOB_ID_V2: case BLOB_ID_V3: case BLOB_ID_V4: case BLOB_ID_V5: byte[] uuidBytes = getUuid().getBytes(); uuidBuf = ByteBuffer.allocate((short) uuidBytes.length); uuidBuf.put(uuidBytes); break; case BLOB_ID_V6: uuidBuf = ByteBuffer.allocate(UuidSerDe.SIZE_IN_BYTES); UuidSerDe.serialize(uuid, uuidBuf); break; default: throw new IllegalArgumentException("blobId version=" + version + " not supported"); } return uuidBuf.array(); }
Source:
public boolean equals(Object o) { if ( this == o ) { return true; } if ( o == null || getClass() != o.getClass() ) { return false; } ConstraintViolationImpl<?> that = (ConstraintViolationImpl<?>) o; if ( interpolatedMessage != null ? !interpolatedMessage.equals( that.interpolatedMessage ) : that.interpolatedMessage != null ) { return false; } if ( messageTemplate != null ? !messageTemplate.equals( that.messageTemplate ) : that.messageTemplate != null ) { return false; } if ( propertyPath != null ? !propertyPath.equals( that.propertyPath ) : that.propertyPath != null ) { return false; } if ( rootBean != null ? ( rootBean != that.rootBean ) : that.rootBean != null ) { return false; } if ( leafBeanInstance != null ? ( leafBeanInstance != that.leafBeanInstance ) : that.leafBeanInstance != null ) { return false; } if ( value != null ? ( value != that.value ) : that.value != null ) { return false; } if ( constraintDescriptor != null ? !constraintDescriptor.equals( that.constraintDescriptor ) : that.constraintDescriptor != null ) { return false; } if ( elementType != null ? !elementType.equals( that.elementType ) : that.elementType != null ) { return false; } if ( rootBeanClass != null ? !rootBeanClass.equals( that.rootBeanClass ) : that.rootBeanClass != null ) { return false; } return true; }

Target:
public boolean equals(Object o) { if ( this == o ) { return true; } if ( o == null || getClass() != o.getClass() ) { return false; } ConstraintViolationImpl<?> that = (ConstraintViolationImpl<?>) o; if ( interpolatedMessage != null ? !interpolatedMessage.equals( that.interpolatedMessage ) : that.interpolatedMessage != null ) { return false; } if ( messageTemplate != null ? !messageTemplate.equals( that.messageTemplate ) : that.messageTemplate != null ) { return false; } if ( propertyPath != null ? !propertyPath.equals( that.propertyPath ) : that.propertyPath != null ) { return false; } if ( rootBean != null ? ( rootBean != that.rootBean ) : that.rootBean != null ) { return false; } if ( leafBeanInstance != null ? ( leafBeanInstance != that.leafBeanInstance ) : that.leafBeanInstance != null ) { return false; } if ( value != null ? ( value != that.value ) : that.value != null ) { return false; } if ( constraintDescriptor != null ? !constraintDescriptor.equals( that.constraintDescriptor ) : that.constraintDescriptor != null ) { return false; } if ( elementType != null ? !elementType.equals( that.elementType ) : that.elementType != null ) { return false; } return true; }
Source:
public GraphicsConsoles list() { GraphicsConsoles consoles = new GraphicsConsoles(); Map<GraphicsType, GraphicsInfo> graphicsTypeToGraphicsInfo; T entity = loadEntity(); boolean current = ParametersHelper.getBooleanParameter(httpHeaders, uriInfo, CURRENT, true, false); if (current) { graphicsTypeToGraphicsInfo = extractGraphicsInofs(entity); } else { List<GraphicsType> graphicsTypes = DisplayHelper.getGraphicsTypesForEntity(this, guid, true); graphicsTypeToGraphicsInfo = new HashMap<>(); for (GraphicsType type : graphicsTypes) { graphicsTypeToGraphicsInfo.put(type, null); } } for (Map.Entry<GraphicsType, GraphicsInfo> graphicsInfo : graphicsTypeToGraphicsInfo.entrySet()) { GraphicsConsole graphicsConsole = addLinks(populate(VmMapper.map(graphicsInfo, null), entity)); graphicsConsole.setRemoteViewerConnectionFile(getRemoteViewerConnectionFileContent(graphicsInfo)); consoles.getGraphicsConsoles().add(graphicsConsole); } return consoles; }

Target:
public GraphicsConsoles list() { GraphicsConsoles consoles = new GraphicsConsoles(); Map<GraphicsType, GraphicsInfo> graphicsTypeToGraphicsInfo; T entity = loadEntity(); boolean current = ParametersHelper.getBooleanParameter(httpHeaders, uriInfo, CURRENT, true, false); if (current) { graphicsTypeToGraphicsInfo = extractGraphicsInofs(entity); } else { List<GraphicsType> graphicsTypes = DisplayHelper.getGraphicsTypesForEntity(this, guid, true); graphicsTypeToGraphicsInfo = new HashMap<>(); for (GraphicsType type : graphicsTypes) { graphicsTypeToGraphicsInfo.put(type, null); } } for (Map.Entry<GraphicsType, GraphicsInfo> graphicsInfo : graphicsTypeToGraphicsInfo.entrySet()) { consoles.getGraphicsConsoles().add(addLinks(populate(VmMapper.map(graphicsInfo, null), entity))); } return consoles; }
Source:
public ObjectRetentionConfiguration(RetentionMode mode, DateTime retainUntilDate) throws XmlPullParserException, InvalidArgumentException { super(); super.name = "Retention"; if (mode == null) { throw new InvalidArgumentException("null is not allowed in mode. Valid values are 'COMPLIANCE' and 'GOVERNANCE'"); } this.mode = mode.toString(); if (retainUntilDate == null) { throw new InvalidArgumentException("retain until date cant be null, it must be a valid date."); } this.retainUntilDate = retainUntilDate.toString(DateFormat.RETENTION_DATE_FORMAT); }

Target:
public ObjectRetentionConfiguration(RetentionMode mode, DateTime retainUntilDate) throws XmlPullParserException, InvalidArgumentException { this(); if (mode == null) { throw new InvalidArgumentException("null mode is not allowed"); } this.mode = mode.toString(); if (retainUntilDate == null) { throw new InvalidArgumentException("null retainUntilDate is not allowed"); } this.retainUntilDate = retainUntilDate.toString(DateFormat.EXPIRATION_DATE_FORMAT); }
Source:
private void onTopicPresent(HttpServerExchange exchange, String messageId, Consumer<CachedTopic> consumer) { String qualifiedTopicName = exchange.getQueryParameters().get("qualifiedTopicName").getFirst(); try { Optional<CachedTopic> topic = topicsCache.getTopic(qualifiedTopicName); if (topic.isPresent()) { if (!topicsCache.isBlacklisted(topic.get().getQualifiedName())) { consumer.accept(topic.get()); } else { topicBlacklisted(exchange, qualifiedTopicName, messageId); } } else { nonExistentTopic(exchange, qualifiedTopicName, messageId); } } catch (IllegalArgumentException exception) { missingTopicGroup(exchange, qualifiedTopicName, messageId); } }

Target:
private void onTopicPresent(HttpServerExchange exchange, String messageId, Consumer<CachedTopic> consumer) { String qualifiedTopicName = exchange.getQueryParameters().get("qualifiedTopicName").getFirst(); try { Optional<CachedTopic> cachedTopic = topicsCache.getTopic(qualifiedTopicName); if (cachedTopic.isPresent()) { CachedTopic topic = cachedTopic.get(); if (!topic.isBlacklisted()) { consumer.accept(topic); } else { topicBlacklisted(exchange, qualifiedTopicName, messageId); } } else { nonExistentTopic(exchange, qualifiedTopicName, messageId); } } catch (IllegalArgumentException exception) { missingTopicGroup(exchange, qualifiedTopicName, messageId); } }
Source:
public void encode(RowData element, OutputStream stream) throws IOException { stream.write(serializationSchema.serialize(element)); stream.write(DEFAULT_LINE_DELIMITER.getBytes()); }

Target:
public void encode(RowData element, OutputStream stream) throws IOException { stream.write(serializationSchema.serialize(element)); stream.write(DEFAULT_LINE_DELIMITER.getBytes(StandardCharsets.UTF_8)); }
Source:
public void markNotificationsAsRead() { if (this.getNumberOfUnreadNotifications() > 0) { if (this.markNotificationsAsReadThisWiki.isDisplayed()) { this.click(this.markNotificationsAsReadThisWiki); } else { this.click(this.markNotificationsAsRead); this.waitForElementVisibleByElement(this.markNotificationsAsReadAllWikis); this.click(this.markNotificationsAsReadAllWikis); } this.waitForElementNotPresent("#WallNotifications > li > div.reddot"); } }

Target:
public void markNotificationsAsRead() { if (this.getNumberOfUnreadNotifications() > 0) { if (this.markNotificationsAsReadThisWiki.isDisplayed()) { this.click(this.markNotificationsAsReadThisWiki); } else { this.click(this.markNotificationsAsRead); this.waitForElementVisibleByElement(this.markNotificationsAsReadAllWikis); this.click(this.markNotificationsAsReadAllWikis); } this.waitForElementNotPresent(unreadNotificationReddot); } }
Source:
private void visitFunctionParameters(FunctionType ftype, boolean emitTemplatizedTypes) { if (emitTemplatizedTypes) { visitTemplateTypes(ftype); } emit("("); Iterator<Node> parameters = ftype.getParameters().iterator(); Iterator<String> names = null; Node functionSource = ftype.getSource(); if (functionSource != null) { Iterable<Node> parameterNodes = functionSource.getFirstChild().getNext().children(); names = Iterables.transform(parameterNodes, NODE_GET_STRING).iterator(); } char pName = 'a'; while (parameters.hasNext()) { Node param = parameters.next(); if (param.isVarArgs()) { emit("..."); } if (names != null && names.hasNext()) { emitNoSpace(names.next()); } else { emitNoSpace("" + pName); if (pName == 'z') { pName = 'A'; } else { pName++; } } if (param.isOptionalArg()) { emit("?"); } visitTypeDeclaration(param.getJSType(), param.isVarArgs()); if (parameters.hasNext()) { emit(", "); } } emit(")"); }

Target:
private void visitFunctionParameters(FunctionType ftype, boolean emitTemplatizedTypes) { if (emitTemplatizedTypes) { visitTemplateTypes(ftype); } emit("("); Iterator<Node> parameters = ftype.getParameters().iterator(); Iterator<String> names = null; Node functionSource = ftype.getSource(); if (functionSource != null) { Iterable<Node> parameterNodes = functionSource.getFirstChild().getNext().children(); names = Iterables.transform(parameterNodes, NODE_GET_STRING).iterator(); } int paramCount = 0; while (parameters.hasNext()) { Node param = parameters.next(); if (param.isVarArgs()) { emit("..."); } if (names != null && names.hasNext()) { emitNoSpace(names.next()); } else { String pName; if (paramCount < 26) { pName = Character.toString((char) (97 + paramCount)); } else { pName = "p" + (paramCount - 26); } emitNoSpace("" + pName); paramCount++; } if (param.isOptionalArg()) { emit("?"); } visitTypeDeclaration(param.getJSType(), param.isVarArgs()); if (parameters.hasNext()) { emit(", "); } } emit(")"); }
Source:
public DigitalTwinsAsyncClient buildAsyncClient() { Objects.requireNonNull(tokenCredential, "'tokenCredential' cannot be null."); Objects.requireNonNull(endpoint, "'endpoint' cannot be null"); this.serviceVersion = this.serviceVersion != null ? this.serviceVersion : DigitalTwinsServiceVersion.getLatest(); this.retryPolicy = this.retryPolicy != null ? this.retryPolicy : new RetryPolicy(); this.httpPipeline = this.httpPipeline != null ? httpPipeline : buildPipeline(this.tokenCredential, this.endpoint, this.logOptions, this.httpClient, this.additionalPolicies, this.retryPolicy); return new DigitalTwinsAsyncClient(this.httpPipeline, this.serviceVersion, this.endpoint); }

Target:
public DigitalTwinsAsyncClient buildAsyncClient() { Objects.requireNonNull(tokenCredential, "'tokenCredential' cannot be null."); Objects.requireNonNull(endpoint, "'endpoint' cannot be null"); this.serviceVersion = this.serviceVersion != null ? this.serviceVersion : DigitalTwinsServiceVersion.getLatest(); this.retryPolicy = this.retryPolicy != null ? this.retryPolicy : new RetryPolicy(); if (this.httpPipeline == null) { this.httpPipeline = buildPipeline( this.tokenCredential, this.endpoint, this.logOptions, this.httpClient, this.additionalPolicies, this.retryPolicy); } return new DigitalTwinsAsyncClient(this.httpPipeline, this.serviceVersion, this.endpoint); }
Source:
public void addReferencePointMapping(String referencePointId, IReferencePoint referencePoint) { if (referencePointMapper.getReferencePoint(referencePointId) == null) { if (wouldCreateNestedReferencePoint(referencePoint)) { leaveSessionDueToNestedReferencePoint(referencePoint); return; } referencePointMapper.addReferencePoint(referencePointId, referencePoint); listenerDispatch.referencePointAdded(referencePoint); } }

Target:
public void addReferencePointMapping(String referencePointId, IReferencePoint referencePoint) { if (referencePointMapper.getReferencePoint(referencePointId) == null) { referencePointMapper.addReferencePoint(referencePointId, referencePoint); listenerDispatch.referencePointAdded(referencePoint); } }
Source:
public void shouldAnswerToPingWithPong() throws Exception { ServerConnectionEstablisher establisher = new ServerConnectionEstablisher(); HttpMessage handshakeRequest = new HttpMessage(HttpHandshakeBuilder.getHttpHandshakeRequestHeader(super.getServertUrl())); WebSocketProxy webSocketProxy = establisher.send(new HandshakeConfig(handshakeRequest,false,false)); NanoWebSocketConnection webSocketConnection = super.getLastConnection(); webSocketConnection.setPingScheduling(50,("1010").getBytes()); Thread.sleep(250); assertTrue(webSocketProxy.isConnected()); List<NanoWSD.WebSocketFrame> messages = webSocketConnection.getListOfIncomingMessages(); assertEquals(4, messages.size()); for(int i = 0; i < messages.size(); i++){ assertEquals("1010", messages.get(i).getTextPayload()); } }

Target:
public void shouldAnswerToPingWithPong() throws Exception { ServerConnectionEstablisher establisher = new ServerConnectionEstablisher(); HttpMessage handshakeRequest = new HttpMessage(HttpHandshakeBuilder.getHttpHandshakeRequestHeader(super.getServertUrl())); WebSocketProxy webSocketProxy = establisher.send(new HandshakeConfig(handshakeRequest,false,false)); NanoWebSocketConnection webSocketConnection = super.getLastConnection(); webSocketConnection.setPingScheduling(50,("1010").getBytes()); Thread.sleep(250); assertTrue(webSocketProxy.isConnected()); List<WebSocketFrame> messages = webSocketConnection.getListOfIncomingMessages(); assertEquals(4, messages.size()); for(WebSocketFrame message : messages){ assertEquals("1010", message.getTextPayload()); assertEquals("Pong", message.getOpCode().toString()); } }
Source:
public Map<String, String> getProperties(PropertyArgs pa, List<OperatorConf> opConfs, String appName) { Map<String, String> opProps = Maps.newHashMap(); Map<String, TemplateConf> templates = stramConf.getChildren(StramElement.TEMPLATE); if (!templates.isEmpty()) { TreeMap<Integer, TemplateConf> matchingTemplates = getMatchingTemplates(pa, appName, templates); if (matchingTemplates != null && !matchingTemplates.isEmpty()) { for (TemplateConf t : matchingTemplates.descendingMap().values()) { opProps.putAll(Maps.fromProperties(t.properties)); } } List<TemplateConf> refTemplates = getDirectTemplates(opConfs, templates); for (TemplateConf t : refTemplates) { opProps.putAll(Maps.fromProperties(t.properties)); } } for (int i = opConfs.size()-1; i >= 0; i--) { Conf conf1 = opConfs.get(i); opProps.putAll(Maps.fromProperties(conf1.properties)); } return opProps; }

Target:
private Map<String, String> getProperties(PropertyArgs pa, List<OperatorConf> opConfs, String appName) { Map<String, String> opProps = Maps.newHashMap(); Map<String, TemplateConf> templates = stramConf.getChildren(StramElement.TEMPLATE); if (!templates.isEmpty()) { TreeMap<Integer, TemplateConf> matchingTemplates = getMatchingTemplates(pa, appName, templates); if (matchingTemplates != null && !matchingTemplates.isEmpty()) { for (TemplateConf t : matchingTemplates.descendingMap().values()) { opProps.putAll(Maps.fromProperties(t.properties)); } } List<TemplateConf> refTemplates = getDirectTemplates(opConfs, templates); for (TemplateConf t : refTemplates) { opProps.putAll(Maps.fromProperties(t.properties)); } } for (int i = opConfs.size()-1; i >= 0; i--) { Conf conf1 = opConfs.get(i); opProps.putAll(Maps.fromProperties(conf1.properties)); } return opProps; }
Source:
public int testCarts(List<EntityMinecart> carts) { if (logic == null || !logic.isValid()) return NO_POWER; for (EntityMinecart cart : carts) { if (routingController.getButtonState() == RoutingButtonState.PRIVATE) if (!getOwner().equals(CartToolsAPI.getCartOwner(cart))) continue; int value = logic.evaluate(this, cart); if (value != 0) return (value == -1 ? FULL_POWER : value); } return NO_POWER; }

Target:
public int testCarts(List<EntityMinecart> carts) { if (logic == null || !logic.isValid()) return NO_POWER; int value = NO_POWER; for (EntityMinecart cart : carts) { if (routingController.getButtonState() == RoutingButtonState.PRIVATE) if (!getOwner().equals(CartToolsAPI.getCartOwner(cart))) continue; value = Math.max(value, logic.evaluate(this, cart)); } return value; }
Source:
private Callback<Long> fetchStitchRequestBodyCallback(CopyingAsyncWritableChannel channel, BlobInfo blobInfo) { return buildCallback(frontendMetrics.postReadStitchRequestMetrics, bytesRead -> router.stitchBlob(blobInfo.getBlobProperties(), blobInfo.getUserMetadata(), getChunksToStitch(blobInfo.getBlobProperties(), FrontendUtils.readJsonFromChannel(channel)), routerStitchBlobCallback(blobInfo)), uri, LOGGER, finalCallback); }

Target:
private Callback<Long> fetchStitchRequestBodyCallback(CopyingAsyncWritableChannel channel, BlobInfo blobInfo) { return buildCallback(frontendMetrics.postReadStitchRequestMetrics, bytesRead -> router.stitchBlob(blobInfo.getBlobProperties(), blobInfo.getUserMetadata(), getChunksToStitch(blobInfo.getBlobProperties(), readJsonFromChannel(channel)), routerStitchBlobCallback(blobInfo)), uri, LOGGER, finalCallback); }
Source:
void assign(AssignableReplica assignableReplica) { if (addToAssignmentRecord(assignableReplica)) { assignableReplica.getCapacity().entrySet().stream().forEach( capacity -> updateCapacityAndUtilization(capacity.getKey(), capacity.getValue())); } else { throw new HelixException(String .format("Resource %s already has a replica from partition %s on node %s", assignableReplica.getResourceName(), assignableReplica.getPartitionName(), getInstanceName())); } }

Target:
void assign(AssignableReplica assignableReplica) { addToAssignmentRecord(assignableReplica); assignableReplica.getCapacity().entrySet().stream() .forEach(capacity -> updateCapacityAndUtilization(capacity.getKey(), capacity.getValue())); }
Source:
public void testPLFM_5989() throws IOException { String fileName = "testPLFM_5989.csv"; String csvString = null; try(InputStream in =UploadPreviewBuilderTest.class.getClassLoader().getResourceAsStream(fileName)){ assertNotNull("Cannot find: "+fileName+" on classpath", in); csvString = IOUtils.toString(in, StandardCharsets.UTF_8); } System.out.println(Arrays.toString(csvString.getBytes(StandardCharsets.UTF_8))); CsvTableDescriptor descriptor = new CsvTableDescriptor(); descriptor.setIsFirstLineHeader(true); UploadToTablePreviewRequest request = new UploadToTablePreviewRequest(); request.setCsvTableDescriptor(descriptor); StringReader sReader = new StringReader(csvString); Long linesToSkip = 0L; CSVReader reader = CSVUtils.createCSVReader(sReader, descriptor, linesToSkip); UploadPreviewBuilder builder = new UploadPreviewBuilder(reader, mockProgressCallback, request); UploadToTablePreviewResult result = builder.buildResult(); assertNotNull(result); assertNotNull(result.getSuggestedColumns()); assertEquals(2, result.getSuggestedColumns().size()); ColumnModel cm = result.getSuggestedColumns().get(0); assertEquals(ColumnType.STRING, cm.getColumnType()); assertEquals("column1", cm.getName()); assertEquals(new Long(5), cm.getMaximumSize()); cm = result.getSuggestedColumns().get(1); assertEquals(ColumnType.DOUBLE, cm.getColumnType()); assertEquals("column2", cm.getName()); }

Target:
public void testPLFM_5989() throws IOException { String fileName = "testPLFM_5989.csv"; String csvString = null; try(InputStream in =UploadPreviewBuilderTest.class.getClassLoader().getResourceAsStream(fileName)){ assertNotNull("Cannot find: "+fileName+" on classpath", in); csvString = IOUtils.toString(in, StandardCharsets.UTF_8); } CsvTableDescriptor descriptor = new CsvTableDescriptor(); descriptor.setIsFirstLineHeader(true); UploadToTablePreviewRequest request = new UploadToTablePreviewRequest(); request.setCsvTableDescriptor(descriptor); StringReader sReader = new StringReader(csvString); Long linesToSkip = 0L; CSVReader reader = CSVUtils.createCSVReader(sReader, descriptor, linesToSkip); UploadPreviewBuilder builder = new UploadPreviewBuilder(reader, mockProgressCallback, request); UploadToTablePreviewResult result = builder.buildResult(); assertNotNull(result); assertNotNull(result.getSuggestedColumns()); assertEquals(2, result.getSuggestedColumns().size()); ColumnModel cm = result.getSuggestedColumns().get(0); assertEquals(ColumnType.STRING, cm.getColumnType()); assertEquals("column1", cm.getName()); assertEquals(new Long(5), cm.getMaximumSize()); cm = result.getSuggestedColumns().get(1); assertEquals(ColumnType.DOUBLE, cm.getColumnType()); assertEquals("column2", cm.getName()); }
Source:
public Map<Client, PaxosLong> apply(Set<Client> clients) { try { return unsafeGetLatest(clients); } catch (RemoteException e) { if (e.getError().errorName().equals(BatchPaxosAcceptor.CACHE_KEY_NOT_FOUND.name())) { log.info("Cache key is invalid, invalidating cache"); return handleCacheMiss(clients); } log.error("received remote exception that is not a cache key miss", e); throw e; } catch (RuntimeException e) { if (e.getMessage().contains(BatchPaxosAcceptor.CACHE_KEY_NOT_FOUND.name())) { log.info("Cache key is invalid, invalidating cache - using deprecated detection method"); return handleCacheMiss(clients); } log.error("received unexpected runtime exception", e); throw e; } }

Target:
public Map<Client, PaxosLong> apply(Set<Client> clients) { try { return unsafeGetLatest(clients); } catch (RemoteException e) { if (e.getError().errorName().equals(BatchPaxosAcceptor.CACHE_KEY_NOT_FOUND.name())) { log.info("Cache key is invalid, invalidating cache"); return handleCacheMiss(clients); } log.warn("received remote exception that is not a cache key miss", e); throw e; } catch (RuntimeException e) { if (e.getMessage().contains(BatchPaxosAcceptor.CACHE_KEY_NOT_FOUND.name())) { log.info("Cache key is invalid, invalidating cache - using deprecated detection method"); return handleCacheMiss(clients); } log.warn("received unexpected runtime exception", e); throw e; } }
Source:
private WifiMode getWifiMode(List<? extends NetInterfaceAddressConfig> netInterfaceAddresses) { WifiMode wifiMode = WifiMode.UNKNOWN; for (NetInterfaceAddressConfig netInterfaceAddress : netInterfaceAddresses) { if (netInterfaceAddress instanceof WifiInterfaceAddressConfig) { wifiMode = ((WifiInterfaceAddressConfig) netInterfaceAddress).getMode(); } } return wifiMode; }

Target:
private WifiMode getWifiMode(List<? extends NetInterfaceAddressConfig> netInterfaceAddresses) { WifiMode wifiMode = WifiMode.UNKNOWN; for (NetInterfaceAddressConfig netInterfaceAddress : netInterfaceAddresses) { if (netInterfaceAddress instanceof WifiInterfaceAddressConfig) { wifiMode = ((WifiInterfaceAddressConfig) netInterfaceAddress).getMode(); break; } } return wifiMode; }
Source:
protected ApplicationInterfaceEntity saveApplicationInterface( ApplicationInterfaceDescription applicationInterfaceDescription, String gatewayId) throws AppCatalogException { String applicationInterfaceId = applicationInterfaceDescription.getApplicationInterfaceId(); Mapper mapper = ObjectMapperSingleton.getInstance(); ApplicationInterfaceEntity applicationInterfaceEntity = mapper.map(applicationInterfaceDescription, ApplicationInterfaceEntity.class); if (gatewayId != null) applicationInterfaceEntity.setGatewayId(gatewayId); if (applicationInterfaceEntity.getApplicationInputs() != null) { applicationInterfaceEntity.getApplicationInputs().forEach(applicationInputEntity -> applicationInputEntity.setInterfaceId(applicationInterfaceId)); } if (applicationInterfaceEntity.getApplicationOutputs() != null) { applicationInterfaceEntity.getApplicationOutputs().forEach(applicationOutputEntity -> applicationOutputEntity.setInterfaceId(applicationInterfaceId)); } if (!isApplicationInterfaceExists(applicationInterfaceId)) applicationInterfaceEntity.setCreationTime(new Timestamp(System.currentTimeMillis())); applicationInterfaceEntity.setUpdateTime(new Timestamp(System.currentTimeMillis())); return execute(entityManager -> entityManager.merge(applicationInterfaceEntity)); }

Target:
protected ApplicationInterfaceEntity saveApplicationInterface( ApplicationInterfaceDescription applicationInterfaceDescription, String gatewayId) throws AppCatalogException { String applicationInterfaceId = applicationInterfaceDescription.getApplicationInterfaceId(); Mapper mapper = ObjectMapperSingleton.getInstance(); ApplicationInterfaceEntity applicationInterfaceEntity = mapper.map(applicationInterfaceDescription, ApplicationInterfaceEntity.class); if (gatewayId != null) { logger.debug("Setting the gateway ID of the Application Interface"); applicationInterfaceEntity.setGatewayId(gatewayId); } if (applicationInterfaceEntity.getApplicationInputs() != null) { logger.debug("Populating the Primary Key of ApplicationInputs objects for the Application Interface"); applicationInterfaceEntity.getApplicationInputs().forEach(applicationInputEntity -> applicationInputEntity.setInterfaceId(applicationInterfaceId)); } if (applicationInterfaceEntity.getApplicationOutputs() != null) { logger.debug("Populating the Primary Key of ApplicationOutputs objects for the Application Interface"); applicationInterfaceEntity.getApplicationOutputs().forEach(applicationOutputEntity -> applicationOutputEntity.setInterfaceId(applicationInterfaceId)); } if (!isApplicationInterfaceExists(applicationInterfaceId)) { logger.debug("Checking if the Application Interface already exists"); applicationInterfaceEntity.setCreationTime(new Timestamp(System.currentTimeMillis())); } applicationInterfaceEntity.setUpdateTime(new Timestamp(System.currentTimeMillis())); return execute(entityManager -> entityManager.merge(applicationInterfaceEntity)); }
Source:
default ColumnValueSelector<Float> makeColumnValueSelector(ReadableOffset offset, ImmutableBitmap nullValueBitmap) { final boolean hasNulls = !nullValueBitmap.isEmpty(); class HistoricalFloatColumnSelector implements FloatColumnSelector, HistoricalColumnSelector<Float> { @Override public float getFloat() { return ColumnarFloats.this.get(offset.getOffset()); } @Override public boolean isNull() { return hasNulls && nullValueBitmap.get(offset.getOffset()); } @Override public double getDouble(int offset) { return ColumnarFloats.this.get(offset); } @Override public void inspectRuntimeShape(RuntimeShapeInspector inspector) { inspector.visit("columnar", ColumnarFloats.this); inspector.visit("offset", offset); } } return new HistoricalFloatColumnSelector(); }

Target:
default ColumnValueSelector<Float> makeColumnValueSelector(ReadableOffset offset, ImmutableBitmap nullValueBitmap) { if (nullValueBitmap.isEmpty()) { class HistoricalFloatColumnSelector implements FloatColumnSelector, HistoricalColumnSelector<Float> { @Override public boolean isNull() { return false; } @Override public float getFloat() { return ColumnarFloats.this.get(offset.getOffset()); } @Override public double getDouble(int offset) { return ColumnarFloats.this.get(offset); } @Override public void inspectRuntimeShape(RuntimeShapeInspector inspector) { inspector.visit("columnar", ColumnarFloats.this); inspector.visit("offset", offset); } } return new HistoricalFloatColumnSelector(); } else { class HistoricalFloatColumnSelectorwithNulls implements FloatColumnSelector, HistoricalColumnSelector<Float> { @Override public boolean isNull() { return nullValueBitmap.get(offset.getOffset()); } @Override public float getFloat() { assert NullHandling.replaceWithDefault() || !isNull(); return ColumnarFloats.this.get(offset.getOffset()); } @Override public double getDouble(int offset) { assert NullHandling.replaceWithDefault() || !nullValueBitmap.get(offset); return ColumnarFloats.this.get(offset); } @Override public void inspectRuntimeShape(RuntimeShapeInspector inspector) { inspector.visit("columnar", ColumnarFloats.this); inspector.visit("offset", offset); inspector.visit("nullValueBitmap", nullValueBitmap); } } return new HistoricalFloatColumnSelectorwithNulls(); } }
Source:
public InstanceInZoneToNodeMetadata(Map<Instance.Status, NodeMetadata.Status> toPortableNodeStatus, GroupNamingConvention.Factory namingConvention, @Memoized Supplier<Map<URI, ? extends Image>> images, @Memoized Supplier<Map<URI, ? extends Hardware>> hardwares, @Memoized Supplier<Map<URI, ? extends Location>> locations, FirewallTagNamingConvention.Factory firewallTagNamingConvention) { this.toPortableNodeStatus = toPortableNodeStatus; this.nodeNamingConvention = namingConvention.createWithoutPrefix(); this.images = images; this.hardwares = hardwares; this.locations = locations; this.firewallTagNamingConvention = firewallTagNamingConvention; }

Target:
public InstanceInZoneToNodeMetadata(Map<Instance.Status, NodeMetadata.Status> toPortableNodeStatus, GroupNamingConvention.Factory namingConvention, @Memoized Supplier<Map<URI, ? extends Image>> images, @Memoized Supplier<Map<URI, ? extends Hardware>> hardwares, @Memoized Supplier<Map<URI, ? extends Location>> locations, FirewallTagNamingConvention.Factory firewallTagNamingConvention) { this.toPortableNodeStatus = toPortableNodeStatus; this.nodeNamingConvention = namingConvention.createWithoutPrefix(); this.images = images; this.hardwares = hardwares; this.locations = locations; this.firewallTagNamingConvention = checkNotNull(firewallTagNamingConvention, "firewallTagNamingConvention"); }
Source:
void setConsentStatuses(Map<SubpopulationGuid,ConsentStatus> consentStatuses) { this.consentStatuses = consentStatuses; }

Target:
void setConsentStatuses(Map<SubpopulationGuid,ConsentStatus> consentStatuses) { this.consentStatuses = (consentStatuses == null) ? ImmutableMap.<SubpopulationGuid,ConsentStatus>of() : ImmutableMap.copyOf(consentStatuses); }
Source:
private static String getMimeTypeFromMessage(MimeMessage message) throws MessagingException { try { return new MimeType(message.getContentType()).getBaseType(); } catch (MimeTypeParseException e) { LOGGER.warn(e.toString()); return ""; } }

Target:
private static Optional<String> getMimeTypeFromMessage(MimeMessage message) throws MessagingException { try { return Optional.of(new MimeType(message.getContentType()).getBaseType()); } catch (MimeTypeParseException e) { LOGGER.warn(String.format("Error while parsing message's mimeType %s", message.getContentType()), e); return Optional.empty(); } }
Source:
public final void destroy() throws IOException { try (Closer closer = Closer.create()) { closer.register(queryRunner); closer.register(embeddedElasticsearch); } catch (IOException e) { throw new UncheckedIOException(e); } }

Target:
public final void destroy() throws IOException { try (Closer closer = Closer.create()) { closer.register(queryRunner); closer.register(embeddedElasticsearchNode); } queryRunner = null; }
Source:
private int calculateValue(NetworkCluster networkCluster) { int res = 0; if (networkCluster != null) { if (networkCluster.isDefaultRoute()) { res += 16; } if (networkCluster.isManagement()) { res += 8; } if (networkCluster.isDisplay()) { res += 4; } if (networkCluster.isMigration()) { res += 2; } if (networkCluster.isGluster()) { res += 1; } } return res; }

Target:
private int calculateValue(NetworkCluster networkCluster) { int res = 0; if (networkCluster != null) { if (networkCluster.isManagement()) { res += 16; } if (networkCluster.isDefaultRoute()) { res += 8; } if (networkCluster.isDisplay()) { res += 4; } if (networkCluster.isMigration()) { res += 2; } if (networkCluster.isGluster()) { res += 1; } } return res; }
Source:
private static String getPatternForSite(RequestMapping mappingAnnotation, Site site) { final Theme theme = site.getTheme(); String[] annotationValue = mappingAnnotation.value(); if (annotationValue.length == 0) return null; String annotationPattern = Iterables.getOnlyElement(Arrays.asList(annotationValue)); Map<String, Object> mappingsConfig; try { mappingsConfig = theme.getConfigMap("mappings"); } catch (IOException e) { throw new RuntimeException(e); } Map<String, Object> override = (Map<String, Object>) mappingsConfig.get(mappingAnnotation.name()); if (override == null) { return annotationPattern; } else { Boolean enabled = (Boolean) override.get("enabled"); if (enabled == null || enabled) { String overridePattern = (String) override.get("pattern"); return (overridePattern != null) ? overridePattern : annotationPattern; } else { return null; } } }

Target:
private static String getPatternForSite(RequestMapping mappingAnnotation, Site site) { final Theme theme = site.getTheme(); String[] annotationValue = mappingAnnotation.value(); if (annotationValue.length == 0) return null; String annotationPattern = Iterables.getOnlyElement(Arrays.asList(annotationValue)); Map<String, Object> mappingsConfig; try { mappingsConfig = theme.getConfigMap("mappings"); } catch (IOException e) { throw new RuntimeException(e); } Map<String, Object> override = (Map<String, Object>) mappingsConfig.get(mappingAnnotation.name()); if (override == null) { return annotationPattern; } else { Boolean disabled = (Boolean) override.get("disabled"); if (disabled != null && disabled) return null; String overridePattern = (String) override.get("pattern"); return (overridePattern != null) ? overridePattern : annotationPattern; } }
Source:
public boolean apply(final String serverId) { checkNotNull(serverId, "serverId"); logger.trace("looking for state on Server %s", serverId); final Server server = api.getServer(serverId); if (server == null) return false; logger.trace("%s: looking for server %s deployed: currently: %s", server, server.state()); if (server.state().isFailed()) { throw new IllegalStateException(MessageFormat.format("Server {0} is in FAILED state", server.id())); } return server.started() == started && server.deployed() == deployed; }

Target:
public boolean apply(final String serverId) { checkNotNull(serverId, "serverId"); logger.trace("looking for start status on Server %s", serverId); final Server server = api.getServer(serverId); if (server == null) return false; logger.trace("Looking for Server %s to be started: %s currently: %s", server.id(), started, server.started()); if (server.state().isFailed()) { throw new IllegalStateException(String.format("Server %s is in FAILED state", server.id())); } return server.started() == started && server.deployed() == deployed; }
Source:
protected Transition createInitialTransition(Region region, Vertex source, Vertex target, IProgressMonitor monitor, IAdaptable info, String firstTransitionName) throws ExecutionException { EObject newElement = null; CreateElementRequest createElementRequest = new CreateElementRequest(region, UMLElementTypes.TRANSITION); IElementEditService provider = ElementEditServiceUtils.getCommandProvider(region); if (provider == null) { throw new ExecutionException("Impossible to get the provider from " + region); } ICommand createGMFCommand = provider.getEditCommand(createElementRequest); if (createGMFCommand != null) { if (createGMFCommand.canExecute()) { IStatus status = createGMFCommand.execute(monitor, info); if (status.isOK()) { newElement = GMFCommandUtils.getCommandEObjectResult(createGMFCommand); if (!(newElement instanceof Transition)) { throw new ExecutionException("Element creation problem for " + UMLElementTypes.TRANSITION.getDisplayName() + "."); } ((Transition) newElement).setName(firstTransitionName); if (source != null) { ((Transition) newElement).setSource(source); } if (target != null) { ((Transition) newElement).setTarget(target); } ((Transition) newElement).setName(firstTransitionName); return ((Transition) newElement); } else { throw new ExecutionException("Impossible to create the initial Transition"); } } else { throw new ExecutionException("Command to create initial Transition is not executable"); } } else { throw new ExecutionException("Impossible to find a command to create the initial Transition"); } }

Target:
protected Transition createInitialTransition(Region region, Vertex source, Vertex target, IProgressMonitor monitor, IAdaptable info, String firstTransitionName) throws ExecutionException { EObject newElement = null; CreateElementRequest createElementRequest = new CreateElementRequest(region, UMLElementTypes.TRANSITION); IElementEditService provider = ElementEditServiceUtils.getCommandProvider(region); if (provider == null) { throw new ExecutionException("Impossible to get the provider from " + region); } ICommand createGMFCommand = provider.getEditCommand(createElementRequest); if (createGMFCommand != null) { if (createGMFCommand.canExecute()) { IStatus status = createGMFCommand.execute(monitor, info); if (status.isOK()) { newElement = GMFCommandUtils.getCommandEObjectResult(createGMFCommand); if (!(newElement instanceof Transition)) { throw new ExecutionException("Element creation problem for Transition " + "."); } ((Transition) newElement).setName(firstTransitionName); if (source != null) { ((Transition) newElement).setSource(source); } if (target != null) { ((Transition) newElement).setTarget(target); } return ((Transition) newElement); } else { throw new ExecutionException("Impossible to create the initial Transition"); } } else { throw new ExecutionException("Command to create initial Transition is not executable"); } } else { throw new ExecutionException("Impossible to find a command to create the initial Transition"); } }
Source:
public static boolean isWindows() { return getOsName().startsWith("Windows"); }

Target:
public static boolean isWindows() { String osname = getOsName(); return osname != null ? osname.startsWith("Windows") : false; }
Source:
protected AsyncPackageDataModelOracle getOracle() { final AsyncPackageDataModelOracle oracle = super.getOracle(); oracle.addModelFields(new HashMap<String, ModelField[]>() { { put("Applicant", new ModelField[]{ new ModelField("this", "Applicant", ModelField.FIELD_CLASS_TYPE.REGULAR_CLASS, ModelField.FIELD_ORIGIN.SELF, FieldAccessorsAndMutators.ACCESSOR, "Applicant"), new ModelField("age", Integer.class.getName(), ModelField.FIELD_CLASS_TYPE.REGULAR_CLASS, ModelField.FIELD_ORIGIN.SELF, FieldAccessorsAndMutators.ACCESSOR, DataType.TYPE_NUMERIC_INTEGER)}); } } ); return oracle; }

Target:
protected AsyncPackageDataModelOracle getOracle() { final AsyncPackageDataModelOracle oracle = super.getOracle(); oracle.addModelFields(Collections.singletonMap("Applicant", new ModelField[]{ modelField("this", "Applicant"), modelField("age", DataType.TYPE_NUMERIC_INTEGER)})); return oracle; }
Source:
private boolean isPricePanel(Element element) { if (!element.hasClassName(res.style().productSection())) { return true; } return false; }

Target:
private boolean isPricePanel(Element element) { return !element.hasClassName(res.style().productSection()); }