auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
private void createSmallDataset() throws RepositoryException{ Random rGen = new Random(42); int[] labelCount = new int[NUM_LABELS]; int[] aclLabelCount = new int[NUM_LABELS]; int[] aclPar1LabelCount = new int[NUM_LABELS]; Node par = allow(getOrCreateByPath("/parent", "oak:Unstructured", session)); for (int i = 0; i < 4; i++) { Node subPar = par.addNode("par" + i); for (int j = 0; j < NUM_LEAF_NODES/10; j++) { Node child = subPar.addNode("c" + j); child.setProperty("cons", "val"); int labelNum = rGen.nextInt(NUM_LABELS); child.setProperty("foo", "l" + labelNum); labelCount[labelNum]++; if (i != 0) { aclLabelCount[labelNum]++; } if (i == 1) { aclPar1LabelCount[labelNum]++; } } if (i == 0) { deny(subPar); } } session.save(); for (int i = 0; i < labelCount.length; i++) { actualLabelCount.put("l" + i, labelCount[i]); actualAclLabelCount.put("l" + i, aclLabelCount[i]); actualAclPar1LabelCount.put("l" + i, aclPar1LabelCount[i]); } assertNotEquals("Acl-ed and actual counts mustn't be same", actualLabelCount, actualAclLabelCount); }

Target:
private void createSmallDataset() throws RepositoryException{ Random rGen = new Random(42); int[] labelCount = new int[NUM_LABELS]; int[] aclLabelCount = new int[NUM_LABELS]; int[] aclPar1LabelCount = new int[NUM_LABELS]; Node par = allow(getOrCreateByPath("/parent", "oak:Unstructured", session)); for (int i = 0; i < NUM_LABELS; i++) { Node subPar = par.addNode("par" + i); for (int j = 0; j < NUM_LEAF_NODES/(2 * NUM_LABELS); j++) { Node child = subPar.addNode("c" + j); child.setProperty("cons", "val"); int labelNum = rGen.nextInt(NUM_LABELS); child.setProperty("foo", "l" + labelNum); labelCount[labelNum]++; if (i != 0) { aclLabelCount[labelNum]++; } if (i == 1) { aclPar1LabelCount[labelNum]++; } } if (i == 0) { deny(subPar); } } session.save(); for (int i = 0; i < labelCount.length; i++) { actualLabelCount.put("l" + i, labelCount[i]); actualAclLabelCount.put("l" + i, aclLabelCount[i]); actualAclPar1LabelCount.put("l" + i, aclPar1LabelCount[i]); } assertNotEquals("Acl-ed and actual counts mustn't be same", actualLabelCount, actualAclLabelCount); }
Source:
public <T> Exporter<T> export(final Invoker<T> invoker) throws RpcException { final String uri = serviceKey(invoker.getUrl()); Exporter<T> exporter = (Exporter<T>) exporterMap.get(uri); if (exporter != null) { if ("hessian".equals(invoker.getUrl().getProtocol())) { if (exporter.getInvoker().getUrl().equals(invoker.getUrl())) { return exporter; } } else { return exporter; } } final Runnable runnable = doExport(proxyFactory.getProxy(invoker, true), invoker.getInterface(), invoker.getUrl()); exporter = new AbstractExporter<T>(invoker) { @Override public void unexport() { super.unexport(); exporterMap.remove(uri); if (runnable != null) { try { runnable.run(); } catch (Throwable t) { logger.warn(t.getMessage(), t); } } } }; exporterMap.put(uri, exporter); return exporter; }

Target:
public <T> Exporter<T> export(final Invoker<T> invoker) throws RpcException { final String uri = serviceKey(invoker.getUrl()); Exporter<T> exporter = (Exporter<T>) exporterMap.get(uri); if (exporter != null) { if (Objects.equals(exporter.getInvoker().getUrl(), invoker.getUrl())) { return exporter; } } final Runnable runnable = doExport(proxyFactory.getProxy(invoker, true), invoker.getInterface(), invoker.getUrl()); exporter = new AbstractExporter<T>(invoker) { @Override public void unexport() { super.unexport(); exporterMap.remove(uri); if (runnable != null) { try { runnable.run(); } catch (Throwable t) { logger.warn(t.getMessage(), t); } } } }; exporterMap.put(uri, exporter); return exporter; }
Source:
public V putIfAbsent(final K key, final V value) throws CacheLoaderException, CacheWriterException { statusTransitioner.checkAvailable(); checkNonNull(key, value); V inCache = null; final BiFunction<K, V, V> mappingFunction = memoize( new BiFunction<K, V, V>() { @Override public V apply(final K k, final V existingValue) { if(existingValue != null) { return existingValue; } V loaded = null; try { if (cacheLoader != null) { loaded = cacheLoader.load(k); } } catch (Exception e) { throw newCacheLoaderException(e); } if (loaded != null) { return loaded; } if (cacheWriter != null) { try { cacheWriter.write(k, null, value); } catch (Exception e) { throw newCacheWriterException(e); } } return value; } }); try { final Store.ValueHolder<V> holder = store.compute(key, mappingFunction); if (holder != null) { inCache = holder.value(); } } catch (CacheAccessException e) { try { inCache = mappingFunction.apply(key, null); if (cacheLoader != null && cacheWriter != null) { store.remove(key); } else { final Store.ValueHolder<V> holder = store.get(key); if (holder == null) { resilienceStrategy.possiblyInconsistent(key, e); } else { return holder.value(); } } } catch (CacheAccessException e1) { resilienceStrategy.possiblyInconsistent(key, e, e1); } } return inCache == value ? null : inCache; }

