auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>protected void initializeConfiguration( ISynchronizePageConfiguration configuration) { configuration.setProperty(ISynchronizePageConfiguration.P_VIEWER_ID, VIEWER_ID); configuration.setProperty( ModelSynchronizeParticipant.P_VISIBLE_MODEL_PROVIDER, GitChangeSetModelProvider.ID); <START> configuration.addActionContribution(new GitActionContributor()); <END> super.initializeConfiguration(configuration); configuration.addActionContribution(new GitActionContributor()); }</code><technical_language>adding this twice</technical_language>

Target:
protected void initializeConfiguration( ISynchronizePageConfiguration configuration) { configuration.setProperty(ISynchronizePageConfiguration.P_VIEWER_ID, VIEWER_ID); configuration.setProperty( ModelSynchronizeParticipant.P_VISIBLE_MODEL_PROVIDER, GitChangeSetModelProvider.ID); super.initializeConfiguration(configuration); configuration.addActionContribution(new GitActionContributor()); }
Source:
<code>public void traceSelected(@Nullable TmfTraceSelectedSignal signal) { LatencyAnalysis analysis = LatencyViewerUtils.getAnalysisFromSignal(signal); if (analysis != null) { <START> analysis.addListener(fListener); <END> if (analysis.getResults() == null) { if (LatencyViewerUtils.runAnalysis()) { return; } } fData = LatencyViewerUtils.getResultsFromAnalysis(analysis); updateModel(fData); } }</code><technical_language>If switch traces added times a listener</technical_language>

Target:
public void traceSelected(@Nullable TmfTraceSelectedSignal signal) { LatencyAnalysis analysis = LatencyViewerUtils.getAnalysisFromSignal(signal); fData = LatencyViewerUtils.getResultsFromAnalysis(analysis); updateModel(fData); }
Source:
<code>protected LogRecord<M> read() { if (closed) { throw new IllegalStateException("The tailer has been closed."); } List<M> value = new ArrayList<>(1); long offset = cqTailer.index(); if (codec != null) { if (!cqTailer.readDocument(w -> value.add(codec.decode(w.read().bytes())))) { return null; } } else { <START> if (!cqTailer.readDocument(w -> value.add((M) w.read("msg").object()))) { <END> return null; } } return new LogRecord<>(value.get(0), new LogOffsetImpl(partition, offset)); }</code><technical_language>common "msg" constant</technical_language>

