auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
public void write(byte b) { try { m_out.write(b); } catch (IOException e) { while (!reconnect()) { try { Thread.sleep(10000); } catch (InterruptedException ie) { } } } }

Target:
public void write(byte b) { try { m_out.write(b); } catch (IOException e) { logger.trace("got exception while writing: {}", e.getMessage()); while (!reconnect()) { try { logger.trace("sleeping before reconnecting"); Thread.sleep(10000); } catch (InterruptedException ie) { logger.warn("interrupted while sleeping on write reconnect"); } } } }
Source:
public final Disposable subscribe(final Action onComplete) { ObjectHelper.requireNonNull(onComplete, "onComplete is null"); return subscribe(onComplete, Functions.ON_ERROR_MISSING); }

Target:
public final Disposable subscribe(final Action onComplete) { return subscribe(onComplete, Functions.ON_ERROR_MISSING); }
Source:
protected Element getUpdatedReferenceDataSubSection(final DocumentBuilder documentBuilder) { final Resource resource = getWizardContext().getTenantContext().getConfigurationFile().toResource(); final DomConfigurationWriter writer = new DomConfigurationWriter(resource); final Element stringPatternsElement = writer.getStringPatternsElement(); final StringPattern stringPattern = new SimpleStringPattern(_name, _expression); stringPatternsElement.appendChild(writer.externalize(stringPattern)); return stringPatternsElement; }

Target:
protected Element getUpdatedReferenceDataSubSection(final DocumentBuilder documentBuilder) { final Element stringPatternsElement = _writer.getStringPatternsElement(); final StringPattern stringPattern = new SimpleStringPattern(_name, _expression); stringPatternsElement.appendChild(_writer.externalize(stringPattern)); return stringPatternsElement; }
Source:
public void warmup() throws Exception { CacheConfig<Integer, Long> config = new CacheConfig<Integer, Long>(); config.setName(basename); config.setTypes(Integer.class, Long.class); cacheManager.createCache(basename, config); ICache cache = cacheManager.getCache(basename, Integer.class, Long.class); for (int k = 0; k < keyCount; k++) { cache.put(k, 0l); } }

Target:
public void warmup() throws Exception { CacheConfig<Integer, Long> config = new CacheConfig<Integer, Long>(); config.setName(basename); config.setTypes(Integer.class, Long.class); cacheManager.createCache(basename, config); cache = cacheManager.getCache(basename, Integer.class, Long.class); for (int k = 0; k < keyCount; k++) { cache.put(k, 0l); } }
Source:
private List<ITmfEventAspect<?>> getAspectsFromColumnsId(List<Long> desiredColumns) { if (!desiredColumns.isEmpty()) { List<ITmfEventAspect<?>> aspects = new ArrayList<>(); for (Long columnsId : desiredColumns) { ITmfEventAspect<?> aspect = fAspectMap.get(columnsId); if (aspect != null) { aspects.add(aspect); } } return aspects; } return new ArrayList<>(fAspectMap.values()); }

Target:
private static Map<Long, ITmfEventAspect<?>> getAspectsFromColumnsId(List<Long> desiredColumns) { Map<Long, ITmfEventAspect<?>> aspects = new LinkedHashMap<>(); if (!desiredColumns.isEmpty()) { for (Long columnsId : desiredColumns) { ITmfEventAspect<?> aspect = fAspectMap.get(columnsId); if (aspect != null) { aspects.put(columnsId, aspect); } } return aspects; } return fAspectMap; }
Source:
public byte[] deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { String text = jp.getText(); if (text != null) { return BASE64.decode(text); } return new byte[0]; }

Target:
public byte[] deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { String text = jp.getText(); if (text != null) { return BASE64.decode(text); } return null; }
Source:
public View getView(int position, View convertView, ViewGroup parent) { TextView tv = (TextView) convertView; if (null == tv) { tv = new TextView(context, null); tv.setPadding(20, 30, 20, 30); tv.setCompoundDrawablePadding(10); tv.setTextAppearance(context, android.R.style.TextAppearance_DeviceDefault_Large); } DialogMenuItem menu = menus[position]; tv.setText(menu.text); tv.setTypeface(Settings.iconFont); if (menu.icon > 0) { tv.setCompoundDrawablesWithIntrinsicBounds(menu.icon, 0, 0, 0); } return tv; }

Target:
public View getView(int position, View convertView, ViewGroup parent) { TextView tv = (TextView) convertView; if (null == tv) { tv = new TextView(context, null); tv.setPadding(20, 30, 20, 30); tv.setCompoundDrawablePadding(10); tv.setTextAppearance(context, android.R.style.TextAppearance_DeviceDefault_Large); tv.setTypeface(Settings.iconFont); } DialogMenuItem menu = menus[position]; tv.setText(menu.text); if (menu.icon > 0) { tv.setCompoundDrawablesWithIntrinsicBounds(menu.icon, 0, 0, 0); } return tv; }
Source:
public void onDestroy() { super.onDestroy(); if (mLoadingDialog != null) { mLoadingDialog.dismiss(); mLoadingDialog = null; } mDisabledDialog = null; mIsDestroyed = true; }

Target:
public void onDestroy() { super.onDestroy(); if (mLoadingDialog != null) { mLoadingDialog.dismiss(); } mIsDestroyed = true; }
Source:
public void putTicket(ImageTicket ticket) { BasicHttpEntityEnclosingRequest request = (BasicHttpEntityEnclosingRequest) getRequest("PUT", TICKETS_URI + ticket.getId()); StringEntity entity = new StringEntity(ImageTicketHelper.toJson(ticket).toString(), StandardCharsets.UTF_8); request.setEntity(entity); request.setHeader("content-length", String.valueOf(request.getEntity().getContentLength())); HttpEntity response = sendRequest(request); consumeEntity(response); }