Target:
public V putIfAbsent(final K key, final V value) throws CacheLoaderException, CacheWriterException { statusTransitioner.checkAvailable(); checkNonNull(key, value); V inCache = null; final AtomicBoolean installed = new AtomicBoolean(); final BiFunction<K, V, V> mappingFunction = memoize( new BiFunction<K, V, V>() { @Override public V apply(final K k, final V existingValue) { if(existingValue != null) { return existingValue; } V loaded = null; try { if (cacheLoader != null) { loaded = cacheLoader.load(k); } } catch (Exception e) { throw newCacheLoaderException(e); } if (loaded != null) { return loaded; } if (cacheWriter != null) { try { cacheWriter.write(k, null, value); } catch (Exception e) { throw newCacheWriterException(e); } } installed.set(true); return value; } }); try { final Store.ValueHolder<V> holder = store.compute(key, mappingFunction); if (holder != null) { inCache = holder.value(); } } catch (CacheAccessException e) { try { inCache = mappingFunction.apply(key, null); if (cacheLoader != null && cacheWriter != null) { store.remove(key); } else { final Store.ValueHolder<V> holder = store.get(key); if (holder == null) { resilienceStrategy.possiblyInconsistent(key, e); } else { return holder.value(); } } } catch (CacheAccessException e1) { resilienceStrategy.possiblyInconsistent(key, e, e1); } } return installed.get() ? null : inCache; }
Source:
public List<String> getDCFromExpression(String expression) { ArrayList<String> finalDCList = new ArrayList<>(); String dcList = _configuration.getValue(com.salesforce.dva.argus.system.SystemConfiguration.Property.DC_LIST).replaceAll(",","|"); String defaultDC = _configuration.getValue(SystemConfiguration.Property.DC_DEFAULT); ArrayList<String> patterns = new ArrayList<>(Arrays.asList( "\\.(?i)(" + dcList + ")\\.", ":argus\\.")); List<String> scopes = QueryUtils.getScopesFromExpression(expression); List<String> ArgusDC; if (expression == null || expression.isEmpty()) { _logger.error("Expression either null or empty. Cannot retrive DC from the expression. Returning default value " + defaultDC); finalDCList.add(defaultDC); } else if((ArgusDC = getMatchedDCAgainstRegex(scopes, patterns.get(1))) != null) { finalDCList = (ArrayList<String>) ArgusDC; } else { List<String> currentDCList = getMatchedDCAgainstRegex(scopes, patterns.get(0)); if (currentDCList != null) finalDCList = (ArrayList<String>) currentDCList; else { List<MetricQuery> queries = getQueries(expression); ArrayList<String> scopeFromExpandedExpressions = new ArrayList<>(); for(MetricQuery currentQuery: queries) scopeFromExpandedExpressions.add(currentQuery.getScope()); finalDCList = (ArrayList<String>) getMatchedDCAgainstRegex(scopeFromExpandedExpressions, patterns.get(0)); } } if (finalDCList.size() == 0) { _logger.info("Unable to identify DC from expression: " + expression +" . Returning default value PRD " + defaultDC); finalDCList.add(defaultDC); } return new ArrayList<>(finalDCList); }

Target:
public List<String> getDCFromExpression(String expression) { ArrayList<String> finalDCList = new ArrayList<>(); String dcList = _configuration.getValue(com.salesforce.dva.argus.system.SystemConfiguration.Property.DC_LIST).replaceAll(",","|"); String defaultDC = _configuration.getValue(SystemConfiguration.Property.DC_DEFAULT); ArrayList<String> patterns = new ArrayList<>(Arrays.asList( "\\.(?i)(" + dcList + ")\\.", ":argus\\.")); List<String> scopes = QueryUtils.getScopesFromExpression(expression); if (expression == null || expression.isEmpty()) { _logger.error("Expression either null or empty. Cannot retrive DC from the expression. Returning default value " + defaultDC); finalDCList.add(defaultDC); } else { List<String> currentDCList = getMatchedDCAgainstRegex(scopes, patterns.get(0)); if (currentDCList != null) finalDCList = (ArrayList<String>) currentDCList; else { List<MetricQuery> queries = getQueries(expression); ArrayList<String> scopeFromExpandedExpressions = new ArrayList<>(); for(MetricQuery currentQuery: queries) scopeFromExpandedExpressions.add(currentQuery.getScope()); finalDCList = (ArrayList<String>) getMatchedDCAgainstRegex(scopeFromExpandedExpressions, patterns.get(0)); } if(getMatchedDCAgainstRegex(scopes, patterns.get(1)).size() > 0) finalDCList.add(defaultDC); } if (finalDCList.size() == 0) { _logger.info("Unable to identify DC from expression: " + expression +" . Returning default value PRD " + defaultDC); finalDCList.add(defaultDC); } return new ArrayList<>(finalDCList); }
Source:
public void showError(Composite parent, Throwable originalThrowable) { Throwable throwable = wrapError(originalThrowable); String errorMessage = throwable.getMessage(); parent.setLayout(new GridLayout()); Composite statusComposite = new Composite(parent, SWT.NONE); Color bgColor= parent.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND); Color fgColor= parent.getDisplay().getSystemColor(SWT.COLOR_LIST_FOREGROUND); parent.setBackground(bgColor); parent.setForeground(fgColor); GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true); gridData.widthHint = 0; gridData.heightHint = 0; statusComposite.setLayoutData(gridData); IStatus displayStatus = new Status(IStatus.ERROR, JBossCentralActivator.PLUGIN_ID, errorMessage, throwable); new StatusPart(statusComposite, displayStatus); final Link link = new Link(parent, SWT.WRAP); link.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); link.setBackground(bgColor); link.setText(Messages.visualEditorFaq); link.setToolTipText(Messages.visualEditorFaqLink); link.setForeground(link.getDisplay().getSystemColor(SWT.COLOR_BLUE)); link.addMouseListener(new MouseAdapter () { public void mouseDown(MouseEvent e) { BusyIndicator.showWhile(link.getDisplay(), new Runnable() { public void run() { JBossCentralActivator.openUrl(Messages.visualEditorFaqLink, Display.getDefault().getActiveShell(), true); URL theURL = null; try { theURL = new URL(Messages.visualEditorFaqLink); } catch (MalformedURLException e) { JBossCentralActivator.log(e); } IWorkbenchBrowserSupport support = PlatformUI.getWorkbench().getBrowserSupport(); try { support.getExternalBrowser().openURL(theURL); } catch (PartInitException e) { JBossCentralActivator.log(e); } } }); } }); parent.getParent().layout(true, true); }