Target:
protected LogRecord<M> read() { if (closed) { throw new IllegalStateException("The tailer has been closed."); } List<M> value = new ArrayList<>(1); long offset = cqTailer.index(); if (NO_CODEC.equals(codec)) { try { if (!cqTailer.readDocument(w -> value.add((M) w.read(MSG_KEY).object()))) { return null; } } catch (ClassCastException e) { throw new IllegalArgumentException(e); } } else { if (!cqTailer.readDocument(w -> value.add(codec.decode(w.read().bytes())))) { return null; } } return new LogRecord<>(value.get(0), new LogOffsetImpl(partition, offset)); }
Source:
<code>public void refreshList() { if (isNetworkAvailable()) { String apiLocationFormat = Constants.getApiLocation(mRoomName); call = MachineService.getService().getMachineStatus(apiLocationFormat); call.enqueue(new Callback<ArrayList<Machine>>() { @Override public void onResponse(Call<ArrayList<Machine>> call, Response<ArrayList<Machine>> response) { if (progressDialog.isShowing()) { progressDialog.dismiss(); } if (response.isSuccessful()) { mSwipeRefreshLayout.setRefreshing(false); isRefreshing = false; classMachines = response.body(); if (ModelOperations.machinesOffline(classMachines)) { showOfflineDialogIfNecessary(); } updateRecyclerView(); } else { int httpCode = response.code(); if (httpCode < 500) { showErrorDialog(getString(R.string.error_client_message)); AnalyticsHelper.sendEventHit("api", "errorCodes", "/location/" + mRoomName, httpCode); } else { showErrorDialog(getString(R.string.error_server_message)); AnalyticsHelper.sendEventHit("api", "errorCodes", "/location/" + mRoomName, httpCode); } } } @Override public void onFailure(Call<ArrayList<Machine>> call, Throwable t) { <START> if (isAdded() && getActivity() != null) { <END> showErrorDialog(getString(R.string.error_server_message)); mSwipeRefreshLayout.setRefreshing(false); isRefreshing = false; alertNetworkError(); } else { AnalyticsHelper.sendEventHit(AnalyticsHelper.ERROR, "onFailure", "MachineFragment's Activity Null"); } AnalyticsHelper.sendErrorHit(t, false); } }); } else { showNoInternetDialog(); } }</code><technical_language>want a call.isCanceled() (<LINK_0> If canceled do nothing. check rest. Calling cancel Call ends in onFailure</technical_language>

Target:
public void refreshList() { if (isNetworkAvailable()) { String apiLocationFormat = Constants.getApiLocation(mRoomName); call = MachineService.getService().getMachineStatus(apiLocationFormat); call.enqueue(new Callback<ArrayList<Machine>>() { @Override public void onResponse(Call<ArrayList<Machine>> call, Response<ArrayList<Machine>> response) { if (progressDialog.isShowing()) { progressDialog.dismiss(); } if (response.isSuccessful()) { mSwipeRefreshLayout.setRefreshing(false); isRefreshing = false; classMachines = response.body(); if (ModelOperations.machinesOffline(classMachines)) { showOfflineDialogIfNecessary(); } updateRecyclerView(); } else { int httpCode = response.code(); if (httpCode < 500) { showErrorDialog(getString(R.string.error_client_message)); AnalyticsHelper.sendEventHit("api", "errorCodes", "/location/" + mRoomName, httpCode); } else { showErrorDialog(getString(R.string.error_server_message)); AnalyticsHelper.sendEventHit("api", "errorCodes", "/location/" + mRoomName, httpCode); } } } @Override public void onFailure(Call<ArrayList<Machine>> call, Throwable t) { if (call.isCanceled()) { return; } if (isAdded() && getActivity() != null) { showErrorDialog(getString(R.string.error_server_message)); mSwipeRefreshLayout.setRefreshing(false); isRefreshing = false; alertNetworkError(); } else { AnalyticsHelper.sendErrorHit(new RuntimeException("Activity null"), false); } AnalyticsHelper.sendErrorHit(t, false); } }); } else { showNoInternetDialog(); } }
Source:
<code>@Override public boolean hasNext() { <START> return nextElementIndex != elementCount; <END> }</code><technical_language>mod check need too</technical_language>

Target:
@Override public boolean hasNext() { checkForComodification(); return nextElementIndex != elementCount; }
Source:
<code>public boolean next() { if ( next == NO_ID ) { reset(); return false; } boolean hasChanges = read.hasTxStateWithChanges(); TransactionState txs = hasChanges ? read.txState() : null; do { if ( hasChanges && txs.nodeIsAddedInThisTx( next ) ) { setId( next++ ); setInUse( true ); } else if ( hasChanges && txs.nodeIsDeletedInThisTx( next ) ) { next++; setInUse( false ); } else { read.node( this, next++, pageCursor ); } if ( next > highMark ) { if ( highMark == NO_ID ) { next = NO_ID; return inUse(); } else { highMark = read.nodeHighMark(); if ( next > highMark ) { next = NO_ID; return inUse(); } } } else if ( next < 0 ) { next = NO_ID; return inUse(); } } <START> while ( !inUse() ); <END> return true; }</code><technical_language>this in a test</technical_language>

Target:
public boolean next() { if ( next == NO_ID ) { reset(); return false; } boolean hasChanges = read.hasTxStateWithChanges(); TransactionState txs = hasChanges ? read.txState() : null; do { if ( hasChanges && txs.nodeIsAddedInThisTx( next ) ) { setId( next++ ); setInUse( true ); } else if ( hasChanges && txs.nodeIsDeletedInThisTx( next ) ) { next++; setInUse( false ); } else { read.node( this, next++, pageCursor ); } if ( next > highMark ) { if ( isSingle() ) { next = NO_ID; return inUse(); } else { highMark = read.nodeHighMark(); if ( next > highMark ) { next = NO_ID; return inUse(); } } } else if ( next < 0 ) { next = NO_ID; return inUse(); } } while ( !inUse() ); return true; }
Source:
<code>public final boolean incrementToken() throws IOException { if (state != null) { restoreState(state); if (scriptOne.length() > 0) { replayTerm(scriptOne); if (scriptTwo.length() == 0) { state = null; } return true; } if (scriptTwo.length() > 0) { replayTerm(scriptTwo); state = null; return true; } <START> assert false; <END> } if (!input.incrementToken()) { return false; } boolean matchesBothScripts = hasChars(translationTable.getScript1Reg()) && hasChars(translationTable.getScript2Reg()); if (matchesBothScripts) { scriptOne.setLength(0); scriptOne.append(termAtt); translationTable.replaceScriptOne(scriptOne); scriptTwo.setLength(0); scriptTwo.append(termAtt); translationTable.replaceScriptTwo(scriptTwo); if (!translationTable.getScript1Reg().matcher(scriptOne).find()) { state = captureState(); } else { scriptOne.setLength(0); } if (!translationTable.getScript2Reg().matcher(scriptTwo).find()) { if (state == null) { state = captureState(); } } else { scriptTwo.setLength(0); } } return true; }</code><technical_language>replacing assert false throw new IllegalStateException("At of [scriptOne, scriptTwo] empty. This happen.") works fine in case. Spotbugs complain. error have</technical_language>

Target:
public final boolean incrementToken() throws IOException { if (state != null) { restoreState(state); if (scriptOne.length() > 0) { replayTerm(scriptOne); if (scriptTwo.length() == 0) { state = null; } return true; } if (scriptTwo.length() > 0) { replayTerm(scriptTwo); state = null; return true; } throw new IllegalStateException("At least one of script one|two should be non empty"); } if (!input.incrementToken()) { return false; } boolean matchesBothScripts = hasChars(translationTable.getScript1Reg()) && hasChars(translationTable.getScript2Reg()); if (matchesBothScripts) { scriptOne.setLength(0); scriptOne.append(termAtt); translationTable.replaceScriptOne(scriptOne); scriptTwo.setLength(0); scriptTwo.append(termAtt); translationTable.replaceScriptTwo(scriptTwo); if (!translationTable.getScript1Reg().matcher(scriptOne).find()) { state = captureState(); } else { scriptOne.setLength(0); } if (!translationTable.getScript2Reg().matcher(scriptTwo).find()) { if (state == null) { state = captureState(); } } else { scriptTwo.setLength(0); } } return true; }
Source:
<code>private String getRepositoryName(String location) { final String[] tokens = location.split(SEPARATOR); return (location.endsWith(GIT_EXTENSION)) <START> ? tokens[4].substring(0, <END> tokens[4].length() - 4) : tokens[4].substring(0); }</code><technical_language>5 tokens. need query</technical_language>

Target:
private String getRepositoryName(String location) { final String[] tokens = location.split(SEPARATOR); if (tokens.length >= 5) return (location.endsWith(GIT_EXTENSION)) ? tokens[4].substring(0, tokens[4].length() - 4) : tokens[4].substring(0); return null; }
Source:
<code>public static ObaRegion get(ContentResolver cr, int id) { final String[] PROJECTION = { _ID, NAME, OBA_BASE_URL, SIRI_BASE_URL, LANGUAGE, CONTACT_EMAIL, SUPPORTS_OBA_DISCOVERY, SUPPORTS_OBA_REALTIME, SUPPORTS_SIRI_REALTIME, SUPPORTS_EMBEDDED_SOCIAL, TWITTER_URL, EXPERIMENTAL, STOP_INFO_URL, OTP_BASE_URL, OTP_CONTACT_EMAIL }; Cursor c = cr.query(buildUri((int) id), PROJECTION, null, null, null); if (c != null) { try { if (c.getCount() == 0) { return null; } c.moveToFirst(); return new ObaRegionElement(id, c.getString(1), true, c.getString(2), c.getString(3), RegionBounds.getRegion(cr, id), RegionOpen311Servers.getOpen311Server(cr, id), c.getString(4), c.getString(5), c.getInt(6) > 0, c.getInt(7) > 0, c.getInt(8) > 0, <START> c.getInt(9) > 0, END> c.getString(10), c.getInt(11) > 0, c.getString(12), c.getString(13), c.getString(14) ); } finally { c.close(); } } return null; }</code><technical_language>embedded social index moved end</technical_language>

Target:
public static ObaRegion get(ContentResolver cr, int id) { final String[] PROJECTION = { _ID, NAME, OBA_BASE_URL, SIRI_BASE_URL, LANGUAGE, CONTACT_EMAIL, SUPPORTS_OBA_DISCOVERY, SUPPORTS_OBA_REALTIME, SUPPORTS_SIRI_REALTIME, TWITTER_URL, EXPERIMENTAL, STOP_INFO_URL, OTP_BASE_URL, OTP_CONTACT_EMAIL, SUPPORTS_OTP_BIKESHARE, SUPPORTS_EMBEDDED_SOCIAL }; Cursor c = cr.query(buildUri((int) id), PROJECTION, null, null, null); if (c != null) { try { if (c.getCount() == 0) { return null; } c.moveToFirst(); return new ObaRegionElement(id, c.getString(1), true, c.getString(2), c.getString(3), RegionBounds.getRegion(cr, id), RegionOpen311Servers.getOpen311Server(cr, id), c.getString(4), c.getString(5), c.getInt(6) > 0, c.getInt(7) > 0, c.getInt(8) > 0, c.getString(9), c.getInt(10) > 0, c.getString(11), c.getString(12), c.getString(13), c.getInt(14) > 0, c.getInt(15) > 0 ); } finally { c.close(); } } return null; }
Source:
<code>public void testChinese() throws IOException, ServletException { CSRFTokenFilter csrfTokenFilter = getFilterForChinese(); csrfTokenFilter.doFilter(req, resp, chain); final Document document = Jsoup.parse(charWriter.toString()); <START> Elements es = document.select("div.center-block"); <END> assertEquals(es.get(1).text(), chinese_loadingPleaseWait); assertEquals(es.get(2).text(), chinese_loadingApplication); }</code><technical_language>expect string parameter in _assertEquals_</technical_language>

Target:
public void testChinese() throws IOException, ServletException { csfrTokenFilterTest("/test-html/sample-Chinese.html", chinese_loadingPleaseWait, chinese_loadingApplication); }
Source:
<code>public Set<Annotation> getQualifiers() { <START> return Collections.singleton( NamedLiteral.of( BeanNames.BEAN_META_DATA_CLASS_NORMALIZER ) ); <END> }</code><technical_language>If this is in request handling path please a constant</technical_language>

Target:
public Set<Annotation> getQualifiers() { return QUALIFIERS; }
Source:
<code>public void testOrderRuleEmpty() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(CustomImportOrderCheck.class); checkConfig.addAttribute("customImportOrderRules", ""); final String[] expected = { "7: " + getCheckMessage(MSG_SEPARATED_IN_GROUP, "java.util.List"), "13: " + getCheckMessage(MSG_SEPARATED_IN_GROUP, "com.puppycrawl.tools.*"), "16: " + getCheckMessage(MSG_SEPARATED_IN_GROUP, "com.google.common.base.*"), }; <START> verify(checkConfig, getPath("InputCustomImportOrderDefault2.java"), expected); <END> }</code><technical_language>try force create Input file for test place config in Input file. example: <LINK_0></technical_language>