Target:
public void putTicket(ImageTicket ticket) { BasicHttpEntityEnclosingRequest request = (BasicHttpEntityEnclosingRequest) getRequest("PUT", TICKETS_URI + ticket.getId()); StringEntity entity = new StringEntity(ImageTicketHelper.toJson(ticket).toString(), StandardCharsets.UTF_8); request.setEntity(entity); request.setHeader("content-length", String.valueOf(request.getEntity().getContentLength())); HttpEntity response = executeRequest(request); consumeEntity(response); }
Source:
public void onPlayerWalks(final PlayerMoveEvent event) { if (event.getFrom().getY() > 255 || event.getFrom().getY() < 0 || event.getTo().getY() > 255 || event.getTo().getY() < 0) { return; } Location from = event.getFrom().getBlock().getLocation(); Location to = event.getTo().getBlock().getLocation(); if (from.equals(to)) { return; } if (!from.getWorld().getName().equalsIgnoreCase(to.getWorld().getName())) { return; } int maxRad = 50 * 50; for (final NPC npc: getAllNPCs()) { if (npc.isSpawned() && npc.getEntity().getType() == EntityType.PLAYER) { if (from.getWorld().getName().equalsIgnoreCase(npc.getEntity().getLocation().getWorld().getName()) && npc.getEntity().getLocation().distanceSquared(to) < maxRad && npc.getEntity().getLocation().distanceSquared(from) > maxRad) { showNPCReset(event.getPlayer(), npc); } } } }

Target:
public void onPlayerWalks(final PlayerMoveEvent event) { Location from = roundLocation(event.getFrom()); Location to = roundLocation(event.getTo()); if (from.equals(to)) { return; } if (from.getWorld() != to.getWorld()) { return; } int maxRad = 50 * 50; for (final NPC npc: getAllNPCs()) { if (npc.isSpawned() && npc.getEntity().getType() == EntityType.PLAYER) { if (from.getWorld().getName().equalsIgnoreCase(npc.getEntity().getLocation().getWorld().getName()) && npc.getEntity().getLocation().distanceSquared(to) < maxRad && npc.getEntity().getLocation().distanceSquared(from) > maxRad) { showNPCReset(event.getPlayer(), npc); } } } }
Source:
public static double argmax(final Function<Double, Double> function, final double min, final double max, final double guess) { final UnivariateObjectiveFunction objective = new UnivariateObjectiveFunction(x -> function.apply(x)); final SearchInterval interval= new SearchInterval(min, max, guess); return DEFAULT_OPTIMIZER.optimize(objective, GoalType.MAXIMIZE, interval, DEFAULT_MAX_EVAL).getPoint(); }

Target:
public static double argmax(final Function<Double, Double> function, final double min, final double max, final double guess) { final SearchInterval interval = new SearchInterval(min, max, guess); return DEFAULT_OPTIMIZER.optimize(new UnivariateObjectiveFunction(function::apply), GoalType.MAXIMIZE, interval, DEFAULT_MAX_EVAL).getPoint(); }
Source:
public <T extends Node> T getNode(String nodeNameSuffix) { String fullNodeName = params.getFullNodeName(nodeNameSuffix); Node node = nodes.get(fullNodeName); if (node == null) { throw new NodeException(String.format( "Node not found. Node name: %s, cluster: %s, cluster nodes: %s", fullNodeName, params.getName(), nodes.keySet()) ); } return ClassUtils.cast(node); }

Target:
public <T extends Node> T getNode(String nodeNameSuffix) { String fullNodeName = params.getFullNodeName(nodeNameSuffix); Optional<Node> node = Optional.ofNullable(nodes.get(fullNodeName)); if (!node.isPresent()) { throw new NodeException(String.format( "Node not found. Node name: %s, cluster: %s, cluster nodes: %s", fullNodeName, params.getName(), nodes.keySet()) ); } return ClassUtils.cast(node.get()); }
Source:
protected void inserted(Object[] elements, int index) { List<Object> kids = null; boolean changed = false; synchronized (this) { ModelNode[] childrenNodes = getRootNode().getChildrenNodes(); if (childrenNodes == null) { kids = new ArrayList<>(elements.length); } else { kids = new ArrayList<>(elements.length + childrenNodes.length); for (ModelNode childrenNode : childrenNodes) { kids.add(childrenNode.getElement()); } } for (Object element : elements) { if (!kids.contains(element)) { kids.add(index, element); index++; changed = true; } } } if (changed) { setChildren(getRootNode(), kids); } }

Target:
protected void inserted(Object[] elements, int index) { List<Object> kids = null; boolean changed = false; synchronized (this) { ModelNode[] childrenNodes = getRootNode().getChildrenNodes(); if (childrenNodes == null) { kids = new ArrayList<>(elements.length); } else { kids = new ArrayList<>(elements.length + childrenNodes.length); for (ModelNode childNode : childrenNodes) { kids.add(childNode.getElement()); } } for (Object element : elements) { if (!kids.contains(element)) { kids.add(index, element); index++; changed = true; } } } if (changed) { setChildren(getRootNode(), kids); } }
Source:
public List<Page> generateEmbeddingVectors(List<Page> pages, int batchThreshold) throws Exception { Map<String, Page> pageMap = pages.stream() .collect(Collectors.toMap(x -> x.getUri().toString(), x -> x)); Map<String, String> queries = new HashMap<>(); Map<String, Future<BatchSentenceVectorResponse>> futureMap = new ConcurrentHashMap<>(); int dimensions = this.getFastTextInfo().getDimensions(); double[] emptyVector = new double[dimensions]; String emptyEncodedVector = FastTextHelper.convertArrayToBase64(emptyVector); try (FastTextExecutorService executorService = new FastTextExecutorService()) { for (Page page : pages) { String pageSentence = page.getPageSentence(); if (null != pageSentence && !pageSentence.isEmpty() && page.getType() != PageType.timeseries) { queries.put(page.getUri().toString(), pageSentence); } else { page.setEncodedEmbeddingVector(emptyEncodedVector); } if (queries.size() == batchThreshold) { futureMap.putAll(this.submitVectorQueries(queries, executorService)); queries.clear(); } } } for (String requestId : futureMap.keySet()) { System.out.println(String.format("Processing request %s", requestId)); Future<BatchSentenceVectorResponse> future = futureMap.get(requestId); BatchSentenceVectorResponse response = future.get(); Map<String, SentenceVectorResponse> results = response.getResults(); for (String uri : results.keySet()) { SentenceVectorResponse sentenceVectorResponse = results.get(uri); String encodedVector = sentenceVectorResponse.getVector(); Map<String, Float> generatedKeywordsMap = sentenceVectorResponse.getKeywords(); List<String> generatedKeywords = generatedKeywordsMap.entrySet().stream() .filter(x -> x.getValue() >= 0.5f) .map(Map.Entry::getKey) .collect(Collectors.toList()); pageMap.get(uri).setEncodedEmbeddingVector(encodedVector); pageMap.get(uri).setGeneratedKeywords(generatedKeywords); } } return new ArrayList<>(pageMap.values()); }