Target:
public void showError(Composite parent, Throwable originalThrowable) { Throwable throwable = wrapError(originalThrowable); String errorMessage = throwable.getMessage(); parent.setLayout(new GridLayout()); Composite statusComposite = new Composite(parent, SWT.NONE); Color bgColor= parent.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND); Color fgColor= parent.getDisplay().getSystemColor(SWT.COLOR_LIST_FOREGROUND); parent.setBackground(bgColor); parent.setForeground(fgColor); GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true); gridData.widthHint = 0; gridData.heightHint = 0; statusComposite.setLayoutData(gridData); IStatus displayStatus = new Status(IStatus.ERROR, JBossCentralActivator.PLUGIN_ID, errorMessage, throwable); new StatusPart(statusComposite, displayStatus); final Link link = new Link(parent, SWT.WRAP); link.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); link.setBackground(bgColor); link.setText(Messages.visualEditorFaq); link.setToolTipText(Messages.visualEditorFaqLink); link.setForeground(link.getDisplay().getSystemColor(SWT.COLOR_BLUE)); link.addMouseListener(new MouseAdapter () { public void mouseDown(MouseEvent e) { BusyIndicator.showWhile(link.getDisplay(), new Runnable() { public void run() { JBossCentralActivator.openUrl(Messages.visualEditorFaqLink, Display.getDefault().getActiveShell(), true); } }); } }); parent.getParent().layout(true, true); }
Source:
static TableReader create(AlluxioURI uri) throws IOException { if (Format.isCsv(uri.getPath())) { return CsvReader.create(uri); } else if (Format.isParquet(uri.getPath())) { return ParquetReader.create(uri); } else { throw new IOException("Unsupported file format for " + uri); } }

Target:
static TableReader create(AlluxioURI uri) throws IOException { ReadWriterUtils.checkUri(uri); if (Format.isCsv(uri.getPath())) { return CsvReader.create(uri); } else if (Format.isParquet(uri.getPath())) { return ParquetReader.create(uri); } else { throw new IOException("Unsupported file format for " + uri); } }
Source:
private void registerSnapshot () { try { Statement statement = connection.createStatement(); statement.execute("create schema " + tablePrefix); PreparedStatement insertStatement = connection.prepareStatement( "insert into feeds values (?, null, null, null, null, null, current_timestamp, ?)"); insertStatement.setString(1, tablePrefix); insertStatement.setString(2, feedIdToSnapshot); insertStatement.execute(); connection.commit(); LOG.info("Created new snapshot namespace: {}", insertStatement); } catch (Exception ex) { LOG.error("Exception while creating unique prefix for new feed: {}", ex.getMessage()); DbUtils.closeQuietly(connection); } }

Target:
private void registerSnapshot () { try { Statement statement = connection.createStatement(); statement.execute("create schema " + tablePrefix); PreparedStatement insertStatement = connection.prepareStatement( "insert into feeds values (?, null, null, null, null, null, current_timestamp, ?)"); insertStatement.setString(1, tablePrefix); insertStatement.setString(2, feedIdToSnapshot); insertStatement.execute(); connection.commit(); LOG.info("Created new snapshot namespace: {}", insertStatement); } catch (Exception ex) { LOG.error("Exception while registering snapshot namespace in feeds table: {}", ex.getMessage()); DbUtils.closeQuietly(connection); } }
Source:
private void internalSendCommand(String command) { if (StringUtils.isBlank(command)) { logger.warn("Trying to send empty command"); return; } try { String url = cmdUrl + URLEncoder.encode(command, Charset.defaultCharset().displayName()); logger.trace("Calling url {}", url); client.prepareGet(url) .execute(new AsyncCompletionHandler<Response>() { @Override public Response onCompleted(Response response) throws Exception { if (response.getStatusCode() != 200) { logger.error("Error while sending command", response.getStatusText()); } return response; } @Override public void onThrowable(Throwable t) { logger.error("Error sending command", t); } }); } catch (UnsupportedEncodingException e) { logger.error("Error preparing command", e); } catch (IOException e) { logger.error("Error sending command", e); e.printStackTrace(); } }

Target:
private void internalSendCommand(String command) { if (StringUtils.isBlank(command)) { logger.warn("Trying to send empty command"); return; } try { String url = cmdUrl + URLEncoder.encode(command, Charset.defaultCharset().displayName()); logger.trace("Calling url {}", url); client.prepareGet(url) .execute(new AsyncCompletionHandler<Response>() { @Override public Response onCompleted(Response response) throws Exception { if (response.getStatusCode() != 200) { logger.warn("Error while sending command", response.getStatusText()); } return response; } @Override public void onThrowable(Throwable t) { logger.warn("Error sending command", t); } }); } catch (UnsupportedEncodingException e) { logger.warn("Error preparing command", e); } catch (IOException e) { logger.warn("Error sending command", e); } }
Source:
public static List<Object> map(Attribute attr) { List<Object> row = new ArrayList<>(); for (Entry<String, String> entry : ATTRIBUTE_ATTRS.entrySet()) { switch (entry.getKey()) { case EMX_ATTRIBUTES_ID_ATTRIBUTE: row.add(getIdAttrValue(attr)); break; case EMX_ATTRIBUTES_TAGS: row.add(getTagsValue(attr)); break; case EMX_ATTRIBUTES_ENTITY: row.add(attr.getEntity() != null ? attr.getEntity().getId() : ""); break; case EMX_ATTRIBUTES_REF_ENTITY: row.add(attr.getRefEntity() != null ? attr.getRefEntity().getId() : ""); break; case EMX_ATTRIBUTES_LOOKUP_ATTRIBUTE: row.add(getLookupValue(attr)); break; case EMX_ATTRIBUTES_NILLABLE: row.add(getNullableValue(attr)); break; case EMX_ATTRIBUTES_VISIBLE: row.add(getVisibleValue(attr)); break; case EMX_ATTRIBUTES_PART_OF_ATTRIBUTE: row.add(getPartOfValue(attr)); break; case EMX_ATTRIBUTES_MAPPED_BY: row.add(getMappedByValue(attr)); break; case EMX_ATTRIBUTES_ENUM_OPTIONS: row.add(getEnumOptions(attr)); break; default: Object value = attr.get(entry.getValue()); row.add(value != null ? value.toString() : ""); } } return row; }