Target:
public void testOrderRuleEmpty() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(CustomImportOrderCheck.class); checkConfig.addAttribute("customImportOrderRules", ""); final String[] expected = { "5: " + getCheckMessage(MSG_SEPARATED_IN_GROUP, "java.util.List"), }; verify(checkConfig, getPath("InputCustomImportOrderEmptyRule.java"), expected); }
Source:
<code>public void testPoll() { manager.start(); manager.poll(); Assert.assertEquals( ImmutableList.of("wikipedia"), manager.getAllDatasourceNames() ); Assert.assertEquals( <START> Sets.newHashSet(segment1, segment2), <END> new HashSet<>(manager.getInventoryValue("wikipedia").getSegments()) ); }</code><technical_language>this change</technical_language>

Target:
public void testPoll() { manager.start(); manager.poll(); Assert.assertEquals( ImmutableList.of("wikipedia"), manager.getAllDatasourceNames() ); Assert.assertEquals( ImmutableSet.of(segment1, segment2), ImmutableSet.copyOf(manager.getInventoryValue("wikipedia").getSegments()) ); }
Source:
<code>public DisksContentTypeRadioGroup() { <START> HorizontalPanel panel = new HorizontalPanel(); <END> Label label = new Label(); label.setText(constants.diskContentType()); label.getElement().getStyle().setProperty("marginRight", "10px"); label.getElement().getStyle().setProperty("marginBottom", "4px"); panel.add(label); panel.add(getRadioGroupPanel()); initWidget(panel); }</code><technical_language>Please Horizontal panels for layout</technical_language>

Target:
public DisksContentTypeRadioGroup() { FlowPanel panel = new FlowPanel(); Label label = new Label(); label.setText(constants.diskContentType() + ":"); label.addStyleName("disk-content-type-group-label"); panel.add(label); panel.add(getRadioGroupPanel()); initWidget(panel); }
Source:
<code>public boolean put(PageId pageId, byte[] page) { LOG.debug("put({},{} bytes) enters", pageId, page.length); if (!mAsyncWrite) { boolean inserted = putInternal(pageId, page); if (inserted) { LOG.debug("put({},{} bytes) exits", pageId, page.length); } else { LOG.debug("put({},{} bytes) fails", pageId, page.length); <START> } <END> return inserted; } if (!mPendingRequests.add(pageId)) { return false; } try { mAsyncCacheExecutor.submit(() -> { try { putInternal(pageId, page); } finally { mPendingRequests.remove(pageId); } }); } catch (RejectedExecutionException e) { mPendingRequests.remove(pageId); LOG.debug("put({},{} bytes) fails due to full queue", pageId, page.length); return false; } LOG.debug("put({},{} bytes) exits with async write", pageId, page.length); return true; }</code><technical_language>Simplify this logging a succeeded field</technical_language>

Target:
public boolean put(PageId pageId, byte[] page) { LOG.debug("put({},{} bytes) enters", pageId, page.length); if (!mAsyncWrite) { boolean inserted = putInternal(pageId, page); LOG.debug("put({},{} bytes) exits: {}", pageId, page.length, inserted); return inserted; } if (!mPendingRequests.add(pageId)) { return false; } try { mAsyncCacheExecutor.submit(() -> { try { putInternal(pageId, page); } finally { mPendingRequests.remove(pageId); } }); } catch (RejectedExecutionException e) { mPendingRequests.remove(pageId); Metrics.PUT_ERRORS.inc(); LOG.debug("put({},{} bytes) fails due to full queue", pageId, page.length); return false; } LOG.debug("put({},{} bytes) exits with async write", pageId, page.length); return true; }
Source:
<code><START> public List<DedicatedResourceVO> listAvailableResources(Long accountId, Long... domains) { <END> StringBuilder sql = new StringBuilder("select data_center_id, pod_id, cluster_id, host_id, domain_id, account_id,"); sql.append("affinity_group_id from dedicated_resources where account_id = ? or (account_id IS NULL and domain_id in ("); for(int i = 0; i < domains.length; i++) { if(i == (domains.length - 1)) { sql.append("?));"); } else { sql.append("?, "); } } TransactionLegacy txn = TransactionLegacy.currentTxn(); ArrayList<DedicatedResourceVO> result = new ArrayList<DedicatedResourceVO>(); try(PreparedStatement pstmt = txn.prepareStatement(sql.toString());) { if(accountId != null) { pstmt.setLong(1, accountId); } for (int i = 2; i < (domains.length + 2); i++) { pstmt.setLong(i, domains[i-2]); } try(ResultSet rs = pstmt.executeQuery();) { while(rs.next()) { Long dataCenterId = rs.getLong(1); if(rs.wasNull()) { dataCenterId = null; } Long podId = rs.getLong(2); if(rs.wasNull()) { podId = null; } Long clusterId = rs.getLong(3); if(rs.wasNull()) { clusterId = null; } Long hostId = rs.getLong(4); if(rs.wasNull()) { hostId = null; } Long domainId = rs.getLong(5); if(rs.wasNull()) { domainId = null; } Long tempAccountId = rs.getLong(6); if(rs.wasNull()) { tempAccountId= null; } Long affinityGroupId = rs.getLong(7); result.add(new DedicatedResourceVO(dataCenterId, podId, clusterId, hostId, domainId, tempAccountId, affinityGroupId)); } } catch (Exception e) { s_logger.warn("Exception: ", e); } } catch (Exception e) { s_logger.warn("Exception: ", e); } return result; }</code><technical_language>Please rewrite this standard query builder (SearchBuilder) is in other methods in this class</technical_language>