Target:
public List<Page> generateEmbeddingVectors(List<Page> pages, int batchThreshold) throws Exception { Map<String, Page> pageMap = pages.stream() .collect(Collectors.toMap(x -> x.getUri().toString(), x -> x)); Map<String, Future<BatchSentenceVectorResponse>> futureMap = this.buildQueries(pages, batchThreshold); for (String requestId : futureMap.keySet()) { logDebug("Processing dp-fasttext request") .addParameter("context", requestId) .log(); Future<BatchSentenceVectorResponse> future = futureMap.get(requestId); BatchSentenceVectorResponse response = future.get(); Map<String, SentenceVectorResponse> results = response.getResults(); for (String uri : results.keySet()) { SentenceVectorResponse sentenceVectorResponse = results.get(uri); String encodedVector = sentenceVectorResponse.getVector(); Map<String, Float> generatedKeywordsMap = sentenceVectorResponse.getKeywords(); List<String> generatedKeywords = generatedKeywordsMap.entrySet().stream() .filter(x -> x.getValue() >= CONFIDENCE_THRESHOLD) .map(Map.Entry::getKey) .collect(Collectors.toList()); pageMap.get(uri).setEncodedEmbeddingVector(encodedVector); pageMap.get(uri).setGeneratedKeywords(generatedKeywords); } } return new ArrayList<>(pageMap.values()); }
Source:
public static Jenkins getInstance() { Jenkins instance = HOLDER.getInstance(); if (instance == null) { if(!Boolean.getBoolean(Jenkins.class.getName()+".disableExceptionOnNullInstance")) { throw new IllegalStateException(); } } return instance; }

Target:
public static Jenkins getInstance() { Jenkins instance = HOLDER.getInstance(); if (instance == null) { if(!Boolean.getBoolean(Jenkins.class.getName()+".disableExceptionOnNullInstance")) { throw new IllegalStateException("Jenkins has not been started, or was already shut down"); } } return instance; }
Source:
void stop(int reason) { int uid = Binder.getCallingUid(); if (uid != mUid && uid != Process.SYSTEM_UID) { if (DBG) { Log.e(TAG, "Cannot stop unowned keepalive " + mSlot + " on " + mNai.network); } } if (NOT_STARTED != mStartedState) { Log.d(TAG, "Stopping keepalive " + mSlot + " on " + mNai.name()); if (mType == TYPE_NATT) { mNai.asyncChannel.sendMessage(CMD_STOP_SOCKET_KEEPALIVE, mSlot); } else if (mType == TYPE_TCP) { mNai.asyncChannel.sendMessage(CMD_STOP_SOCKET_KEEPALIVE, mSlot); mNai.asyncChannel.sendMessage(CMD_REMOVE_KEEPALIVE_PACKET_FILTER, mSlot, mInterval, mPacket); mTcpController.stopSocketMonitor(mSlot); } else { Log.wtf(TAG, "Stoping keepalive with unknown type: " + mType); } } notifyMessenger(mSlot, reason); unlinkDeathRecipient(); }

Target:
void stop(int reason) { int uid = Binder.getCallingUid(); if (uid != mUid && uid != Process.SYSTEM_UID) { if (DBG) { Log.e(TAG, "Cannot stop unowned keepalive " + mSlot + " on " + mNai.network); } } if (NOT_STARTED != mStartedState) { Log.d(TAG, "Stopping keepalive " + mSlot + " on " + mNai.name()); if (mType == TYPE_NATT) { mNai.asyncChannel.sendMessage(CMD_STOP_SOCKET_KEEPALIVE, mSlot); } else if (mType == TYPE_TCP) { mNai.asyncChannel.sendMessage(CMD_STOP_SOCKET_KEEPALIVE, mSlot); mNai.asyncChannel.sendMessage(CMD_REMOVE_KEEPALIVE_PACKET_FILTER, mSlot); mTcpController.stopSocketMonitor(mSlot); } else { Log.wtf(TAG, "Stopping keepalive with unknown type: " + mType); } } notifyMessenger(mSlot, reason); unlinkDeathRecipient(); }
Source:
public final void doFilter( ServletRequest request, ServletResponse response, FilterChain filterChain) throws IOException, ServletException { final HttpServletRequest httpRequest = (HttpServletRequest) request; final HttpSession session = httpRequest.getSession(false); if (session != null) { Subject subject = (Subject) session.getAttribute("che_subject"); if (subject != null && subject.getUserId() != null) { MDC.put(IDENTITY_ID_MDC_KEY, subject.getUserId()); } } try { filterChain.doFilter(request, response); } finally { MDC.remove(IDENTITY_ID_MDC_KEY); } }

Target:
public final void doFilter( ServletRequest request, ServletResponse response, FilterChain filterChain) throws IOException, ServletException { Subject subject = EnvironmentContext.getCurrent().getSubject(); if (subject != null && subject.getUserId() != null) { MDC.put(IDENTITY_ID_MDC_KEY, subject.getUserId()); } try { filterChain.doFilter(request, response); } finally { MDC.remove(IDENTITY_ID_MDC_KEY); } }
Source:
private static boolean assertSameHtml(String expected, String actual, boolean isPart, boolean isDifferenceToBeShown) { String processedExpected = expected.replace("\r", ""); String processedActual = convertToStandardHtml(actual, isPart); if (areDifferentHtmls(processedExpected, processedActual)) { processedExpected = convertToStandardHtml(expected, isPart); if (areDifferentHtmls(processedExpected, processedActual)) { if (isDifferenceToBeShown) { assertEquals("<expected>\n" + processedExpected + "</expected>", "<actual>\n" + processedActual + "</actual>"); } return false; } } return true; }