Target:
public static List<Object> map(Attribute attr) { List<Object> row = new ArrayList<>(ATTRIBUTE_ATTRS.size()); for (Entry<String, String> entry : ATTRIBUTE_ATTRS.entrySet()) { switch (entry.getKey()) { case EMX_ATTRIBUTES_ID_ATTRIBUTE: row.add(getIdAttrValue(attr)); break; case EMX_ATTRIBUTES_TAGS: row.add(getTagsValue(attr)); break; case EMX_ATTRIBUTES_ENTITY: row.add(attr.getEntity() != null ? attr.getEntity().getId() : null); break; case EMX_ATTRIBUTES_REF_ENTITY: row.add(attr.getRefEntity() != null ? attr.getRefEntity().getId() : null); break; case EMX_ATTRIBUTES_LOOKUP_ATTRIBUTE: row.add(getLookupValue(attr)); break; case EMX_ATTRIBUTES_NILLABLE: row.add(getNullableValue(attr)); break; case EMX_ATTRIBUTES_VISIBLE: row.add(getVisibleValue(attr)); break; case EMX_ATTRIBUTES_PART_OF_ATTRIBUTE: row.add(getPartOfValue(attr)); break; case EMX_ATTRIBUTES_MAPPED_BY: row.add(getMappedByValue(attr)); break; case EMX_ATTRIBUTES_ENUM_OPTIONS: row.add(getEnumOptions(attr)); break; default: Object value = attr.get(entry.getValue()); row.add(value != null ? value.toString() : null); } } return row; }
Source:
public static void main(String[] args) { try { if (args.length < 1) { usage(); System.exit(-1); } int numBookies = 0; try { numBookies = Integer.parseInt(args[0]); } catch (NumberFormatException nfe) { LOG.error("Unrecognized number-of-bookies: " + args[0]); usage(); System.exit(-1); } ServerConfiguration conf = new ServerConfiguration(); conf.setAllowLoopback(true); if (args.length >= 2) { String confFile = args[1]; try { conf.loadConf(new File(confFile).toURI().toURL()); LOG.info("Using configuration file " + confFile); } catch (Exception e) { LOG.warn("Error loading configuration file " + confFile, e); } } String zkDataDir = null; if (args.length >= 3) { zkDataDir = args[2]; } String localBookiesConfigDirName = defaultLocalBookiesConfigDir; if (args.length >= 4) { localBookiesConfigDirName = args[3]; } startLocalBookiesInternal(conf, zooKeeperDefaultHost, zooKeeperDefaultPort, numBookies, true, bookieDefaultInitialPort, false, "test", zkDataDir, localBookiesConfigDirName); } catch (Exception e) { LOG.error("Exiting LocalBookKeeper because of exception in main method", e); e.printStackTrace(); System.exit(-1); } }

Target:
public static void main(String[] args) { try { if (args.length < 1) { usage(); System.exit(-1); } int numBookies = 0; try { numBookies = Integer.parseInt(args[0]); } catch (NumberFormatException nfe) { LOG.error("Unrecognized number-of-bookies: {}", args[0]); usage(); System.exit(-1); } ServerConfiguration conf = new ServerConfiguration(); conf.setAllowLoopback(true); if (args.length >= 2) { String confFile = args[1]; try { conf.loadConf(new File(confFile).toURI().toURL()); LOG.info("Using configuration file " + confFile); } catch (Exception e) { LOG.warn("Error loading configuration file " + confFile, e); } } String zkDataDir = null; if (args.length >= 3) { zkDataDir = args[2]; } String localBookiesConfigDirName = defaultLocalBookiesConfigDir; if (args.length >= 4) { localBookiesConfigDirName = args[3]; } startLocalBookiesInternal(conf, zooKeeperDefaultHost, zooKeeperDefaultPort, numBookies, true, bookieDefaultInitialPort, false, "test", zkDataDir, localBookiesConfigDirName); } catch (Exception e) { LOG.error("Exiting LocalBookKeeper because of exception in main method", e); e.printStackTrace(); System.exit(-1); } }
Source:
WebsocketSession(ClientCodec<ByteBuf> codec, Connection connection) { this.id = Integer.toHexString(System.identityHashCode(this)); this.codec = codec; this.connection = connection; this.outbound = (WebsocketOutbound) connection.outbound(); DirectProcessor<ByteBuf> outboundProcessor = DirectProcessor.create(); outboundSink = outboundProcessor.sink(); this.outbound .options(SendOptions::flushOnEach) .sendObject(outboundProcessor.map(TextWebSocketFrame::new)) .then() .subscribe( null, th -> LOGGER.error("Exception on sending for session={}, cause: {}", id, th)); WebsocketInbound inbound = (WebsocketInbound) connection.inbound(); inbound .aggregateFrames() .receive() .retain() .subscribe( byteBuf -> { ClientMessage msg; try { msg = codec.decode(byteBuf); } catch (Exception ex) { LOGGER.error("Response decoder failed: " + ex); return; } if (!msg.hasHeader(STREAM_ID)) { LOGGER.error("Ignore response: with null sid, session={}", msg, id); Optional.ofNullable(msg.data()).ifPresent(ReferenceCountUtil::safestRelease); return; } long sid = Long.valueOf(msg.header(STREAM_ID)); UnicastProcessor<ClientMessage> processor = inboundProcessors.get(sid); if (processor == null) { LOGGER.error( "Can't find processor by sid={} for response: {}, session={}", sid, msg, id); Optional.ofNullable(msg.data()).ifPresent(ReferenceCountUtil::safestRelease); return; } handleResponse(msg, processor::onNext, processor::onError, processor::onComplete); }); }

Target:
WebsocketSession(ClientCodec<ByteBuf> codec, Connection connection) { this.id = Integer.toHexString(System.identityHashCode(this)); this.codec = codec; this.connection = connection; this.outbound = (WebsocketOutbound) connection.outbound(); UnicastProcessor<ByteBuf> outboundProcessor = UnicastProcessor.create(); outboundSink = outboundProcessor.sink(); this.outbound .options(SendOptions::flushOnEach) .sendObject(outboundProcessor.onBackpressureBuffer().map(TextWebSocketFrame::new)) .then() .subscribe( null, th -> LOGGER.error("Exception on sending for session={}, cause: {}", id, th)); WebsocketInbound inbound = (WebsocketInbound) connection.inbound(); inbound .aggregateFrames() .receive() .retain() .subscribe( byteBuf -> { ClientMessage msg; try { msg = codec.decode(byteBuf); } catch (Exception ex) { LOGGER.error("Response decoder failed: " + ex); return; } if (!msg.hasHeader(STREAM_ID)) { LOGGER.error("Ignore response: with null sid, session={}", msg, id); Optional.ofNullable(msg.data()).ifPresent(ReferenceCountUtil::safestRelease); return; } long sid = Long.valueOf(msg.header(STREAM_ID)); UnicastProcessor<ClientMessage> processor = inboundProcessors.get(sid); if (processor == null) { LOGGER.error( "Can't find processor by sid={} for response: {}, session={}", sid, msg, id); Optional.ofNullable(msg.data()).ifPresent(ReferenceCountUtil::safestRelease); return; } handleResponse(msg, processor::onNext, processor::onError, processor::onComplete); }); }
Source:
public void parse_shouldReturnAnMrrtTemplateObjectIfFileIsValid() throws Exception { File file = new File(getClass().getClassLoader() .getResource("mrrttemplates/radreport/ValidTemplate1.html") .getFile()); FileInputStream in = new FileInputStream(file); MrrtReportTemplate template = parser.parse(in); assertNotNull(template); assertThat(template.getCharset(), is(CHARSET)); assertThat(template.getDcTermsTitle(), is(TEST_DCTERMS_TITLE)); assertThat(template.getDcTermsDescription(), is(TEST_DCTERMS_DESCRIPTION)); assertThat(template.getDcTermsIdentifier(), is(TEST_DCTERMS_IDENTIFIER)); assertThat(template.getDcTermsLanguage(), is(TEST_DCTERMS_LANGUAGE)); assertThat(template.getDcTermsLanguage(), is(TEST_DCTERMS_LANGUAGE)); assertThat(template.getDcTermsType(), is(TEST_DCTERMS_TYPE)); assertThat(template.getDcTermsPublisher(), is(TEST_DCTERMS_PUBLISHER)); assertThat(template.getDcTermsRights(), is(TEST_DCTERMS_RIGHTS)); assertThat(template.getDcTermsLicense(), is(TEST_DCTERMS_LICENSE)); assertThat(template.getDcTermsDate(), is(TEST_DCTERMS_DATE)); assertThat(template.getDcTermsCreator(), is(TEST_DCTERMS_CREATOR)); }