Target:
public List<DedicatedResourceVO> listAvailableResources(Long accountId, Long... domains) { SearchCriteria<DedicatedResourceVO> sc = ListAvailableResourcesSearch.create(); sc.setParameters("accountId", accountId); sc.setParameters("domainId", domains); return listBy(sc); }
Source:
<code>Map<String, Runnable> getScaleCallBacks() { <START> return callBacks; <END> }</code><technical_language>this return UnmodifiableMap instead of memory manager itself</technical_language>

Target:
Map<String, Runnable> getScaleCallBacks() { return Collections.unmodifiableMap(callBacks); }
Source:
<code>private boolean hasTextDefined(Citation citation) { <START> return citation.getEntry().getRawText()!=null && StringUtils.isNotBlank(citation.getEntry().getRawText().toString()); <END> }</code><technical_language>checking StringUtils.isNotBlank(citation.getEntry().getRawText()) work fine</technical_language>

Target:
private boolean hasTextDefined(Citation citation) { return StringUtils.isNotBlank(citation.getEntry().getRawText()); }
Source:
<code>private static String formatArrayTypeImpl( List<@Nullable ATypeElement> scenelibRepInJavacOrder, ArrayType javacRep) { TypeMirror javacComponent = javacRep.getComponentType(); ATypeElement scenelibRep = scenelibRepInJavacOrder.get(0); ATypeElement scenelibComponent = scenelibRepInJavacOrder.get(1); String result = ""; List<? extends AnnotationMirror> explicitAnnos = javacRep.getAnnotationMirrors(); for (AnnotationMirror explicitAnno : explicitAnnos) { result += explicitAnno.toString(); result += " "; } if ("".equals(result)) { <START> if (scenelibRep != null) { <END> result += formatAnnotations(scenelibRep.tlAnnotationsHere); } } result += "[] "; if (javacComponent.getKind() == TypeKind.ARRAY) { return formatArrayTypeImpl( scenelibRepInJavacOrder.subList(1, scenelibRepInJavacOrder.size()), (ArrayType) javacComponent) + result; } return formatType(scenelibComponent, javacComponent) + result; }</code><technical_language>This nested if-statement merged surrounding if statement. change "".equals(result) result.isEmpty() well</technical_language>