Target:
private static boolean assertSameHtml(String expected, String actual, boolean isPart, boolean isDifferenceToBeShown) { String processedExpected = standardizeLineBreaks(expected); String processedActual = convertToStandardHtml(actual, isPart); if (areSameHtmls(processedExpected, processedActual)) { return true; } processedExpected = convertToStandardHtml(expected, isPart); if (areSameHtmls(processedExpected, processedActual)) { return true; } else { if (isDifferenceToBeShown) { assertEquals("<expected>\n" + processedExpected + "</expected>", "<actual>\n" + processedActual + "</actual>"); } return false; } }
Source:
void jul() { logger.finest("Unable to open file " + csvPath); logger.finer("Unable to open file " + csvPath); logger.fine("Unable to open file " + csvPath); logger.config("Unable to open file " + csvPath); logger.info("Unable to open file " + csvPath); logger.warning("Unable to open file " + csvPath); logger.severe("Unable to open file " + csvPath); if (logger.isFinestEnabled()) { logger.finest("Unable to open file " + csvPath); } if (logger.isFinerEnabled()) { logger.finer("Unable to open file " + csvPath); } if (logger.isFineEnabled()) { logger.fine("Unable to open file " + csvPath); } if (logger.isFinestEnabled()) { logger.finest("Unable to open file " + csvPath); } if (logger.isConfigEnabled()) { logger.config("Unable to open file " + csvPath); } if (logger.isInfoEnabled()) { logger.info("Unable to open file " + csvPath); } if (logger.isWarningEnabled()) { logger.warning("Unable to open file " + csvPath); } if (logger.isSevereEnabled()) { logger.severe("Unable to open file " + csvPath); } }

Target:
void jul() { logger.finest("Unable to open file " + csvPath); logger.finer("Unable to open file " + csvPath); logger.fine("Unable to open file " + csvPath); logger.config("Unable to open file " + csvPath); logger.info("Unable to open file " + csvPath); logger.warning("Unable to open file " + csvPath); logger.severe("Unable to open file " + csvPath); if (logger.isLoggable(Level.FINEST)) { logger.finest("Unable to open file " + csvPath); } if (logger.isLoggable(Level.INFO)) { logger.trace("Unable to open file " + csvPath); logger.info("Unable to open file " + csvPath); } }
Source:
public static boolean checkPerm(EntityPlayer player, String node, Map<String, IContext> contextInfo) { if (player instanceof FakePlayer) throw new IllegalArgumentException("You cannot check permissions with a fake player. Use PermManager.getPerm(username, node)"); return FACTORY.checkPerm(player, node, contextInfo); }

Target:
public static boolean checkPerm(EntityPlayer player, String node, Map<String, IContext> contextInfo) { return FACTORY.checkPerm(player, node, contextInfo); }
Source:
public String getCollectionInput() { MultiInstanceLoopCharacteristics loopCharacteristics = getMultiInstanceLoopCharacteristics(); ItemAwareElement ieDataInput = loopCharacteristics.getLoopDataInputRef(); return process.getDataInputAssociations().stream() .filter(dia -> dia.getTargetRef().equals(ieDataInput)) .map(dia -> dia.getSourceRef().get(0).getId()) .findFirst() .get(); }

Target:
public String getCollectionInput() { ItemAwareElement ieDataInput = getMultiInstanceLoopCharacteristics() .map(MultiInstanceLoopCharacteristics::getLoopDataInputRef) .orElse(null); return process.getDataInputAssociations().stream() .filter(dia -> dia.getTargetRef().getId().equals(ieDataInput.getId())) .map(dia -> ProcessVariableReader.getProcessVariableName((Property) dia.getSourceRef().get(0))) .findFirst() .orElse(null); }
Source:
public static String randomAllocateIpv4Address(Long startIp, Long endIp, List<Long> allocatedIps) { int total = (int)(endIp - startIp + 1); if (total == allocatedIps.size()) { return null; } if (startIp == endIp){ return longToIpv4String(startIp); } BitSet full = new BitSet(total); for (long alloc : allocatedIps) { full.set((int) (alloc-startIp)); } Random random = new Random(); int next = random.nextInt(total); int a = full.nextClearBit(next); if (a >= total) { a = full.nextClearBit(0); } return longToIpv4String(a + startIp); }

Target:
public static String randomAllocateIpv4Address(Long startIp, Long endIp, List<Long> allocatedIps) { int total = (int)(endIp - startIp + 1); if (total == allocatedIps.size()) { return null; } if (startIp.equals(endIp) && allocatedIps.size() == 0){ return longToIpv4String(startIp); } BitSet full = new BitSet(total); for (long alloc : allocatedIps) { full.set((int) (alloc-startIp)); } Random random = new Random(); int next = random.nextInt(total); int a = full.nextClearBit(next); if (a >= total) { a = full.nextClearBit(0); } return longToIpv4String(a + startIp); }
Source:
public WriterTarget getTarget() { return target; }

Target:
public Optional<WriterTarget> getTarget() { return target; }
Source:
public void select(final MenuItem item) { Boolean enabled = Display.syncExec(new ResultRunnable<Boolean>() { @Override public Boolean run() { return isMenuItemEnabled(item); } }); if (!enabled) { throw new CoreLayerException("Menu item is not enabled"); } else { Display.syncExec(new Runnable() { @Override public void run() { if (((item.getStyle() & SWT.RADIO) != 0) || ((item.getStyle() & SWT.CHECK) != 0)) { item.setSelection(!item.getSelection()); } } }); Display.asyncExec(new Runnable() { @Override public void run() { final Event event = new Event(); event.time = (int) System.currentTimeMillis(); event.widget = item; event.item = item; event.display = item.getDisplay(); event.type = SWT.Selection; log.info("Click on menu item: " + item.getText()); item.notifyListeners(SWT.Selection, event); } }); Display.syncExec(new Runnable() { @Override public void run() { } }); } }

Target:
public void select(final MenuItem item) { if (!isEnabled(item)) { throw new CoreLayerException("Menu item is not enabled"); } else { Display.syncExec(new Runnable() { @Override public void run() { if (((item.getStyle() & SWT.RADIO) != 0) || ((item.getStyle() & SWT.CHECK) != 0)) { item.setSelection(!item.getSelection()); } } }); Display.asyncExec(new Runnable() { @Override public void run() { final Event event = createSelectionEvent(item); log.info("Select menu item: " + item.getText()); item.notifyListeners(SWT.Selection, event); } }); Display.syncExec(new Runnable() { @Override public void run() { } }); } }
Source:
private void closeViewer() { if (getRoot() != null) BagsManager.instance().unwatch(getRoot()); tryNavigate(_history.empty()); treeSnapshots.clear(); try { SwingUtilities.getWindowAncestor(this).dispose(); } catch (Exception ex) { LOG.log(Level.WARNING, "Couldn't close viewer window", ex); } _orderedInstances.remove(this); PluginRegistry.unregisterConsumer(this); OT.removeEditableStateListener(_editableStateListener); _actions.close(); ViewerService.instance().get().unregisterView(this); }