Target:
public void parse_shouldReturnAnMrrtTemplateObjectIfFileIsValid() throws Exception { File file = new File(getClass().getClassLoader() .getResource("mrrttemplates/ihe/connectathon/2015/CTChestAbdomen.html") .getFile()); FileInputStream in = new FileInputStream(file); MrrtReportTemplate template = parser.parse(in); assertNotNull(template); assertThat(template.getCharset(), is(CHARSET)); assertThat(template.getDcTermsTitle(), is(TEST_DCTERMS_TITLE)); assertThat(template.getDcTermsDescription(), is(TEST_DCTERMS_DESCRIPTION)); assertThat(template.getDcTermsIdentifier(), is(TEST_DCTERMS_IDENTIFIER)); assertThat(template.getDcTermsLanguage(), is(TEST_DCTERMS_LANGUAGE)); assertThat(template.getDcTermsLanguage(), is(TEST_DCTERMS_LANGUAGE)); assertThat(template.getDcTermsType(), is(TEST_DCTERMS_TYPE)); assertThat(template.getDcTermsPublisher(), is(TEST_DCTERMS_PUBLISHER)); assertThat(template.getDcTermsRights(), is(TEST_DCTERMS_RIGHTS)); assertThat(template.getDcTermsLicense(), is(TEST_DCTERMS_LICENSE)); assertThat(template.getDcTermsDate(), is(TEST_DCTERMS_DATE)); assertThat(template.getDcTermsCreator(), is(TEST_DCTERMS_CREATOR)); }
Source:
public List<Event> execute(final LnClientConnection conn, final FindEventsQuery findEventsQuery) throws IOException, ProtocolAdapterException, TimeoutException { List<Event> eventList = new ArrayList<>(); final AttributeAddress configurationObjectValue = new AttributeAddress(CLASS_ID, EVENT_LOG_CATEGORY_OBISCODE_MAP.get(findEventsQuery.getEventLogCategory()), ATTRIBUTE_ID); final List<GetResult> getResultList = conn.get(configurationObjectValue); if (getResultList.isEmpty()) { throw new ProtocolAdapterException("No GetResult received while retrieving event register " + findEventsQuery.getEventLogCategory()); } if (getResultList.size() > 1) { throw new ProtocolAdapterException("Expected 1 GetResult while retrieving event log for " + findEventsQuery.getEventLogCategory() + ". Got " + getResultList.size()); } final GetResult result = getResultList.get(0); if (!AccessResultCode.SUCCESS.equals(result.resultCode())) { LOGGER.info("Result of getting events for is {}", findEventsQuery.getEventLogCategory(), result.resultCode()); return eventList; } final DataObject resultData = result.resultData(); eventList = this.dataObjectToEventListConverter.convert(resultData); return this.filterEventList(eventList, findEventsQuery); }

Target:
public List<Event> execute(final LnClientConnection conn, final FindEventsQuery findEventsQuery) throws IOException, ProtocolAdapterException, TimeoutException { final SelectiveAccessDescription selectiveAccessDescription = this.getSelectiveAccessDescription( findEventsQuery.getFrom(), findEventsQuery.getUntil()); final AttributeAddress configurationObjectValue = new AttributeAddress(CLASS_ID, EVENT_LOG_CATEGORY_OBISCODE_MAP.get(findEventsQuery.getEventLogCategory()), ATTRIBUTE_ID, selectiveAccessDescription); final List<GetResult> getResultList = conn.get(configurationObjectValue); if (getResultList.isEmpty()) { throw new ProtocolAdapterException("No GetResult received while retrieving event register " + findEventsQuery.getEventLogCategory()); } if (getResultList.size() > 1) { throw new ProtocolAdapterException("Expected 1 GetResult while retrieving event log for " + findEventsQuery.getEventLogCategory() + ". Got " + getResultList.size()); } final GetResult result = getResultList.get(0); if (!AccessResultCode.SUCCESS.equals(result.resultCode())) { LOGGER.info("Result of getting events for is {}", findEventsQuery.getEventLogCategory(), result.resultCode()); throw new ProtocolAdapterException("Getting the events for " + findEventsQuery.getEventLogCategory() + " from the meter resulted in" + result.resultCode()); } final DataObject resultData = result.resultData(); return this.dataObjectToEventListConverter.convert(resultData); }
Source:
public RecordCursor cursor(ConnectorTransactionHandle transactionHandle, ConnectorSession session, TupleDomain<Integer> constraint) { Builder table = InMemoryRecordSet.builder(QUERY_TABLE); List<QueryInfo> allQueryInfo = queryManager.getAllQueryInfo().stream() .map(BasicQueryInfo::getQueryId) .map(queryId -> { try { return queryManager.getFullQueryInfo(queryId); } catch (NoSuchElementException e) { return null; } }) .filter(Objects::nonNull) .collect(toImmutableList()); for (QueryInfo queryInfo : allQueryInfo) { QueryStats queryStats = queryInfo.getQueryStats(); table.addRow( nodeId, queryInfo.getQueryId().toString(), queryInfo.getState().toString(), queryInfo.getSession().getUser(), queryInfo.getSession().getSource().orElse(null), queryInfo.getQuery(), queryInfo.getResourceGroupId().map(QuerySystemTable::resourceGroupIdToBlock).orElse(null), toMillis(queryStats.getQueuedTime()), toMillis(queryStats.getAnalysisTime()), toMillis(queryStats.getDistributedPlanningTime()), toTimeStamp(queryStats.getCreateTime()), toTimeStamp(queryStats.getExecutionStartTime()), toTimeStamp(queryStats.getLastHeartbeat()), toTimeStamp(queryStats.getEndTime())); } return table.build().cursor(); }