Target:
private static String formatArrayTypeImpl( List<@Nullable ATypeElement> scenelibRepInJavacOrder, ArrayType javacRep) { TypeMirror javacComponent = javacRep.getComponentType(); ATypeElement scenelibRep = scenelibRepInJavacOrder.get(0); ATypeElement scenelibComponent = scenelibRepInJavacOrder.get(1); String result = ""; List<? extends AnnotationMirror> explicitAnnos = javacRep.getAnnotationMirrors(); for (AnnotationMirror explicitAnno : explicitAnnos) { result += explicitAnno.toString(); result += " "; } if (result.isEmpty() && scenelibRep != null) { result += formatAnnotations(scenelibRep.tlAnnotationsHere); } result += "[] "; if (javacComponent.getKind() == TypeKind.ARRAY) { return formatArrayTypeImpl( scenelibRepInJavacOrder.subList(1, scenelibRepInJavacOrder.size()), (ArrayType) javacComponent) + result; } return formatType(scenelibComponent, javacComponent) + result; }
Source:
<code>protected void actionPerformed( final GuiButton btn ) { if( btn == this.craftingStatusBtn ) { NetworkHandler.instance.sendToServer( new PacketSwitchGuis( GuiBridge.GUI_CRAFTING_STATUS ) ); } if( btn instanceof GuiImgButton ) { final boolean backwards = Mouse.isButtonDown( 1 ); final GuiImgButton iBtn = (GuiImgButton) btn; if( iBtn.getSetting() != Settings.ACTIONS ) { final Enum cv = iBtn.getCurrentValue(); final Enum next = Platform.rotateEnum( cv, backwards, iBtn.getSetting().getPossibleValues() ); if( btn == this.terminalStyleBox ) { <START> AEConfig.instance().getConfigManager().putSetting( iBtn.getSetting(), next ); <END> } else if( btn == this.searchBoxSettings ) { AEConfig.instance().getConfigManager().putSetting( iBtn.getSetting(), next ); } else { try { NetworkHandler.instance.sendToServer( new PacketValueConfig( iBtn.getSetting().name(), next.name() ) ); } catch( final IOException e ) { AELog.debug( e ); } } iBtn.set( next ); if( next.getClass() == SearchBoxMode.class || next.getClass() == TerminalStyle.class ) { this.reinitalize(); } } } }</code><technical_language>![MAJOR](<LINK_0> Method appeng.client.gui.implementations.GuiMEMonitorable.actionPerformed(GuiButton) appears call method object redundantly [![rule](<LINK_1>](<LINK_2></technical_language>

Target:
protected void actionPerformed( final GuiButton btn ) { if( btn == this.craftingStatusBtn ) { NetworkHandler.instance().sendToServer( new PacketSwitchGuis( GuiBridge.GUI_CRAFTING_STATUS ) ); } if( btn instanceof GuiImgButton ) { final boolean backwards = Mouse.isButtonDown( 1 ); final GuiImgButton iBtn = (GuiImgButton) btn; if( iBtn.getSetting() != Settings.ACTIONS ) { final Enum cv = iBtn.getCurrentValue(); final Enum next = Platform.rotateEnum( cv, backwards, iBtn.getSetting().getPossibleValues() ); if( btn == this.terminalStyleBox ) { AEConfig.instance().getConfigManager().putSetting( iBtn.getSetting(), next ); } else if( btn == this.searchBoxSettings ) { AEConfig.instance().getConfigManager().putSetting( iBtn.getSetting(), next ); } else { try { NetworkHandler.instance().sendToServer( new PacketValueConfig( iBtn.getSetting().name(), next.name() ) ); } catch( final IOException e ) { AELog.debug( e ); } } iBtn.set( next ); if( next.getClass() == SearchBoxMode.class || next.getClass() == TerminalStyle.class ) { this.reinitalize(); } } } }
Source:
<code>InvalidSessionStrategy getInvalidSessionStrategy() { if (this.invalidSessionStrategy != null) { return this.invalidSessionStrategy; } if (this.invalidSessionUrl != null) { this.invalidSessionStrategy = new SimpleRedirectInvalidSessionStrategy( this.invalidSessionUrl); } <START> return this.invalidSessionStrategy; <END> }</code><technical_language>@OrangeDog Thanks for this. a getExpiredSessionStrategy below, opportunity for cleanup well. of making methods same, like: java if (strategy != null) { return strategy; } if (url == null) { return null; } strategy = // get default strategy return strategy; I this get rid of dead branches if statement simple</technical_language>

Target:
InvalidSessionStrategy getInvalidSessionStrategy() { if (this.invalidSessionStrategy != null) { return this.invalidSessionStrategy; } if (this.invalidSessionUrl == null) { return null; } this.invalidSessionStrategy = new SimpleRedirectInvalidSessionStrategy( this.invalidSessionUrl); return this.invalidSessionStrategy; }
Source:
<code>public boolean stop(String name) { List<Binding<Object>> inputBindings = BindingsEndpoint.this.gatherInputBindings(); for (Binding<Object> binding : inputBindings) { String bindingName = binding.getName(); if (name.equals(bindingName)) { <START> binding.unbind(); <END> } } return true; }</code><technical_language>return true (not if more binding name) false in end of method is stop? consider implement this logic Java Stream</technical_language>

Target:
public boolean stop(String name) { List<Binding<Object>> inputBindings = BindingsEndpoint.this.gatherInputBindings(); for (Binding<Object> binding : inputBindings) { if (name.equals(binding.getName())) { binding.stop(); return true; } } return false; }
Source:
<code>public void init() { if (isInitialized.compareAndSet(false, true)) { LOG.info("Starting the coordinator stream system consumer with config: {}.", config); registerConsumer(); systemConsumer.start(); systemProducer.register(SOURCE); systemProducer.start(); Runtime.getRuntime().addShutdownHook(new Thread(() -> { LOG.info("CoordinatorStreamStore Shut Down Hook thread is closing kafka clients"); <START> this.systemProducer.stop(); <END> this.systemConsumer.stop(); this.systemAdmin.stop(); })); iterator = new SystemStreamPartitionIterator(systemConsumer, coordinatorSystemStreamPartition); readMessagesFromCoordinatorStream(); } else { LOG.info("Store had already been initialized. Skipping.", coordinatorSystemStreamPartition); } }</code><technical_language>do this.close()</technical_language>

Target:
public void init() { if (isInitialized.compareAndSet(false, true)) { LOG.info("Starting the coordinator stream system consumer with config: {}.", config); registerConsumer(); systemConsumer.start(); systemProducer.register(SOURCE); systemProducer.start(); iterator = new SystemStreamPartitionIterator(systemConsumer, coordinatorSystemStreamPartition); readMessagesFromCoordinatorStream(); } else { LOG.info("Store had already been initialized. Skipping.", coordinatorSystemStreamPartition); } }
Source:
<code><T> Mono<PagedResponse<T>> listRelationshipsFirstPage(String digitalTwinId, String relationshipName, Class<T> clazz, Context context) { return protocolLayer .getDigitalTwins() .listRelationshipsSinglePageAsync(digitalTwinId, relationshipName, context) .map( objectPagedResponse -> { List<T> list = objectPagedResponse.getValue().stream() .map(object -> { try { return DeserializationHelpers.castObject(mapper, object, clazz); } catch (JsonProcessingException e) { <START> logger.error("JsonProcessingException occurred while retrieving relationships: ", e); <END> throw new RuntimeException("JsonProcessingException occurred while retrieving relationships", e); } }) .filter(Objects::nonNull) .collect(Collectors.toList()); return new PagedResponseBase<>( objectPagedResponse.getRequest(), objectPagedResponse.getStatusCode(), objectPagedResponse.getHeaders(), list, SerializationHelpers.serializeContinuationToken(objectPagedResponse.getContinuationToken()), ((PagedResponseBase) objectPagedResponse).getDeserializedHeaders()); } ); }</code><technical_language>exception is deserialization, highlight (it occur REST operation)</technical_language>

Target:
<T> Mono<PagedResponse<T>> listRelationshipsFirstPage(String digitalTwinId, String relationshipName, Class<T> clazz, Context context) { return protocolLayer .getDigitalTwins() .listRelationshipsSinglePageAsync(digitalTwinId, relationshipName, context) .map( objectPagedResponse -> { List<T> list = objectPagedResponse.getValue().stream() .map(object -> { try { return DeserializationHelpers.castObject(mapper, object, clazz); } catch (JsonProcessingException e) { logger.error("JsonProcessingException occurred while deserializing the list relationship response: ", e); throw new RuntimeException("JsonProcessingException occurred while deserializing the list relationship response", e); } }) .filter(Objects::nonNull) .collect(Collectors.toList()); return new PagedResponseBase<>( objectPagedResponse.getRequest(), objectPagedResponse.getStatusCode(), objectPagedResponse.getHeaders(), list, SerializationHelpers.serializeContinuationToken(objectPagedResponse.getContinuationToken()), ((PagedResponseBase) objectPagedResponse).getDeserializedHeaders()); } ); }
Source:
<code>public void testCreateViewWithMatchRecognize() { Map<String, String> prop = new HashMap<>(); <START> prop.put("connector", "datagen"); <END> prop.put("number-of-rows", "10"); CatalogTableImpl catalogTable = new CatalogTableImpl( TableSchema.builder() .field("id", DataTypes.INT().notNull()) .field("measurement", DataTypes.BIGINT().notNull()) .field("ts", DataTypes.ROW(DataTypes.FIELD("tmstmp", DataTypes.TIMESTAMP(3)))) .build(), prop, null ); catalogManager.createTable( catalogTable, ObjectIdentifier.of("builtin", "default", "events"), false); final String sql = "" + "CREATE TEMPORARY VIEW foo AS " + "SELECT * " + "FROM events MATCH_RECOGNIZE (" + " PARTITION BY id " + " ORDER BY ts ASC " + " MEASURES " + " next_step.measurement - this_step.measurement AS diff " + " AFTER MATCH SKIP TO NEXT ROW " + " PATTERN (this_step next_step)" + " DEFINE " + " this_step AS TRUE," + " next_step AS TRUE" + ")"; Operation operation = parse(sql, SqlDialect.DEFAULT); assertThat(operation, instanceOf(CreateViewOperation.class)); }</code><technical_language>nit: values instead of datagen, datagen is intended for testing I</technical_language>

Target:
public void testCreateViewWithMatchRecognize() { Map<String, String> prop = new HashMap<>(); prop.put("connector", "values"); prop.put("bounded", "true"); CatalogTableImpl catalogTable = new CatalogTableImpl( TableSchema.builder() .field("id", DataTypes.INT().notNull()) .field("measurement", DataTypes.BIGINT().notNull()) .field("ts", DataTypes.ROW(DataTypes.FIELD("tmstmp", DataTypes.TIMESTAMP(3)))) .build(), prop, null ); catalogManager.createTable( catalogTable, ObjectIdentifier.of("builtin", "default", "events"), false); final String sql = "" + "CREATE TEMPORARY VIEW foo AS " + "SELECT * " + "FROM events MATCH_RECOGNIZE (" + " PARTITION BY id " + " ORDER BY ts ASC " + " MEASURES " + " next_step.measurement - this_step.measurement AS diff " + " AFTER MATCH SKIP TO NEXT ROW " + " PATTERN (this_step next_step)" + " DEFINE " + " this_step AS TRUE," + " next_step AS TRUE" + ")"; Operation operation = parse(sql, SqlDialect.DEFAULT); assertThat(operation, instanceOf(CreateViewOperation.class)); }
Source:
<code>private Map<String, Name> computeImports(DataSchema schema, String rootNamespace) { Set<Name> encounteredTypes = new HashSet<>(); <START> Set<String> typeNamesWithSimpleReference = new HashSet<>(); <END> gatherTypes(schema, true, encounteredTypes, typeNamesWithSimpleReference, rootNamespace); return encounteredTypes .stream() .filter(name -> !name.getNamespace().equals(rootNamespace) && !typeNamesWithSimpleReference.contains(name.getName())) .collect(Collectors.toMap( Name::getName, Function.identity(), (Name nameA, Name nameB) -> nameA.compareTo(nameB) < 0 ? nameA : nameB )); }</code><technical_language>name this nonImportableTypeNames consistent</technical_language>

Target:
private Map<String, Name> computeImports(DataSchema schema, String rootNamespace) { Set<Name> encounteredTypes = new HashSet<>(); Set<String> nonImportableTypeNames = new HashSet<>(); gatherTypes(schema, true, encounteredTypes, nonImportableTypeNames, rootNamespace); return encounteredTypes .stream() .filter(name -> !name.getNamespace().equals(rootNamespace) && !nonImportableTypeNames.contains(name.getName())) .collect(Collectors.toMap( Name::getName, Function.identity(), (Name nameA, Name nameB) -> nameA.compareTo(nameB) < 0 ? nameA : nameB )); }
Source:
<code>public static boolean createMerc(SolGame game, SolShip hero, MercItem mercItem) { ShipConfig config = mercItem.getConfig(); <START> Guardian dp = new Guardian(game, config.hull, hero.getPilot(), hero.getPosition(), hero.getHull().config, SolMath.rnd(180)); <END> AiPilot pilot = new AiPilot(dp, true, Faction.LAANI, false, "Merc", Const.AI_DET_DIST); Vector2 pos = getPos(game, hero, config.hull); if (pos == null) { return false; } SolShip merc = game.getShipBuilder().buildNewFar(game, pos, new Vector2(), 0, 0, pilot, config.items, config.hull, null, true, config.money, null, true) .toObj(game); merc.setMerc(mercItem); mercItem.setSolShip(merc); game.getHero().getTradeContainer().getMercs().add(mercItem); game.getObjMan().addObjNow(game, merc); return true; }</code><technical_language>dp .</technical_language>

Target:
public static boolean createMerc(SolGame game, SolShip hero, MercItem mercItem) { ShipConfig config = mercItem.getConfig(); Guardian guardian = new Guardian(game, config.hull, hero.getPilot(), hero.getPosition(), hero.getHull().config, SolMath.rnd(180)); AiPilot pilot = new AiPilot(guardian, true, Faction.LAANI, false, "Merc", Const.AI_DET_DIST); Vector2 pos = getPos(game, hero, config.hull); if (pos == null) { return false; } SolShip merc = game.getShipBuilder().buildNewFar(game, pos, new Vector2(), 0, 0, pilot, config.items, config.hull, null, true, config.money, null, true) .toObj(game); merc.setMerc(mercItem); mercItem.setSolShip(merc); game.getHero().getTradeContainer().getMercs().add(mercItem); game.getObjMan().addObjNow(game, merc); return true; }
Source:
<code>public boolean isPropertySet(Property prop, boolean cacheAndWatch) { if (fixedProps.containsKey(prop.getKey())) { return true; } if (cacheAndWatch) { if (getRaw(prop.getKey()) != null) { return true; } } else { ZooReader zr = context.getZooReaderWriter(); String zPath = propPathPrefix + "/" + prop.getKey(); try { if (zr.exists(zPath) && zr.getData(zPath, null) != null) { return true; } } catch (KeeperException|InterruptedException e) { <START> throw new RuntimeException(e); <END> } } return parent.isPropertySet(prop, cacheAndWatch); }</code><technical_language>I generally prefer a more specific RTE parent class. IllegalStateException UncheckedIOException appropriate</technical_language>

Target:
public boolean isPropertySet(Property prop, boolean cacheAndWatch) { if (fixedProps.containsKey(prop.getKey())) { return true; } if (cacheAndWatch) { if (getRaw(prop.getKey()) != null) { return true; } } else { ZooReader zr = context.getZooReaderWriter(); String zPath = propPathPrefix + "/" + prop.getKey(); try { if (zr.exists(zPath)) { return true; } } catch (KeeperException|InterruptedException e) { throw new IllegalStateException(e); } } return parent.isPropertySet(prop, cacheAndWatch); }
Source:
<code>public void testRegexProxyChainWithInvalidProxy() throws TicketValidationException, UnsupportedEncodingException { final List<String[]> list = new ArrayList<String[]>(); list.add(new String[] { "proxy1", "proxy2", "^proxy3/[a-z]*/" }); this.ticketValidator.setAllowedProxyChains(new ProxyList(list)); <START> final String RESPONSE = "<cas:serviceResponse xmlns:cas='<LINK_0>'><cas:authenticationSuccess><cas:user>username</cas:user><cas:proxyGrantingTicket>PGTIOU-84678-8a9d...</cas:proxyGrantingTicket><cas:proxies><cas:proxy>proxy/ABC/</cas:proxy><cas:proxy>proxy2</cas:proxy><cas:proxy>proxy3</cas:proxy></cas:proxies></cas:authenticationSuccess></cas:serviceResponse>"; <END> server.content = RESPONSE.getBytes(server.encoding); try { this.ticketValidator.validate("test", "test"); fail("Invalid proxy chain"); } catch (InvalidProxyChainTicketValidationException e) { } }</code><technical_language>lets break this line a part multiple ones</technical_language>

Target:
public void testRegexProxyChainWithInvalidProxy() throws TicketValidationException, UnsupportedEncodingException { final List<String[]> list = new ArrayList<String[]>(); list.add(new String[] { "proxy1", "proxy2", "^proxy3/[a-z]*/" }); this.ticketValidator.setAllowedProxyChains(new ProxyList(list)); final String RESPONSE = "<cas:serviceResponse xmlns:cas='<LINK_0>'><cas:authenticationSuccess><cas:user>username</cas:user><cas:proxyGrantingTicket>PGTIOU-84678-8a9d...</cas:proxyGrantingTicket><cas:proxies><cas:proxy>proxy1</cas:proxy><cas:proxy>proxy2</cas:proxy><cas:proxy>proxy3/ABC/</cas:proxy></cas:proxies></cas:authenticationSuccess></cas:serviceResponse>"; server.content = RESPONSE.getBytes(server.encoding); try { this.ticketValidator.validate("test", "test"); fail("Invalid proxy chain"); } catch (InvalidProxyChainTicketValidationException e) { } }
Source:
<code><START> public DamagedItemDefinition( @Nonnull IStackSrc source ) <END> { this.source = source; }</code><technical_language>add assert other definitions it</technical_language>

Target:
public DamagedItemDefinition( @Nonnull IStackSrc source ) { this.source = Preconditions.checkNotNull( source ); }
Source:
<code>private void resizePVs(List<String> lunsToRefresh) { for (String lun : lunsToRefresh) { Long pvSizeInBytes = resizePV(lun); <START> log.debug("PV size after resize of LUN " + lun + " :" + pvSizeInBytes + " bytes"); <END> } }</code><technical_language>Consider carly bracket</technical_language>

Target:
private void resizePVs(List<String> lunsToRefresh) { for (String lun : lunsToRefresh) { Long pvSizeInBytes = resizeStorageDomainPV(lun); log.debug("PV size after resize of LUN " + lun + " :" + pvSizeInBytes + " bytes"); } }
Source:
<code>private void updateTaskWithIncomingReviewState(ITask task, boolean hasIncomingReviews) { <START> task.setAttribute(ReviewsCoreConstants.INCOMING_REVIEW_STATE, hasIncomingReviews ? "true" : "false"); END> }</code><technical_language>Boolean.toString</technical_language>

Target:
private void updateTaskWithIncomingReviewState(ITask task, boolean hasIncomingReviews) { task.setAttribute(ReviewsCoreConstants.INCOMING_REVIEW_STATE, Boolean.toString(hasIncomingReviews)); }
Source:
<code><START> public OpenShiftEnvironment( <END> InternalRecipe internalRecipe, Map<String, InternalMachineConfig> machines, List<Warning> warnings, Map<String, Pod> pods, Map<String, Service> services, Map<String, Ingress> ingresses, Map<String, PersistentVolumeClaim> pvcs, Map<String, Secret> secrets, Map<String, ConfigMap> configMaps, Map<String, Route> routes) { super(internalRecipe, machines, warnings, pods, services, ingresses, pvcs, secrets, configMaps); this.routes = routes; setType(TYPE); }</code><technical_language>consider adding constructor passes k8s environment instead of internal</technical_language>

Target:
public OpenShiftEnvironment( InternalRecipe internalRecipe, Map<String, InternalMachineConfig> machines, List<Warning> warnings, Map<String, Pod> pods, Map<String, Service> services, Map<String, Ingress> ingresses, Map<String, PersistentVolumeClaim> pvcs, Map<String, Secret> secrets, Map<String, ConfigMap> configMaps, Map<String, Route> routes) { super(internalRecipe, machines, warnings, pods, services, ingresses, pvcs, secrets, configMaps); setType(TYPE); this.routes = routes; }
Source:
<code>private AuthenticationResult tryAcquireTokenSilentLocally(final AuthenticationRequest authenticationRequest) throws AuthenticationException { Logger.v(TAG, "Try to silently get token from local cache."); final AcquireTokenSilentHandler acquireTokenSilentHandler = new AcquireTokenSilentHandler(mContext, authenticationRequest, mTokenCacheAccessor); <START> if(mAuthContext.getExtendedLifetimeEnabled()) { <END> acquireTokenSilentHandler.setOutageModeIsOn(true); } final AuthenticationResult authResult; try { authResult = acquireTokenSilentHandler.getAccessToken(); } catch (final AuthenticationException authenticationException) { ClientAnalytics.logEvent(new RefreshTokenEvent( new InstrumentationPropertiesBuilder(authenticationRequest, authenticationException), InstrumentationIDs.EVENT_RESULT_FAIL)); throw authenticationException; } return authResult; }</code><technical_language>space if</technical_language>

Target:
private AuthenticationResult tryAcquireTokenSilentLocally(final AuthenticationRequest authenticationRequest) throws AuthenticationException { Logger.v(TAG, "Try to silently get token from local cache."); final AcquireTokenSilentHandler acquireTokenSilentHandler = new AcquireTokenSilentHandler(mContext, authenticationRequest, mTokenCacheAccessor); final AuthenticationResult authResult; try { authResult = acquireTokenSilentHandler.getAccessToken(); } catch (final AuthenticationException authenticationException) { ClientAnalytics.logEvent(new RefreshTokenEvent( new InstrumentationPropertiesBuilder(authenticationRequest, authenticationException), InstrumentationIDs.EVENT_RESULT_FAIL)); throw authenticationException; } return authResult; }
Source:
<code>public void testExpiredRequestAllocationOnAnyHost() throws Exception { MockClusterResourceManager spyManager = spy(new MockClusterResourceManager(callback, state)); spyAllocator = Mockito.spy(new ContainerAllocator(spyManager, config, state, true, Optional.empty())); spyAllocator.requestResources(new HashMap<String, String>() { { put("0", "abc"); put("1", "def"); } }); spyAllocatorThread = new Thread(spyAllocator); spyAllocatorThread.start(); Thread.sleep(10); assertTrue(state.preferredHostRequests.get() == 2); assertTrue(state.expiredPreferredHostRequests.get() == 2); <START> verify(spyAllocator, times(1)).handleExpiredRequest(eq("0"), eq("abc"), <END> any(SamzaResourceRequest.class)); verify(spyAllocator, times(1)).handleExpiredRequest(eq("1"), eq("def"), any(SamzaResourceRequest.class)); ArgumentCaptor<SamzaResourceRequest> cancelledRequestCaptor = ArgumentCaptor.forClass(SamzaResourceRequest.class); verify(spyManager, atLeast(2)).cancelResourceRequest(cancelledRequestCaptor.capture()); assertTrue(cancelledRequestCaptor.getAllValues().stream().map(resourceRequest -> resourceRequest.getPreferredHost()).collect( Collectors.toSet()).size() > 2); assertTrue(state.matchedResourceRequests.get() == 0); assertTrue(state.anyHostRequests.get() > 2); containerAllocator.stop(); }</code><technical_language>%s/abc/hostname-0/g %s/def/hostname-1/g</technical_language>

Target:
public void testExpiredRequestAllocationOnAnyHost() throws Exception { MockClusterResourceManager spyManager = spy(new MockClusterResourceManager(callback, state)); spyAllocator = Mockito.spy(new ContainerAllocator(spyManager, config, state, true, Optional.empty())); spyAllocator.requestResources(new HashMap<String, String>() { { put("0", "hostname-0"); put("1", "hostname-1"); } }); spyAllocatorThread = new Thread(spyAllocator); spyAllocatorThread.start(); Thread.sleep(10); assertTrue(state.preferredHostRequests.get() == 2); assertTrue(state.expiredPreferredHostRequests.get() == 2); verify(spyAllocator, times(1)).handleExpiredRequest(eq("0"), eq("hostname-0"), any(SamzaResourceRequest.class)); verify(spyAllocator, times(1)).handleExpiredRequest(eq("1"), eq("hostname-1"), any(SamzaResourceRequest.class)); ArgumentCaptor<SamzaResourceRequest> cancelledRequestCaptor = ArgumentCaptor.forClass(SamzaResourceRequest.class); verify(spyManager, atLeast(2)).cancelResourceRequest(cancelledRequestCaptor.capture()); assertTrue(cancelledRequestCaptor.getAllValues().stream().map(resourceRequest -> resourceRequest.getPreferredHost()).collect( Collectors.toSet()).size() > 2); assertTrue(state.matchedResourceRequests.get() == 0); assertTrue(state.anyHostRequests.get() > 2); containerAllocator.stop(); }
Source:
<code>public void deactivate() { <START> expr = null; <END> }</code><technical_language>need of this.</technical_language>

Target:
public void deactivate() { }
Source:
<code><START> public Event getEvent() { <END> return event; }</code><technical_language>remove public</technical_language>

Target:
Event getEvent() { return event; }
Source:
<code>public void setTouchEnabled(boolean enabled) { if (enabled) { webView.loadUrl("javascript:setTouchEnabled(true);"); } else { webView.loadUrl("javascript:setTouchEnabled(false);"); <START> } <END> }</code><technical_language>Similar above: java webView.loadUrl("javascript:setTouchEnabled(" + enabled + ");");</technical_language>

Target:
public void setTouchEnabled(boolean enabled) { webView.loadUrl("javascript:setTouchEnabled(" + enabled + ");"); }
Source:
<code>private static WorkspaceConfigDto asDto(UsersWorkspaceImpl workspace, String projectPath) throws ConflictException { final List<CommandDto> commands = workspace.getCommands() .stream() .map(DtoConverter::asDto) .collect(toList()); Predicate<ProjectConfigImpl> predicate = new Predicate<ProjectConfigImpl>() { @Override public boolean test(ProjectConfigImpl projectConfig) { if (projectPath != null) { <START> if (!projectConfig.getPath().equals(projectPath)) { <END> return false; } } return projectConfig.getSource() != null && projectConfig.getSource().getType() != null && !projectConfig.getSource().getType().isEmpty() && projectConfig.getSource().getLocation() != null && !projectConfig.getSource().getLocation().isEmpty(); } }; final List<ProjectConfigDto> projects = workspace.getProjects() .stream() .filter(predicate) .map(DtoConverter::asDto) .collect(toList()); if (projects.isEmpty()) { throw new ConflictException( "Unable to create factory from this workspace, because it does not contains projects with source storage set and/or specified path"); } final Map<String, EnvironmentDto> environments = workspace.getEnvironments() .values() .stream() .collect(toMap(EnvironmentStateImpl::getName, FactoryService::asDto)); return DtoFactory.newDto(WorkspaceConfigDto.class) .withName(workspace.getName()) .withDefaultEnvName(workspace.getDefaultEnvName()) .withCommands(commands) .withProjects(projects) .withEnvironments(environments) .withDescription(workspace.getDescription()) .withAttributes(workspace.getAttributes()); }</code><technical_language>For reason double if</technical_language>

Target:
private static WorkspaceConfigDto asDto(UsersWorkspaceImpl workspace, String projectPath) throws ConflictException { final List<CommandDto> commands = workspace.getCommands() .stream() .map(DtoConverter::asDto) .collect(toList()); Predicate<ProjectConfigImpl> predicate = new Predicate<ProjectConfigImpl>() { @Override public boolean test(ProjectConfigImpl projectConfig) { if (projectPath != null && !projectConfig.getPath().equals(projectPath)) { return false; } return projectConfig.getSource() != null && !isNullOrEmpty(projectConfig.getSource().getType()) && !isNullOrEmpty(projectConfig.getSource().getLocation()); } }; final List<ProjectConfigDto> projects = workspace.getProjects() .stream() .filter(predicate) .map(DtoConverter::asDto) .collect(toList()); if (projects.isEmpty()) { throw new ConflictException( "Unable to create factory from this workspace, because it does not contains projects with source storage set and/or specified path"); } final Map<String, EnvironmentDto> environments = workspace.getEnvironments() .values() .stream() .collect(toMap(EnvironmentStateImpl::getName, FactoryService::asDto)); return newDto(WorkspaceConfigDto.class) .withName(workspace.getName()) .withDefaultEnvName(workspace.getDefaultEnvName()) .withCommands(commands) .withProjects(projects) .withEnvironments(environments) .withDescription(workspace.getDescription()) .withAttributes(workspace.getAttributes()); }