Target:
private void closeViewer() { if (getRoot() != null) { BagsManager.instance().unwatch(getRoot()); } tryNavigate(_history.empty()); treeSnapshots.clear(); try { SwingUtilities.getWindowAncestor(this).dispose(); } catch (Exception ex) { LOG.log(Level.WARNING, "Couldn't close viewer window", ex); } _orderedInstances.remove(this); PluginRegistry.unregisterConsumer(this); OT.removeEditableStateListener(_editableStateListener); _actions.close(); ViewerService.instance().get().unregisterView(this); }
Source:
public String getNextID(Class<? extends OWLEntity> type) throws AutoIDException { String id = nextId; try { nextId = Util.randomProlong(); } catch (Exception e) { e.printStackTrace(); } return getPrefix(type) + id.toString().replace("-", "_") + getSuffix(type); }

Target:
public String getNextID(Class<? extends OWLEntity> type) throws AutoIDException { try { nextId = Util.randomProlong(); } catch (Exception e) { logger.error("An error occurred whilst attempting to get the next ID", e); } return getPrefix(type) + nextId.toString() + getSuffix(type); }
Source:
public PopupMenuExportResponse() { super(Constant.messages.getString("history.export.response.popup")); this.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(java.awt.event.ActionEvent e) { List<HistoryReference> hrefs = extension.getSelectedHistoryReferences(); if (hrefs.size() == 0) { extension.getView().showWarningDialog(Constant.messages.getString("history.export.response.select.warning")); return; } File file = getOutputFile(); if (file == null) { return; } boolean isAppend = true; if (file.exists()) { int rc = extension.getView().showYesNoCancelDialog(Constant.messages.getString("file.overwrite.warning")); if (rc == JOptionPane.CANCEL_OPTION) { return; } else if (rc == JOptionPane.YES_OPTION) { isAppend = false; } } BufferedOutputStream bos = null; try { bos = new BufferedOutputStream(new FileOutputStream(file, isAppend)); for (HistoryReference href : hrefs) { HttpMessage msg = null; msg = href.getHttpMessage(); exportHistory(msg, bos); } } catch (Exception e1) { extension.getView().showWarningDialog(Constant.messages.getString("file.save.error") + file.getAbsolutePath() + "."); log.warn(e1.getMessage(), e1); } finally { try { if (bos != null) { bos.close(); } } catch (Exception e2) { log.warn(e2.getMessage(), e2); } } } }); }

Target:
public PopupMenuExportResponse() { super(Constant.messages.getString("history.export.response.popup")); this.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(java.awt.event.ActionEvent e) { List<HistoryReference> hrefs = extension.getSelectedHistoryReferences(); if (hrefs.size() == 0) { extension.getView().showWarningDialog(Constant.messages.getString("history.export.response.select.warning")); return; } File file = getOutputFile(); if (file == null) { return; } boolean isAppend = true; if (file.exists()) { int rc = extension.getView().showYesNoCancelDialog(Constant.messages.getString("file.overwrite.warning")); if (rc == JOptionPane.CANCEL_OPTION) { return; } else if (rc == JOptionPane.YES_OPTION) { isAppend = false; } } try (BufferedOutputStream bos = new BufferedOutputStream( new FileOutputStream(file, isAppend));) { for (HistoryReference href : hrefs) { HttpMessage msg = null; msg = href.getHttpMessage(); exportHistory(msg, bos); } } catch (Exception e1) { extension.getView().showWarningDialog(Constant.messages.getString("file.save.error") + file.getAbsolutePath() + "."); log.warn(e1.getMessage(), e1); } } }); }
Source:
private void generateTheStackTrace(Throwable exception, ITestNGMethod method, String title, StringBuilder contentBuffer) { logger.entering(new Object[] { exception, method, title, contentBuffer }); contentBuffer.append(" <div class='stContainer' >" + exception.getClass() + ":" + title + "<a class='exceptionlnk' herf='#'>(+)</a>"); contentBuffer.append("<div class='exception' style='display:none'>"); StackTraceElement[] s1 = exception.getStackTrace(); Throwable t2 = exception.getCause(); if ((t2 != null) && (t2.equals(exception))) { t2 = null; } for (int x = 0; x < s1.length; x++) { contentBuffer.append((x > 0 ? "<br/>at " : "") + escape(s1[x].toString())); } if (t2 != null) { generateExceptionReport(t2, method, "Caused by " + t2.getLocalizedMessage(), contentBuffer); } contentBuffer.append("</div></div>"); logger.exiting(); }

Target:
private void generateTheStackTrace(Throwable exception, ITestNGMethod method, String title, StringBuilder contentBuffer) { logger.entering(new Object[] { exception, method, title, contentBuffer }); contentBuffer.append(" <div class='stContainer' >" + exception.getClass() + ":" + title + "<a class='exceptionlnk' href='#'>(+)</a>"); contentBuffer.append("<div class='exception' style='display:none'>"); StackTraceElement[] s1 = exception.getStackTrace(); Throwable t2 = exception.getCause(); if ((t2 != null) && (t2.equals(exception))) { t2 = null; } for (int x = 0; x < s1.length; x++) { contentBuffer.append((x > 0 ? "<br/>at " : "") + escape(s1[x].toString())); } if (t2 != null) { generateExceptionReport(t2, method, "Caused by " + t2.getLocalizedMessage(), contentBuffer); } contentBuffer.append("</div></div>"); logger.exiting(); }
Source:
public <D extends EntityDriver> D build(DriverDependentEntity<D> entity, Location location){ Class<D> driverInterface = entity.getDriverInterface(); Class<? extends D> driverClass; if (driverInterface.isInterface()) { String driverClassName = inferClassName(driverInterface, location); try { System.out.println("Loading "+driverInterface.getName()); entity.getClass().getClassLoader().loadClass(driverInterface.getName()); } catch (ClassNotFoundException e) { throw Throwables.propagate(e); } try { System.out.println("Loading "+driverClassName); driverClass = (Class<? extends D>) entity.getClass().getClassLoader().loadClass(driverClassName); } catch (ClassNotFoundException e) { throw Throwables.propagate(e); } } else { driverClass = driverInterface; } Constructor constructor = getConstructor(driverClass); try { constructor.setAccessible(true); return (D) constructor.newInstance(entity, location); } catch (InstantiationException e) { throw Throwables.propagate(e); } catch (IllegalAccessException e) { throw Throwables.propagate(e); } catch (InvocationTargetException e) { throw Throwables.propagate(e); } }