Target:
public RecordCursor cursor(ConnectorTransactionHandle transactionHandle, ConnectorSession session, TupleDomain<Integer> constraint) { Builder table = InMemoryRecordSet.builder(QUERY_TABLE); List<QueryInfo> queryInfos = queryManager.getQueries().stream() .map(BasicQueryInfo::getQueryId) .map(queryId -> { try { return queryManager.getFullQueryInfo(queryId); } catch (NoSuchElementException e) { return null; } }) .filter(Objects::nonNull) .collect(toImmutableList()); for (QueryInfo queryInfo : queryInfos) { QueryStats queryStats = queryInfo.getQueryStats(); table.addRow( nodeId, queryInfo.getQueryId().toString(), queryInfo.getState().toString(), queryInfo.getSession().getUser(), queryInfo.getSession().getSource().orElse(null), queryInfo.getQuery(), queryInfo.getResourceGroupId().map(QuerySystemTable::resourceGroupIdToBlock).orElse(null), toMillis(queryStats.getQueuedTime()), toMillis(queryStats.getAnalysisTime()), toMillis(queryStats.getDistributedPlanningTime()), toTimeStamp(queryStats.getCreateTime()), toTimeStamp(queryStats.getExecutionStartTime()), toTimeStamp(queryStats.getLastHeartbeat()), toTimeStamp(queryStats.getEndTime())); } return table.build().cursor(); }
Source:
public List<Node> getNodesInTopologicalOrder() { List<Node> topologicalList = new ArrayList<>(); List<Node> nodesToExamine = new ArrayList<>(); nodesToExamine.add(findNode(new SimpleUri("engine:shadowMapClearingNode"))); while (!nodesToExamine.isEmpty()) { Node currentNode = nodesToExamine.get(0); topologicalList.add(currentNode); nodesToExamine.addAll(nodeEdges.get(currentNode)); nodesToExamine.remove(0); } return topologicalList; }

Target:
public List<Node> getNodesInTopologicalOrder() { List<Node> topologicalList = new ArrayList<>(); Map<Node, Integer> inDegreeMap = Maps.newHashMap(); List<Node> nodesToExamine = Lists.newArrayList(); int visitedNodes = 0; for (Entry<Node, Collection<Node>> nodeEdgeList : reverseEdgeMap.asMap().entrySet()) { inDegreeMap.put(nodeEdgeList.getKey(), nodeEdgeList.getValue().size()); } for (Node node : nodeMap.values()) { if (!inDegreeMap.containsKey(node)) { inDegreeMap.put(node, 0); nodesToExamine.add(node); } } while (!nodesToExamine.isEmpty()) { Node currentNode = nodesToExamine.remove(0); for (Node adjacentNode : edgeMap.get(currentNode)) { int updatedInDegree = inDegreeMap.get(adjacentNode) - 1; inDegreeMap.put(adjacentNode, updatedInDegree); if (updatedInDegree == 0) { nodesToExamine.add(adjacentNode); } } topologicalList.add(currentNode); visitedNodes++; } if (visitedNodes != nodeMap.size()) { throw new RuntimeException("Cycle detected in the DAG: topological sorting not possible!"); } return topologicalList; }
Source:
private static void checkAssertion(SamlAssertionWrapper assertion, String confirmMethod) throws WSSecurityException { if (OpenSAMLUtil.isMethodHolderOfKey(confirmMethod)) { if (assertion.getSubjectKeyInfo() == null) { LOG.debug("There is no Subject KeyInfo to match the holder-of-key subject conf method"); throw new WSSecurityException(ErrorCode.FAILED_CHECK, "noKeyInSAMLToken"); } if (!assertion.isSigned()) { LOG.debug("A holder-of-key assertion must be signed"); throw new WSSecurityException(ErrorCode.FAILED_CHECK, "invalidSAMLsecurity"); } } }

Target:
private static void checkAssertion(SamlAssertionWrapper assertion, String confirmMethod) throws WSSecurityException { if (OpenSAMLUtil.isMethodHolderOfKey(confirmMethod)) { if (assertion.getSubjectKeyInfo() == null) { LOG.info("There is no Subject KeyInfo to match the holder-of-key subject conf method"); throw new WSSecurityException(ErrorCode.FAILED_CHECK, "noKeyInSAMLToken"); } if (!assertion.isSigned()) { LOG.info("A holder-of-key assertion must be signed"); throw new WSSecurityException(ErrorCode.FAILED_CHECK, "invalidSAMLsecurity"); } } }
Source:
private String resolveMessage(String message, Map<String, LinkedList<String>> variables) { String returnValue = message; RegExp regex = RegExp.compile(VARIABLE_PATTERN, "gi"); MatchResult result; while (returnValue.length() > 0) { result = regex.exec(returnValue); if (result == null) { break; } String match = result.getGroup(0); String key = match.substring(2, match.length() - 1); if (variables.containsKey(key)) { LinkedList<String> values = variables.get(key); String value = values.size() == 1 ? values.getFirst() : values.size() > 1 ? values.removeFirst() : ""; returnValue = returnValue.replace(match, value); } regex.setLastIndex(0); } return returnValue; }