Target:
public <D extends EntityDriver> D build(DriverDependentEntity<D> entity, Location location){ Class<D> driverInterface = entity.getDriverInterface(); Class<? extends D> driverClass; if (driverInterface.isInterface()) { String driverClassName = inferClassName(driverInterface, location); try { driverClass = (Class<? extends D>) entity.getClass().getClassLoader().loadClass(driverClassName); } catch (ClassNotFoundException e) { throw Throwables.propagate(e); } } else { driverClass = driverInterface; } Constructor<? extends D> constructor = getConstructor(driverClass); try { constructor.setAccessible(true); return constructor.newInstance(entity, location); } catch (InstantiationException e) { throw Throwables.propagate(e); } catch (IllegalAccessException e) { throw Throwables.propagate(e); } catch (InvocationTargetException e) { throw Throwables.propagate(e); } }
Source:
public void testGetAllDatabases() throws Exception { final String[] dbsToCreate = {"db_1", "db_2", "db_3"}; final WebTarget dbTarget = target().path("metastore").path("databases"); for (String name : dbsToCreate) { dbTarget.queryParam("sessionid", lensSessionId).request(mediaType).post(Entity.xml(name)); } StringList allDbs = target().path("metastore").path("databases") .queryParam("sessionid", lensSessionId).request(mediaType) .get(StringList.class); System.out.println("ALL DBs:" + allDbs.getElements()); assertEquals(allDbs.getElements().size(), 6); List<String> expected = new ArrayList<String>(Arrays.asList(dbsToCreate)); expected.add("default");expected.add("lensstats");expected.add("test_set_db"); assertEquals(allDbs.getElements(), expected); for (String name : dbsToCreate) { dbTarget.path(name).queryParam("cascade", "true").queryParam("sessionid", lensSessionId).request().delete(); } }

Target:
public void testGetAllDatabases() throws Exception { final String[] dbsToCreate = {"db_1", "db_2", "db_3"}; final WebTarget dbTarget = target().path("metastore").path("databases"); for (String name : dbsToCreate) { dbTarget.queryParam("sessionid", lensSessionId).request(mediaType).post(Entity.xml(name)); } StringList allDbs = target().path("metastore").path("databases") .queryParam("sessionid", lensSessionId).request(mediaType) .get(StringList.class); System.out.println("ALL DBs:" + allDbs.getElements()); assertEquals(allDbs.getElements().size(), 4); List<String> expected = new ArrayList<String>(Arrays.asList(dbsToCreate)); expected.add("default"); assertEquals(allDbs.getElements(), expected); for (String name : dbsToCreate) { dbTarget.path(name).queryParam("cascade", "true").queryParam("sessionid", lensSessionId).request().delete(); } }
Source:
private BulkWriteResult executeAndLogBulkErrors(BulkWriteOperation bwo) { BulkWriteResult result = null; try { if (writeConcern == null) { LOGGER.debug("Bulk updating docs"); result = bwo.execute(); } else { LOGGER.debug("Bulk deleting docs with writeConcern={} from execution", writeConcern); result = bwo.execute(writeConcern); } } catch (BulkWriteException e) { BulkWriteException bwe = e; result = bwe.getWriteResult(); LOGGER.warn("Bulk update operation contains errors", bwe); docUpdateErrors.addAll(bwe.getWriteErrors()); } catch (Exception e) { throw e; } return result; }

Target:
private BulkWriteResult executeAndLogBulkErrors(BulkWriteOperation bwo) { BulkWriteResult result = null; try { if (writeConcern == null) { LOGGER.debug("Bulk updating docs"); result = bwo.execute(); } else { LOGGER.debug("Bulk deleting docs with writeConcern={} from execution", writeConcern); result = bwo.execute(writeConcern); } } catch (BulkWriteException e) { BulkWriteException bwe = e; result = bwe.getWriteResult(); LOGGER.warn("Bulk update operation contains errors", bwe); docUpdateErrors.addAll(bwe.getWriteErrors()); } return result; }
Source:
public void after() { for (IBean<?> bean : m_replacedBeans) { BeanTestingHelper.get().unregisterBean(bean); } m_replacedBeans.clear(); }

Target:
public void after() { BeanTestingHelper.get().unregisterBeans(m_replacedBeans); m_replacedBeans.clear(); }
Source:
public void testCheckTaskStatus() throws ProductInstallatorException, OpenStackException { TaskService taskService = mock (TaskService.class); com.telefonica.euro_iaas.sdc.model.Task task = new Task (); task.setStatus(TaskStates.SUCCESS); when(taskService.load(anyString(),anyString(), anyString())).thenReturn(task); when(openStackRegion.getDefaultRegion(anyString())).thenReturn("region"); when(openStackRegion.getSdcEndPoint(anyString(), anyString())).thenReturn("http"); when(sDCClient.getTaskService(anyString(),anyString())).thenReturn(taskService); sdcUtilImpl.checkTaskStatus(task, "token", "vdc"); }

Target:
public void testCheckTaskStatus() throws ProductInstallatorException, OpenStackException { TaskService taskService = mock (TaskService.class); com.telefonica.euro_iaas.sdc.model.Task task = new Task (); task.setStatus(TaskStates.SUCCESS); when(taskService.load(anyString(),anyString(), anyString())).thenReturn(task); when(openStackRegion.getDefaultRegion(anyString())).thenReturn("region"); when(openStackRegion.getSdcEndPoint(anyString(), anyString())).thenReturn("http"); when(sDCClient.getTaskService(anyString(),anyString())).thenReturn(taskService); sdcUtilImpl.checkTaskStatus(task, "token", "vdc"); verify (sDCClient).getTaskService(anyString(),anyString()); }
Source:
protected boolean containsExpectedPageContents() { if (isElementPresent(By.className("modal-content"))) { waitForConfirmationModalAndClickOk(); } reloadPageIfStuckLoading(); return getPageTitle().contains("Submit Feedback"); }

Target:
protected boolean containsExpectedPageContents() { if (isElementPresent(By.className("modal-content"))) { waitForConfirmationModalAndClickOk(); } return getPageTitle().contains("Submit Feedback"); }
Source:
private List<SubscriptionAssignment> readExistingAssignments() { return subscriptionsCache.listActiveSubscriptionNames().stream().flatMap(subscriptionName -> { String path = pathSerializer.serialize(subscriptionName); List<String> children = new ArrayList<>(); try { children.addAll(curator.getChildren().forPath(path)); } catch (Exception e) { } return children.stream().map(node -> new SubscriptionAssignment(node, subscriptionName)); }).collect(Collectors.toList()); }