Target:
private String resolveMessage(String message, Map<String, LinkedList<String>> variables) { String returnValue = message; RegExp regex = RegExp.compile(VARIABLE_PATTERN, "gi"); MatchResult result; while (returnValue.length() > 0) { result = regex.exec(returnValue); if (result == null) { break; } String match = result.getGroup(0); String key = match.substring(2, match.length() - 1); if (variables.containsKey(key)) { LinkedList<String> values = variables.get(key); String value = values.size() == 1 ? values.getFirst() : values.size() > 1 ? values.removeFirst() : ""; returnValue = returnValue.replace(match, value); } else { break; } regex.setLastIndex(0); } return returnValue; }
Source:
public MoveRepresentationAction(Session session, final DAnalysis targetAnalysis, Collection<DRepresentation> selection) { super(); this.targetAnalysis = targetAnalysis; this.session = session; this.representations = Collections2.filter(selection, new Predicate<DRepresentation>() { @Override public boolean apply(DRepresentation input) { boolean result = true; EObject container = input.eContainer(); if (container instanceof DRepresentationContainer) { IPermissionAuthority permissionAuthority = PermissionAuthorityRegistry.getDefault().getPermissionAuthority(container); if (permissionAuthority != null && !permissionAuthority.canCreateIn(container)) { result = false; } } if (result) { DRepresentationContainer targetContainer = DAnalysisSessionHelper.findContainerForAddedRepresentation(targetAnalysis, input); if (targetContainer != null) { IPermissionAuthority permissionAuthority = PermissionAuthorityRegistry.getDefault().getPermissionAuthority(targetContainer); if (permissionAuthority != null && !permissionAuthority.canCreateIn(targetContainer)) { result = false; } } } return result; } }); final ImageDescriptor descriptor = AbstractUIPlugin.imageDescriptorFromPlugin(SiriusEditPlugin.ID, "/icons/full/others/forward.gif"); this.setImageDescriptor(descriptor); this.setText("move to " + targetAnalysis.eResource().getURI().toString()); if (this.representations.isEmpty()) { this.setEnabled(false); } }

Target:
public MoveRepresentationAction(Session session, final DAnalysis targetAnalysis, Collection<DRepresentation> selection) { super(); this.targetAnalysis = targetAnalysis; this.session = session; this.representations = Collections2.filter(selection, new Predicate<DRepresentation>() { @Override public boolean apply(DRepresentation input) { boolean result = true; EObject container = input.eContainer(); if (container instanceof DRepresentationContainer) { IPermissionAuthority permissionAuthority = PermissionAuthorityRegistry.getDefault().getPermissionAuthority(container); if (permissionAuthority != null && !permissionAuthority.canDeleteInstance(container)) { result = false; } } if (result) { DRepresentationContainer targetContainer = DAnalysisSessionHelper.findContainerForAddedRepresentation(targetAnalysis, input); if (targetContainer != null) { IPermissionAuthority permissionAuthority = PermissionAuthorityRegistry.getDefault().getPermissionAuthority(targetContainer); if (permissionAuthority != null && !permissionAuthority.canCreateIn(targetContainer)) { result = false; } } } return result; } }); final ImageDescriptor descriptor = AbstractUIPlugin.imageDescriptorFromPlugin(SiriusEditPlugin.ID, "/icons/full/others/forward.gif"); this.setImageDescriptor(descriptor); this.setText("move to " + targetAnalysis.eResource().getURI().toString()); if (this.representations.isEmpty()) { this.setEnabled(false); } }
Source:
private static Set<String> getClusterEmulatedMachines(VDSGroup cluster) { if (cluster.getEmulatedMachine() != null) { return new HashSet<>(Arrays.asList(cluster.getEmulatedMachine().split(","))); } else { return new HashSet<>(); } }

Target:
private static Set<String> getClusterEmulatedMachines(VDSGroup cluster) { if (cluster.getEmulatedMachine() == null) { return new HashSet<>(); } else { return new HashSet<>(Arrays.asList(cluster.getEmulatedMachine().split(","))); } }
Source:
protected void installLocations() { super.installLocations(); bind(RegionIdToURISupplier.class).to(RegionsToApiEndpoints.class).in(Scopes.SINGLETON); bind(ZoneIdsSupplier.class).to(ZoneIdsFromRegionIdToZoneIdsValues.class).in(Scopes.SINGLETON); bind(RegionIdsSupplier.class).to(RegionIdsFromRegionIdToURIKeySet.class).in(Scopes.SINGLETON); bind(ZoneIdToURISupplier.class).to(ZoneIdToURIFromJoinOnRegionIdToURI.class).in(Scopes.SINGLETON); bind(ImplicitLocationSupplier.class).to(OnlyLocationOrFirstZone.class).in(Scopes.SINGLETON); }

Target:
protected void installLocations() { super.installLocations(); bind(RegionIdToURISupplier.class).to(RegionsToApiEndpoints.class).in(Scopes.SINGLETON); bind(ZoneIdsSupplier.class).to(ZoneIdsFromRegionIdToZoneIdsValues.class).in(Scopes.SINGLETON); bind(ZoneIdToURISupplier.class).to(ZoneIdToURIFromJoinOnRegionIdToURI.class).in(Scopes.SINGLETON); bind(ImplicitLocationSupplier.class).to(OnlyLocationOrFirstZone.class).in(Scopes.SINGLETON); }
Source:
private void insertUserIntoGroup(final String authId, final String groupId, final Authentication.AuthResponse.PermissionLevel permissionLevel) throws AuthenticationException, DatabaseAccessException { final DBCollection collection = database.getCollection(DatabaseStringConstants.USER_GROUP_COLLECTION); final DBObject group = collection.findOne(new ObjectId(groupId), new BasicDBObject(DatabaseStringConstants.SALT, true)); if (group == null) { throw new DatabaseAccessException("group could not be found"); } final String salt = group.get(DatabaseStringConstants.SALT).toString(); String hash = null; try { hash = HashManager.toHex(HashManager.createHash(authId, salt).getBytes(StandardCharsets.UTF_8)); } catch (NoSuchAlgorithmException e) { throw new AuthenticationException(e); } if (hash == null) { throw new AuthenticationException("Unable to create authentication hash for group " + groupId, AuthenticationException.OTHER); } final BasicDBObject update = new BasicDBObject(hash, permissionLevel.getNumber()); database.getCollection(DatabaseStringConstants.USER_GROUP_COLLECTION).update( group, new BasicDBObject(DatabaseStringConstants.SET_COMMAND, update)); }

Target:
private void insertUserIntoGroup(final String authId, final String groupId, final Authentication.AuthResponse.PermissionLevel permissionLevel) throws AuthenticationException, DatabaseAccessException { final DBCollection collection = database.getCollection(DatabaseStringConstants.USER_GROUP_COLLECTION); final DBObject group = collection.findOne(new ObjectId(groupId), new BasicDBObject(DatabaseStringConstants.SALT, true)); if (group == null) { throw new DatabaseAccessException("Group with id " + groupId + " could not be found."); } final String salt = group.get(DatabaseStringConstants.SALT).toString(); String hash = null; try { hash = HashManager.toHex(HashManager.createHash(authId, salt).getBytes(StandardCharsets.UTF_8)); } catch (NoSuchAlgorithmException e) { throw new AuthenticationException(e); } if (hash == null) { throw new AuthenticationException("Unable to create authentication hash for group " + groupId, AuthenticationException.OTHER); } final BasicDBObject update = new BasicDBObject(hash, permissionLevel.getNumber()); database.getCollection(DatabaseStringConstants.USER_GROUP_COLLECTION).update( group, new BasicDBObject(DatabaseStringConstants.SET_COMMAND, update)); }
Source:
protected void eventHandle(ITmfEvent event) { if (!considerEvent(event)) { return; } try { String functionEntryName = functionEntry(event); if (functionEntryName != null) { long timestamp = event.getTimestamp().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue(); String thread = getThreadName(event); int quark = ss.getQuarkAbsoluteAndAdd(THREADS, thread, CALL_STACK); ITmfStateValue value = TmfStateValue.newValueString(functionEntryName); ss.pushAttribute(timestamp, value, quark); return; } String functionExitName = functionExit(event); if (functionExitName != null) { long timestamp = event.getTimestamp().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue(); String thread = getThreadName(event); int quark = ss.getQuarkAbsoluteAndAdd(THREADS, thread, CALL_STACK); ITmfStateValue poppedValue = ss.popAttribute(timestamp, quark); if (!functionExitName.equals(UNDEFINED) && !functionExitName.equals(poppedValue.unboxStr())) { Activator.logWarning(Messages.CallStackStateProvider_UmatchedPoppedValue); } } } catch (TimeRangeException e) { e.printStackTrace(); } catch (AttributeNotFoundException e) { e.printStackTrace(); } catch (StateValueTypeException e) { e.printStackTrace(); } }

Target:
protected void eventHandle(ITmfEvent event) { if (!considerEvent(event)) { return; } try { String functionEntryName = functionEntry(event); if (functionEntryName != null) { long timestamp = event.getTimestamp().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue(); String thread = getThreadName(event); int quark = ss.getQuarkAbsoluteAndAdd(THREADS, thread, CALL_STACK); ITmfStateValue value = TmfStateValue.newValueString(functionEntryName); ss.pushAttribute(timestamp, value, quark); return; } String functionExitName = functionExit(event); if (functionExitName != null) { long timestamp = event.getTimestamp().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue(); String thread = getThreadName(event); int quark = ss.getQuarkAbsoluteAndAdd(THREADS, thread, CALL_STACK); ITmfStateValue poppedValue = ss.popAttribute(timestamp, quark); String poppedName = (poppedValue == null ? NO_FUNCTION : poppedValue.unboxStr()); if (!functionExitName.equals(UNDEFINED) && !functionExitName.equals(poppedName)) { Activator.logWarning(NLS.bind( Messages.CallStackStateProvider_UnmatchedPoppedValue, functionExitName, poppedName)); } } } catch (TimeRangeException e) { e.printStackTrace(); } catch (AttributeNotFoundException e) { e.printStackTrace(); } catch (StateValueTypeException e) { e.printStackTrace(); } }
Source:
private static Connection getDBConnection() { Connection dbConnection = null; try { Class.forName(DB_DRIVER); } catch (ClassNotFoundException e) { LOG.error("Driver not found", e); } try { dbConnection = DriverManager.getConnection(DB_CONNECTION, DB_USER, DB_PASSWORD); return dbConnection; } catch (SQLException e) { LOG.error("Exception in getting connection handle", e); } return dbConnection; }

Target:
private static Connection getDBConnection() { Connection dbConnection = null; try { Class.forName(DB_DRIVER); } catch (ClassNotFoundException e) { LOG.error("Driver not found", e); throw new RuntimeException(e); } try { dbConnection = DriverManager.getConnection(DB_CONNECTION, DB_USER, DB_PASSWORD); return dbConnection; } catch (SQLException e) { LOG.error("Exception in getting connection handle", e); throw new RuntimeException(e); } }
Source:
public FactoryDto createFactory(@NotNull final Map<String, String> factoryParameters) throws BadRequestException, ServerException { final GithubUrl githubUrl = githubUrlParser.parse(factoryParameters.remove(URL_PARAMETER_NAME)); FactoryDto factory = urlFactoryBuilder .createFactoryFromDevfile( githubUrl, fileName -> urlFetcher.fetch(githubUrl.rawFileLocation(fileName)), factoryParameters) .orElseGet( () -> urlFactoryBuilder .createFactoryFromJson(githubUrl) .orElseGet( () -> newDto(FactoryDto.class) .withV(CURRENT_VERSION) .withSource("repo"))); if (factory.getWorkspace() != null) { return projectConfigDtoMerger.merge( factory, () -> { return newDto(ProjectConfigDto.class) .withSource(githubSourceStorageBuilder.buildWorkspaceConfigSource(githubUrl)) .withName(githubUrl.getRepository()) .withPath("/".concat(githubUrl.getRepository())); }); } else if (factory.getDevfile() == null) { factory.setDevfile(urlFactoryBuilder.buildDefaultDevfile(githubUrl.getRepository())); factory .getDevfile() .setProjects( Collections.singletonList( newDto(ProjectDto.class) .withSource(githubSourceStorageBuilder.buildDevfileSource(githubUrl)) .withName(githubUrl.getRepository()))); } return factory; }

Target:
public FactoryDto createFactory(@NotNull final Map<String, String> factoryParameters) throws BadRequestException, ServerException { final GithubUrl githubUrl = githubUrlParser.parse(factoryParameters.get(URL_PARAMETER_NAME)); FactoryDto factory = urlFactoryBuilder .createFactoryFromDevfile( githubUrl, fileName -> urlFetcher.fetch(githubUrl.rawFileLocation(fileName)), extractOverrideParams(factoryParameters)) .orElseGet( () -> urlFactoryBuilder .createFactoryFromJson(githubUrl) .orElseGet( () -> newDto(FactoryDto.class) .withV(CURRENT_VERSION) .withSource("repo"))); if (factory.getWorkspace() != null) { return projectConfigDtoMerger.merge( factory, () -> { return newDto(ProjectConfigDto.class) .withSource(githubSourceStorageBuilder.buildWorkspaceConfigSource(githubUrl)) .withName(githubUrl.getRepository()) .withPath("/".concat(githubUrl.getRepository())); }); } else if (factory.getDevfile() == null) { factory.setDevfile(urlFactoryBuilder.buildDefaultDevfile(githubUrl.getRepository())); factory .getDevfile() .setProjects( Collections.singletonList( newDto(ProjectDto.class) .withSource(githubSourceStorageBuilder.buildDevfileSource(githubUrl)) .withName(githubUrl.getRepository()))); } return factory; }