Target:
private List<SubscriptionAssignment> readExistingAssignments() { List<SubscriptionAssignment> existingAssignments = new ArrayList<>(); for (SubscriptionName subscriptionName : subscriptionsCache.listActiveSubscriptionNames()) { try { String path = pathSerializer.serialize(subscriptionName); List<String> nodes = curator.getChildren().forPath(path); for (String node : nodes) { String fullPath = path + "/" + node; existingAssignments.add(pathSerializer.deserialize(fullPath, curator.getData().forPath(fullPath))); } } catch (Exception e) { logger.info("Exception occurred when initializing cache with subscription {}", subscriptionName, e); } } return existingAssignments; }
Source:
public ZAddArgs gt() { this.gt = true; return this; }

Target:
public ZAddArgs gt() { this.gt = true; this.lt = false; return this; }
Source:
private VmNetworkInterface getIfaceWithNetworkName(List<VmNetworkInterface> interfaces) { if (getNetworkName() == null) { return null; } else { return LinqUtils.firstOrNull(interfaces, new Predicate<VmNetworkInterface>() { @Override public boolean eval(VmNetworkInterface vmNetworkInterface) { return getNetworkName().equals(vmNetworkInterface.getName()); } }); } }

Target:
private VmNetworkInterface getIfaceWithNetworkName(List<VmNetworkInterface> interfaces) { return LinqUtils.firstOrNull(interfaces, new Predicate<VmNetworkInterface>() { @Override public boolean eval(VmNetworkInterface vmNetworkInterface) { return getNetworkName().equals(vmNetworkInterface.getName()); } }); }
Source:
public IASTName[] getNames() { IASTName[] result = new IASTName[fQualifierPos + (fLastName == null ? 1 : 2)]; int idx = 0; for (ICPPASTNameSpecifier nameSpecifier : getQualifier()) if (nameSpecifier instanceof IASTName) result[idx++] = (IASTName) nameSpecifier; else throw new UnsupportedOperationException("Can't use getNames() on a " + "qualified name that includes a decltype-specifier. Use " + "getQualifier() and getLastName() instead"); if (fLastName != null) result[fQualifierPos + 1] = fLastName; return result; }

Target:
public IASTName[] getNames() { IASTName[] result = new IASTName[fQualifierPos + (fLastName == null ? 1 : 2)]; int idx = 0; for (ICPPASTNameSpecifier nameSpecifier : getQualifier()) { if (nameSpecifier instanceof IASTName) { result[idx++] = (IASTName) nameSpecifier; } else { throw new UnsupportedOperationException("Can't use getNames() on a " + "qualified name that includes a decltype-specifier. Use " + "getQualifier() and getLastName() instead"); } } if (fLastName != null) result[fQualifierPos + 1] = fLastName; return result; }
Source:
public NotificationAssert hasGroup(String group) { isNotNull(); assertThat(actual.getGroup()) .overridingErrorMessage("Expected group <%s> but was <%s>.", group, actual.getGroup()) .isEqualTo(group); return this; }

Target:
public NotificationAssert hasGroup(String group) { isNotNull(); String actualGroup = actual.getGroup(); assertThat(actual.getGroup()) .overridingErrorMessage("Expected group <%s> but was <%s>.", group, actualGroup) .isEqualTo(group); return this; }
Source:
private InstructorFeedbackResultsPage loginToInstructorFeedbackResultsPage(String instructorName, String fsName) { AppUrl resultsUrl = createUrl(Const.ActionURIs.INSTRUCTOR_FEEDBACK_RESULTS_PAGE) .withUserId(testData.instructors.get(instructorName).googleId) .withCourseId(testData.feedbackSessions.get(fsName).getCourseId()) .withSessionName(testData.feedbackSessions.get(fsName).getFeedbackSessionName()); Stopwatch stopwatch = new Stopwatch(); stopwatch.start(); InstructorFeedbackResultsPage resultsPage = loginAdminToPage(resultsUrl, InstructorFeedbackResultsPage.class); log.info("Time taken: " + stopwatch.getTimeElapsedInSeconds()); return resultsPage; }

Target:
private InstructorFeedbackResultsPage loginToInstructorFeedbackResultsPage(String instructorName, String fsName) { AppUrl resultsUrl = createUrl(Const.ActionURIs.INSTRUCTOR_FEEDBACK_RESULTS_PAGE) .withUserId(testData.instructors.get(instructorName).googleId) .withCourseId(testData.feedbackSessions.get(fsName).getCourseId()) .withSessionName(testData.feedbackSessions.get(fsName).getFeedbackSessionName()); Stopwatch stopwatch = new Stopwatch(); stopwatch.start(); InstructorFeedbackResultsPage resultsPage = loginAdminToPage(resultsUrl, InstructorFeedbackResultsPage.class); resultsPage.expandPanels(); log.info("Time taken: " + stopwatch.getTimeElapsedInSeconds()); return resultsPage; }
Source:
public String allowedPattern(Type type) { return Converter.ANY_MULTI_LINE; }

Target:
public String allowedPattern(Type type) { return "\\s*([0-9]+/(tcp|udp)\\s*)+"; }
Source:
public void should_SetExpiration_givenKeyTo_StringValueInMilliSeconds() { String key = "key"; String value = "value"; long millisecondsToLive = 20000l; jedis.set(key, value); Long timeToLive = jedis.ttl(key); assertThat(timeToLive).isEqualTo(-1); jedis.pexpire(key, millisecondsToLive); timeToLive = jedis.ttl(key); assertThat(timeToLive).isLessThanOrEqualTo(20); assertThat(timeToLive).isGreaterThanOrEqualTo(15); }

Target:
public void should_SetExpiration_givenKeyTo_StringValueInMilliSeconds() { String key = "key"; String value = "value"; long millisecondsToLive = 20000L; jedis.set(key, value); Long timeToLive = jedis.ttl(key); assertThat(timeToLive).isEqualTo(-1); jedis.pexpire(key, millisecondsToLive); timeToLive = jedis.ttl(key); assertThat(timeToLive).isLessThanOrEqualTo(20); assertThat(timeToLive).isGreaterThanOrEqualTo(15); }
Source:
public boolean quit() { if (stateManager.getAnyTaskRunning().getValue()) { Optional<ButtonType> shouldClose = dialogService.showBackgroundProgressDialogAndWait( Localization.lang("Please wait..."), Localization.lang("Waiting for background tasks to finish. Quit anyway?"), stateManager ); if (!(shouldClose.isPresent() && (shouldClose.get() == ButtonType.YES))) { return false; } } List<String> filenames = new ArrayList<>(); for (int i = 0; i < tabbedPane.getTabs().size(); i++) { BasePanel panel = getBasePanelAt(i); final BibDatabaseContext context = panel.getBibDatabaseContext(); if (panel.isModified() && (context.getLocation() == DatabaseLocation.LOCAL)) { tabbedPane.getSelectionModel().select(i); if (!confirmClose(panel)) { return false; } } else if (context.getLocation() == DatabaseLocation.SHARED) { context.convertToLocalDatabase(); context.getDBMSSynchronizer().closeSharedDatabase(); context.clearDBMSSynchronizer(); } SaveDatabaseAction.shutDown(context); BackupManager.shutdown(context); context.getDatabasePath().map(Path::toAbsolutePath).map(Path::toString).ifPresent(filenames::add); } WaitForSaveFinishedDialog waitForSaveFinishedDialog = new WaitForSaveFinishedDialog(dialogService); waitForSaveFinishedDialog.showAndWait(getBasePanelList()); tearDownJabRef(filenames); Platform.exit(); return true; }

Target:
public boolean quit() { if (stateManager.getAnyTaskRunning().getValue()) { Optional<ButtonType> shouldClose = dialogService.showBackgroundProgressDialogAndWait( Localization.lang("Please wait..."), Localization.lang("Waiting for background tasks to finish. Quit anyway?"), stateManager ); if (!(shouldClose.isPresent() && (shouldClose.get() == ButtonType.YES))) { return false; } } List<String> filenames = new ArrayList<>(); for (int i = 0; i < tabbedPane.getTabs().size(); i++) { LibraryTab libraryTab = getLibraryTabAt(i); final BibDatabaseContext context = libraryTab.getBibDatabaseContext(); if (libraryTab.isModified() && (context.getLocation() == DatabaseLocation.LOCAL)) { tabbedPane.getSelectionModel().select(i); if (!confirmClose(libraryTab)) { return false; } } else if (context.getLocation() == DatabaseLocation.SHARED) { context.convertToLocalDatabase(); context.getDBMSSynchronizer().closeSharedDatabase(); context.clearDBMSSynchronizer(); } AutosaveManager.shutdown(context); BackupManager.shutdown(context); context.getDatabasePath().map(Path::toAbsolutePath).map(Path::toString).ifPresent(filenames::add); } WaitForSaveFinishedDialog waitForSaveFinishedDialog = new WaitForSaveFinishedDialog(dialogService); waitForSaveFinishedDialog.showAndWait(getLibraryTabs()); tearDownJabRef(filenames); Platform.exit(); return true; }
Source:
private void waitForPackagesRefreshed() { int count = 0; synchronized (lock) { while (!moduleRefreshed && count < MAX_WAIT_COUNT) { try { lock.wait(WAIT_TIME); } catch (InterruptedException e) { LOGGER.error("Interrupted while waiting", e); } ++count; } if(count >= MAX_WAIT_COUNT) { LOGGER.error("Package has not been refreshed, reached time limit"); } } }

Target:
private void waitForPackagesRefreshed() { int count = 0; synchronized (lock) { while (!moduleRefreshed && count < MAX_WAIT_COUNT) { try { lock.wait(WAIT_TIME); } catch (InterruptedException e) { LOGGER.error("Interrupted while waiting", e); } ++count; } if (count >= MAX_WAIT_COUNT) { LOGGER.error("Packages have not been refreshed, reached time limit"); } } }
Source:
final Listener wrap(Listener delegate) { return new Listener() { @Override public void onSuccess() { requestsSucceeded.increment(); delegate.onSuccess(); } @Override public void onIgnore() { requestsIgnored.increment(); delegate.onIgnore(); } @Override public void onDropped() { requestsDropped.increment(); delegate.onDropped(); } }; }

Target:
final Listener wrap(Listener delegate) { return new Listener() { @Override public void onSuccess() { requestsSucceeded.increment(); delegate.onSuccess(); } @Override public void onIgnore() { requestsIgnored.increment(); delegate.onIgnore(); } @Override public void onDropped() { requestsDropped.increment(); delegate.onDropped(); } @Override public String toString() { return "LimiterMetrics{" + delegate + "}"; } }; }
Source:
protected int run() throws Exception { boolean errorOccurred = false; try { Jenkins.getActiveInstance().doReload(); } catch (AccessDeniedException e) { stderr.println(e.getMessage()); errorOccurred = true; } catch (Exception e) { final String errorMsg = String.format("Unexpected exception occurred during performing clear-queue command: %s", e.getMessage()); stderr.println(errorMsg); LOGGER.warning(errorMsg); errorOccurred = true; } return errorOccurred ? 1 : 0; }

Target:
protected int run() throws Exception { Jenkins.getActiveInstance().doReload(); return 0; }
Source:
public void setGuestOsNamedVersion() { if (guestOsType == OsType.Linux) { String optional = ""; if (!StringUtils.isEmpty(guestOsCodename)) { optional = messages.guestOSVersionOptional(guestOsCodename); } guestOsNamedVersion = messages.guestOSVersionLinux(guestOsDistribution, guestOsVersion, optional); } else if (guestOsType == OsType.Windows && guestOs.startsWith("Win ")) { if (guestOs.startsWith("Win 20")) { guestOsNamedVersion = messages.guestOSVersionWindowsServer(guestOs.substring(4), guestOsVersion); } else { guestOsNamedVersion = messages.guestOSVersionWindows(guestOs.substring(4), guestOsVersion); } } }

Target:
private void setGuestOsNamedVersion() { if (guestOsType == OsType.Linux) { String optional = ""; if (!StringUtils.isEmpty(guestOsCodename)) { optional = messages.guestOSVersionOptional(guestOsCodename); } guestOsNamedVersion = messages.guestOSVersionLinux(guestOsDistribution, guestOsVersion, optional); } else if (guestOsType == OsType.Windows && guestOs.startsWith("Win ")) { if (guestOs.startsWith("Win 20")) { guestOsNamedVersion = messages.guestOSVersionWindowsServer(guestOs.substring(4), guestOsVersion); } else { guestOsNamedVersion = messages.guestOSVersionWindows(guestOs.substring(4), guestOsVersion); } } }