auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public void testQueryType() throws IllegalArgumentException, IllegalAccessException { <START> assertNotSame(VdcQueryType.Unknown, TestHelperQueriesCommandType.getQueryTypeFieldValue(query)); <END> }</code><technical_language>add a message stating query in enum, easier understand failure means</technical_language>

Target:
public void testQueryType() throws IllegalArgumentException, IllegalAccessException { assertNotSame("The query can't be found in the enum VdcQueryType", VdcQueryType.Unknown, TestHelperQueriesCommandType.getQueryTypeFieldValue(query)); }
Source:
<code>public static ThirdPartyContext multitenant(String name) { <START> checkNotNull(name); <END> return newContext(name, true); }</code><technical_language>check for empty string too, please</technical_language>

Target:
public static ThirdPartyContext multitenant(String name) { return newContext(name, true); }
Source:
<code>public void testMaxspeed() { ReaderWay osmWay = new ReaderWay(0); osmWay.setTag("highway", "primary"); osmWay.setTag("maxspeed", "10"); long flags = encoder.handleWayTags(osmWay, 1, 0); EdgeIteratorState edge = GHUtility.createMockedEdgeIteratorState(0, flags); assertEquals(10, encoder.getMaxspeed(edge, motorVehicleInt, false), .1); assertEquals(10, encoder.getMaxspeed(edge, motorVehicleInt, true), .1); osmWay = new ReaderWay(0); <START> osmWay.setTag("highway", "primary"); <END> osmWay.setTag("maxspeed:forward", "10"); flags = encoder.handleWayTags(osmWay, 1, 0); edge = GHUtility.createMockedEdgeIteratorState(0, flags); assertEquals(10, encoder.getMaxspeed(edge, motorVehicleInt, false), .1); assertEquals(-1, encoder.getMaxspeed(edge, motorVehicleInt, true), .1); }</code><technical_language>revert this removal ..</technical_language>

Target:
public void testMaxspeed() { ReaderWay osmWay = new ReaderWay(0); osmWay.setTag("highway", "primary"); osmWay.setTag("maxspeed", "10"); long flags = encoder.handleWayTags(osmWay, 1, 0); EdgeIteratorState edge = GHUtility.createMockedEdgeIteratorState(0, flags); assertEquals(10, encoder.getMaxspeed(edge, motorVehicleInt, false), .1); assertEquals(10, encoder.getMaxspeed(edge, motorVehicleInt, true), .1); osmWay = new ReaderWay(0); osmWay.setTag("highway", "primary"); osmWay.setTag("maxspeed:forward", "10"); flags = encoder.handleWayTags(osmWay, 1, 0); edge = GHUtility.createMockedEdgeIteratorState(0, flags); assertEquals(10, encoder.getMaxspeed(edge, motorVehicleInt, false), .1); assertEquals(-1, encoder.getMaxspeed(edge, motorVehicleInt, true), .1); osmWay = new ReaderWay(0); osmWay.setTag("highway", "primary"); osmWay.setTag("maxspeed:forward", "50"); osmWay.setTag("maxspeed:backward", "50"); osmWay.setTag("maxspeed", "60"); flags = encoder.handleWayTags(osmWay, 1, 0); edge = GHUtility.createMockedEdgeIteratorState(0, flags); assertEquals(50, encoder.getMaxspeed(edge, motorVehicleInt, false), .1); assertEquals(50, encoder.getMaxspeed(edge, motorVehicleInt, true), .1); }
Source:
<code><START> public static FailureItem of(FailureReason reason, String message, Map<String, String> attributes) { <END> ArgChecker.notNull(reason, "reason"); ArgChecker.notEmpty(message, "message"); String stackTrace = localGetStackTraceAsString(message, 1); return new FailureItem(reason, message, attributes, stackTrace, null); }</code><technical_language>thoughts including this method. I confusing. if user includes named placeholders in message? expect attribute values substituted? Also, for symmetry expect attribute map added other factory methods. simple get rid of a case for now. add if need to. P.S. for changing mind</technical_language>

Target:
private static FailureItem of(FailureReason reason, String message, Map<String, String> attributes) { ArgChecker.notNull(reason, "reason"); ArgChecker.notEmpty(message, "message"); String stackTrace = localGetStackTraceAsString(message, 1); return new FailureItem(reason, message, attributes, stackTrace, null); }
Source:
<code>public void testBasicRoundTrip() { byte[] serialized = serialize(kryo, UnicodeBlock.UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS); try { assertSame(deserialize(kryo, serialized, UnicodeBlock.class), UnicodeBlock.UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS); <START> } catch (NullPointerException e) { <END> e.printStackTrace(); throw e; } }</code><technical_language>removed now</technical_language>

Target:
public void testBasicRoundTrip() { byte[] serialized = serialize(kryo, UnicodeBlock.UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS); assertSame(deserialize(kryo, serialized, UnicodeBlock.class), UnicodeBlock.UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS); }
Source:
<code>@Override public boolean equals( Object o ) { if ( this == o ) { return true; } if ( !( o instanceof HazelcastConfiguration ) ) { return false; } HazelcastConfiguration that = (HazelcastConfiguration) o; return replicationFactor == that.replicationFactor && port == that.port && server == that.server && Objects.equals( hazelcastSeedNodes, that.hazelcastSeedNodes ) && Objects.equals( instanceName, that.instanceName ) && Objects.equals( group, that.group ) && Objects.equals( password, that.password ) && <START> Objects.equals( scheduledExecutors, that.scheduledExecutors ); <END> }</code><technical_language>is this missing a durableExecutors equality check</technical_language>

Target:
@Override public boolean equals( Object o ) { if ( this == o ) { return true; } if ( !( o instanceof HazelcastConfiguration ) ) { return false; } HazelcastConfiguration that = (HazelcastConfiguration) o; return replicationFactor == that.replicationFactor && port == that.port && server == that.server && Objects.equals( hazelcastSeedNodes, that.hazelcastSeedNodes ) && Objects.equals( instanceName, that.instanceName ) && Objects.equals( group, that.group ) && Objects.equals( password, that.password ) && Objects.equals( scheduledExecutors, that.scheduledExecutors ) && Objects.equals( cpMemberCount, that.cpMemberCount ) && Objects.equals( durableExecutors, that.durableExecutors ); }
Source:
<code>public Map<String, String> getJobMessageProperties() { if (jobProperties == null) { <START> jobProperties = super.getJobMessageProperties(); <END> jobProperties.put(GlusterConstants.VOLUME, getParameters().getVolume().getName()); } return jobProperties; }</code><technical_language>is default implementation of this method super - i adding implementation GlusterCommandBase ease code reading performs precise action wish (in this case adding cluster name map querying vds_groups table). Note this is part of current patch added affecting this patch</technical_language>

Target:
public Map<String, String> getJobMessageProperties() { if (volume != null) { if (jobProperties == null) { jobProperties = super.getJobMessageProperties(); } jobProperties.put(GlusterConstants.VOLUME, volume.getName()); } return jobProperties; }
Source:
<code>public void putEvent(JsonRpcEvent event) { try (LockWrapper wrapper = new LockWrapper(this.lock)) { <START> event.setCreationTime(LocalTime.now().minusMinutes(1)); <END> this.events.addFirst(event); purgeOldEventsIfNotConsumed(); } }</code><technical_language>This is fragile approach. Please monotonic time I change System.nanoTime()</technical_language>

Target:
public void putEvent(JsonRpcEvent event) { try (LockWrapper wrapper = new LockWrapper(this.lock)) { event.setCreationTime(System.nanoTime()); this.events.addFirst(event); } }
Source:
<code>private PendingIntent createPendingIntent(@PlaybackStateCompat.Actions long action) { int keyCode = PlaybackStateCompat.toKeyCode(action); Intent intent = new Intent(Intent.ACTION_MEDIA_BUTTON); <START> intent.setComponent(new ComponentName( mServiceInstance.getPackageName(), mServiceInstance.getClass().getCanonicalName())); <END> intent.putExtra(Intent.EXTRA_KEY_EVENT, new KeyEvent(KeyEvent.ACTION_DOWN, keyCode)); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && keyCode == KEYCODE_MEDIA_PLAY) { return PendingIntent.getForegroundService( mServiceInstance, keyCode , intent, 0 ); } else { return PendingIntent.getService( mServiceInstance, keyCode , intent, 0 ); } }</code><technical_language>new ComponentName(mServiceInstance, mServiceInstance.getClass()) easier</technical_language>

Target:
private PendingIntent createPendingIntent(@PlaybackStateCompat.Actions long action) { int keyCode = PlaybackStateCompat.toKeyCode(action); Intent intent = new Intent(Intent.ACTION_MEDIA_BUTTON); intent.setComponent(new ComponentName(mServiceInstance, mServiceInstance.getClass())); intent.putExtra(Intent.EXTRA_KEY_EVENT, new KeyEvent(KeyEvent.ACTION_DOWN, keyCode)); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && action != ACTION_PAUSE) { return PendingIntent.getForegroundService( mServiceInstance, keyCode , intent, 0 ); } else { return PendingIntent.getService( mServiceInstance, keyCode , intent, 0 ); } }
Source:
<code>private boolean parseUrl( JsonQueryProcessorState state, CharSequence keepAliveHeader ) throws PeerDisconnectedException, PeerIsSlowToReadException { final HttpRequestHeader header = state.getHttpConnectionContext().getRequestHeader(); final DirectByteCharSequence query = header.getUrlParam("query"); if (query == null || query.length() == 0) { state.info().$("Empty query header received. Sending empty reply.").$(); sendException(state.getHttpConnectionContext().getChunkedResponseSocket(), 0, "No query text", 400, query, keepAliveHeader); return false; } long skip = 0; long stop = Long.MAX_VALUE; CharSequence limit = header.getUrlParam("limit"); if (limit != null) { int sepPos = Chars.indexOf(limit, ','); try { if (sepPos > 0) { skip = Numbers.parseLong(limit, 0, sepPos) - 1; if (sepPos + 1 < limit.length()) { stop = Numbers.parseLong(limit, sepPos + 1, limit.length()); } } else { stop = Numbers.parseLong(limit); } } catch (NumericException ex) { } } if (stop < 0) { stop = 0; } if (skip < 0) { skip = 0; } <START> if (configuration.getMaxQueryResponseRowLimit() != Long.MAX_VALUE && (stop - skip) > configuration.getMaxQueryResponseRowLimit()) { <END> stop = skip + configuration.getMaxQueryResponseRowLimit(); } try { state.configure(header, query, skip, stop); } catch (Utf8Exception e) { state.info().$("Bad UTF8 encoding").$(); sendException(state.getHttpConnectionContext().getChunkedResponseSocket(), 0, "Bad UTF8 encoding in query text", 400, query, keepAliveHeader); return false; } return true; }</code><technical_language>same, comparison MAX_VALUE is redundant</technical_language>

Target:
private boolean parseUrl( JsonQueryProcessorState state, CharSequence keepAliveHeader ) throws PeerDisconnectedException, PeerIsSlowToReadException { final HttpRequestHeader header = state.getHttpConnectionContext().getRequestHeader(); final DirectByteCharSequence query = header.getUrlParam("query"); if (query == null || query.length() == 0) { state.info().$("Empty query header received. Sending empty reply.").$(); sendException(state.getHttpConnectionContext().getChunkedResponseSocket(), 0, "No query text", 400, query, keepAliveHeader); return false; } long skip = 0; long stop = Long.MAX_VALUE; CharSequence limit = header.getUrlParam("limit"); if (limit != null) { int sepPos = Chars.indexOf(limit, ','); try { if (sepPos > 0) { skip = Numbers.parseLong(limit, 0, sepPos) - 1; if (sepPos + 1 < limit.length()) { stop = Numbers.parseLong(limit, sepPos + 1, limit.length()); } } else { stop = Numbers.parseLong(limit); } } catch (NumericException ex) { } } if (stop < 0) { stop = 0; } if (skip < 0) { skip = 0; } if ((stop - skip) > configuration.getMaxQueryResponseRowLimit()) { stop = skip + configuration.getMaxQueryResponseRowLimit(); } try { state.configure(header, query, skip, stop); } catch (Utf8Exception e) { state.info().$("Bad UTF8 encoding").$(); sendException(state.getHttpConnectionContext().getChunkedResponseSocket(), 0, "Bad UTF8 encoding in query text", 400, query, keepAliveHeader); return false; } return true; }
Source:
<code>public void freeze() throws IOException { <START> recordManager.close(); <END> recordManager = null; }</code><technical_language>some work needs done in runActivity method in order freeze coherent api. Right now, calling freeze, other methods fail. I prefer executed resume is called</technical_language>

Target:
public void freeze() throws IOException { logger.info("Closing Record Manager"); recordManager.close(); recordManager = null; isStarted = false; }
Source:
<code>public void writePacket(byte[] buf, int pos, int len) throws IOException { formatLength(len + 4); <START> out.write(lenbuffer, 0, 4); out.write(buf, pos, len); <END> }</code><technical_language>I put debugging output here</technical_language>

Target:
public void writePacket(byte[] buf, int pos, int len) throws IOException { formatLength(len + 4); out.write(lenbuffer, 0, 4); out.write(buf, pos, len); log.debug("git> " + RawParseUtils.decode(Constants.CHARSET, buf, pos, len)); }
Source:
<code>int runCmd(CommandLine cmdLine) throws Exception { boolean getter = cmdLine.hasOption("g"); boolean setter = cmdLine.hasOption("s"); if ((!getter && !setter) || (getter && setter)) { LOG.error("One and only one of -get and -set must be specified"); printUsage(); return 1; } ZooKeeper zk = null; try { <START> zk = ZooKeeperClient.newBuilder().connectString(bkConf.getZkServers()) <END> .sessionTimeoutMs(bkConf.getZkTimeout()).build(); LedgerManagerFactory mFactory = LedgerManagerFactory.newLedgerManagerFactory(bkConf, zk); LedgerUnderreplicationManager underreplicationManager = mFactory.newLedgerUnderreplicationManager(); if (getter) { int lostBookieRecoveryDelay = underreplicationManager.getLostBookieRecoveryDelay(); LOG.info("LostBookieRecoveryDelay value in ZK: {}", String.valueOf(lostBookieRecoveryDelay)); } else { int lostBookieRecoveryDelay = Integer.parseInt(cmdLine.getOptionValue("set")); underreplicationManager.setLostBookieRecoveryDelay(lostBookieRecoveryDelay); LOG.info("Successfully set LostBookieRecoveryDelay value in ZK: {}", String.valueOf(lostBookieRecoveryDelay)); } } finally { if (zk != null) { zk.close(); } } return 0; }</code><technical_language>good put this set/get logic in BookKeeperAdmin, for seasons: - shell tool simpler - is easier test verify logic</technical_language>

Target:
int runCmd(CommandLine cmdLine) throws Exception { boolean getter = cmdLine.hasOption("g"); boolean setter = cmdLine.hasOption("s"); if ((!getter && !setter) || (getter && setter)) { LOG.error("One and only one of -get and -set must be specified"); printUsage(); return 1; } ClientConfiguration adminConf = new ClientConfiguration(bkConf); BookKeeperAdmin admin = new BookKeeperAdmin(adminConf); try { if (getter) { int lostBookieRecoveryDelay = admin.getLostBookieRecoveryDelay(); LOG.info("LostBookieRecoveryDelay value in ZK: {}", String.valueOf(lostBookieRecoveryDelay)); } else { int lostBookieRecoveryDelay = Integer.parseInt(cmdLine.getOptionValue("set")); admin.setLostBookieRecoveryDelay(lostBookieRecoveryDelay); LOG.info("Successfully set LostBookieRecoveryDelay value in ZK: {}", String.valueOf(lostBookieRecoveryDelay)); } } finally { if (admin != null) { admin.close(); } } return 0; }
Source:
<code>private void refreshVdsRunTimeInfo() { boolean isVdsUpOrGoingToMaintenance = _vds.getStatus() == VDSStatus.Up || _vds.getStatus() == VDSStatus.PreparingForMaintenance || _vds.getStatus() == VDSStatus.Error || _vds.getStatus() == VDSStatus.NonOperational; try { if (isVdsUpOrGoingToMaintenance) { if (_vdsManager.getRefreshStatistics() || _vds.getStatus() == VDSStatus.PreparingForMaintenance) { refreshVdsStats(); } else { } } else { final AtomicBoolean processHardwareNeededAtomic = new AtomicBoolean(); VDSStatus refreshReturnStatus = _vdsManager.refreshCapabilities(processHardwareNeededAtomic, _vds, false); AttestationResultEnum trustLevel = AttestationCacheManager.getInstance() <START> .getValueFromCache(_vds.getHostName()).getTrustLevel(); <END> processHardwareCapsNeeded = processHardwareNeededAtomic.get(); refreshedCapabilities = true; if (refreshReturnStatus != VDSStatus.NonOperational) { _vdsManager.setStatus(VDSStatus.Up, _vds); } if (refreshReturnStatus != VDSStatus.NonOperational &&_vds.getTrustedService()){ if (trustLevel == AttestationResultEnum.TRUSTED){ _vdsManager.setStatus(VDSStatus.Up, _vds); } else{ _vdsManager.setStatus(VDSStatus.NonOperational, _vds); } } _saveVdsDynamic = true; } beforeFirstRefreshTreatment(isVdsUpOrGoingToMaintenance); refreshVmStats(); } catch (VDSRecoveringException e) { if (_vds.getStatus() != VDSStatus.PreparingForMaintenance) { throw e; } } moveVDSToMaintenanceIfNeeded(); }</code><technical_language>NPE cache is empty AttestationCacheManager.getInstance().getValueFromCache(_vds.getHostName()) != null</technical_language>

Target:
private void refreshVdsRunTimeInfo() { boolean isVdsUpOrGoingToMaintenance = _vds.getStatus() == VDSStatus.Up || _vds.getStatus() == VDSStatus.PreparingForMaintenance || _vds.getStatus() == VDSStatus.Error || _vds.getStatus() == VDSStatus.NonOperational; try { if (isVdsUpOrGoingToMaintenance) { if (_vdsManager.getRefreshStatistics() || _vds.getStatus() == VDSStatus.PreparingForMaintenance) { refreshVdsStats(); } else { } } else { final AtomicBoolean processHardwareNeededAtomic = new AtomicBoolean(); VDSStatus refreshReturnStatus = _vdsManager.refreshCapabilities(processHardwareNeededAtomic, _vds, false); AttestationResultEnum trustLevel = AttestationResultEnum.UNKNOWN; AttestationValue value = AttestationCacheManager.getInstance().getValueFromCache(_vds.getHostName()); if (value !=null ){ trustLevel = value.getTrustLevel(); } processHardwareCapsNeeded = processHardwareNeededAtomic.get(); refreshedCapabilities = true; if (refreshReturnStatus != VDSStatus.NonOperational) { _vdsManager.setStatus(VDSStatus.Up, _vds); } if (refreshReturnStatus != VDSStatus.NonOperational &&_vds.getTrustedService()){ if (trustLevel == AttestationResultEnum.TRUSTED){ _vdsManager.setStatus(VDSStatus.Up, _vds); } else{ _vdsManager.setStatus(VDSStatus.NonOperational, _vds); } } _saveVdsDynamic = true; } beforeFirstRefreshTreatment(isVdsUpOrGoingToMaintenance); refreshVmStats(); } catch (VDSRecoveringException e) { if (_vds.getStatus() != VDSStatus.PreparingForMaintenance) { throw e; } } moveVDSToMaintenanceIfNeeded(); }
Source:
<code><START> public Map<String, String> computeRecoveryAssignment(final CurrentStateOutput currentStateOutput, <END> final String resourceName, final Partition partition, StateModelDefinition stateModelDef, List<String> preferenceList) { Map<String, String> currentStateMap = currentStateOutput.getCurrentStateMap(resourceName, partition); if (isCurrentStatesValid(currentStateOutput, resourceName, partition, stateModelDef)) { LOG.warn("The input current state map is valid, return the original current state.", currentStateMap); return currentStateMap; } Map<String, String> recoverMap = new HashMap<>(currentStateMap); String recoveryState = stateModelDef .getNextStateForTransition(stateModelDef.getTopState(), stateModelDef.getInitialState()); if (preferenceList != null && !preferenceList.isEmpty()) { String expectedTopStateHost = preferenceList.get(0); if (recoverMap.get(expectedTopStateHost).equals(stateModelDef.getTopState())) { recoverMap.put(expectedTopStateHost, recoveryState); } } boolean hasReservedTheTopState = false; for (String instance : recoverMap.keySet()) { if (recoverMap.get(instance).equals(stateModelDef.getTopState())) { if (hasReservedTheTopState) { recoverMap.put(instance, recoveryState); } else { hasReservedTheTopState = true; } } } return recoverMap; }</code><technical_language>computeCorrectedAssignment is clearer</technical_language>

Target:
public Map<String, String> computeRecoveryAssignment(final CurrentStateOutput currentStateOutput, final String resourceName, final Partition partition, StateModelDefinition stateModelDef, List<String> preferenceList) { Map<String, String> currentStateMap = currentStateOutput.getCurrentStateMap(resourceName, partition); if (checkCurrentStates(currentStateOutput, resourceName, partition, stateModelDef)) { LOG.warn("The input current state map is valid, return the original current state.", currentStateMap); return currentStateMap; } Map<String, String> recoverMap = new HashMap<>(currentStateMap); String recoveryState = stateModelDef .getNextStateForTransition(stateModelDef.getTopState(), stateModelDef.getInitialState()); if (preferenceList != null && !preferenceList.isEmpty()) { String expectedTopStateHost = preferenceList.get(0); if (recoverMap.get(expectedTopStateHost).equals(stateModelDef.getTopState())) { recoverMap.put(expectedTopStateHost, recoveryState); } } boolean hasReservedTopState = false; for (String instance : recoverMap.keySet()) { if (recoverMap.get(instance).equals(stateModelDef.getTopState())) { if (hasReservedTopState) { recoverMap.put(instance, recoveryState); } else { hasReservedTopState = true; } } } return recoverMap; }
Source:
<code><START> public void nonBinaryWithSourceImages() throws Exception { <END> FolderObject folderObject = repoObjectFactory.createFolderObject(null); final Map<String, Object> headers = createEvent(true, folderObject.getPid(), Cdr.Collection.getURI(), Container.getURI()); template.sendBodyAndHeaders("", headers); NotifyBuilder notify1 = new NotifyBuilder(cdrEnhancements) .whenCompleted(1) .create(); NotifyBuilder notify2 = new NotifyBuilder(cdrServiceSolr) .whenCompleted(1) .create(); boolean result1 = notify1.matches(5l, TimeUnit.SECONDS); assertTrue("Enhancement route not satisfied", result1); boolean result2 = notify2.matches(5l, TimeUnit.SECONDS); assertTrue("Indexing route not satisfied", result2); verify(solrIngestProcessor).process(any(Exchange.class)); }</code><technical_language>This test verify thumbnail enhancements called. check access copy is called</technical_language>

Target:
public void nonBinaryWithSourceImages() throws Exception { CollectionObject collObject = repoObjectFactory.createCollectionObject(null); String uuid = collObject.getPid().getUUID(); String basePath = idToPath(uuid, HASHED_PATH_DEPTH, HASHED_PATH_SIZE); File uploadedFile = new File(String.valueOf(Paths.get(tempDir.getAbsolutePath(), basePath, uuid))); FileInputStream input = new FileInputStream("src/test/resources/uploaded-files/burndown.png"); FileUtils.copyInputStreamToFile(input, uploadedFile); final Map<String, Object> headers = createEvent(collObject.getPid(), Cdr.Collection.getURI(), Container.getURI()); template.sendBodyAndHeaders("", headers); NotifyBuilder notify1 = new NotifyBuilder(cdrEnhancements) .whenCompleted(1) .create(); NotifyBuilder notify2 = new NotifyBuilder(cdrServiceSolr) .whenCompleted(1) .create(); boolean result1 = notify1.matches(5l, TimeUnit.SECONDS); assertTrue("Enhancement route not satisfied", result1); boolean result2 = notify2.matches(5l, TimeUnit.SECONDS); assertTrue("Indexing route not satisfied", result2); verify(addSmallThumbnailProcessor).process(any(Exchange.class)); verify(addLargeThumbnailProcessor).process(any(Exchange.class)); verify(addAccessCopyProcessor, never()).process(any(Exchange.class)); verify(solrIngestProcessor).process(any(Exchange.class)); }
Source:
<code>protected static String getAgentString(String agentName, String agentVersion, String agentDesc, String agentURL, String agentEmail) { StringBuffer buf = new StringBuffer(); buf.append(agentName); if (agentVersion != null) { buf.append("/"); buf.append(agentVersion); } if (((agentDesc != null) && (agentDesc.length() != 0)) || ((agentEmail != null) && (agentEmail.length() != 0)) <START> || ((agentURL != null) && (agentURL.length() != 0))) { <END> buf.append(" ("); if ((agentDesc != null) && (agentDesc.length() != 0)) { buf.append(agentDesc); if ((agentURL != null) || (agentEmail != null)) buf.append("; "); } if ((agentURL != null) && (agentURL.length() != 0)) { buf.append(agentURL); if (agentEmail != null) buf.append("; "); } if ((agentEmail != null) && (agentEmail.length() != 0)) buf.append(agentEmail); buf.append(")"); } return buf.toString(); }</code><technical_language>StringUtils.isNotBlank isNotEmpty</technical_language>

Target:
protected static String getAgentString(String agentName, String agentVersion, String agentDesc, String agentURL, String agentEmail) { StringBuffer buf = new StringBuffer(); buf.append(agentName); if (StringUtils.isNotBlank(agentVersion)) { buf.append("/"); buf.append(agentVersion); } boolean hasAgentDesc = StringUtils.isNotBlank(agentDesc); boolean hasAgentURL = StringUtils.isNotBlank(agentURL); boolean hasAgentEmail = StringUtils.isNotBlank(agentEmail); if (hasAgentDesc || hasAgentEmail || hasAgentURL) { buf.append(" ("); if (hasAgentDesc) { buf.append(agentDesc); if (hasAgentURL || hasAgentEmail) buf.append("; "); } if (hasAgentURL) { buf.append(agentURL); if (hasAgentEmail) buf.append("; "); } if (hasAgentEmail) { buf.append(agentEmail); } buf.append(")"); } return buf.toString(); }
Source:
<code>public AccountAttributes getCopy() { AccountAttributes copy = AccountAttributes.builder() .withGoogleId(googleId) .withName(name) .withEmail(email) .withInstitute(institute) .withIsInstructor(isInstructor) .withDefaultStudentProfileAttributes(googleId) .build(); <START> copy.studentProfile = this.studentProfile == null ? null : this.studentProfile.getCopy(); <END> return copy; }</code><technical_language>me, this line redundant. pass withStudentProfileAttributes(this.studentProfile.getCopy()) in building process</technical_language>

Target:
public AccountAttributes getCopy() { return AccountAttributes.builder() .withGoogleId(googleId) .withName(name) .withEmail(email) .withInstitute(institute) .withIsInstructor(isInstructor) .withStudentProfileAttributes(this.studentProfile == null ? null : this.studentProfile.getCopy()) .build(); }
Source:
<code>public Hypervisor build() { properties(properties() != null ? ImmutableList.copyOf(properties()) : null); diskSpeeds(diskSpeeds() != null ? ImmutableList.copyOf(diskSpeeds()) : null); <START> cpuSpeeds(cpuSpeeds() != null ? ImmutableList.copyOf(cpuSpeeds()) : null); <END> return autoBuild(); }</code><technical_language>For lists marked @Nullable return empty list instead of null (or mark @Nullable if appropriate)</technical_language>

Target:
public Hypervisor build() { properties(properties() != null ? ImmutableList.copyOf(properties()) : ImmutableList.<Property>of()); diskSpeeds(diskSpeeds() != null ? ImmutableList.copyOf(diskSpeeds()) : ImmutableList.<DiskSpeed>of()); cpuSpeeds(cpuSpeeds() != null ? ImmutableList.copyOf(cpuSpeeds()) : ImmutableList.<CpuSpeed>of()); return autoBuild(); }
Source:
<code>private void bindGeocachingUserToGCVoteuser() { final Preference pref = getPreference(R.string.pref_username); if (pref == null) { return; } <START> final String value = PreferenceManager <END> .getDefaultSharedPreferences(pref.getContext()) .getString(pref.getKey(), ""); getPreference(R.string.pref_user_vote).setSummary(value); final Preference prefvote = getPreference(R.string.pref_user_vote); bindSummaryToValue(prefvote, value); }</code><technical_language>Settings.getGcCredentials() (perhaps checking Settings.hasGcCredentials()) instead of this more complicated harder understand preference</technical_language>

Target:
private void bindGeocachingUserToGCVoteuser() { if (!Settings.hasGCCredentials()) { return; } final String value = Settings.getGcCredentials().getLeft(); getPreference(R.string.pref_user_vote).setSummary(value); final Preference prefvote = getPreference(R.string.pref_user_vote); bindSummaryToValue(prefvote, value); }
Source:
<code>private boolean allowEnrollInPublication(Node node, String nodeType) throws Exception { String path = node.getPath(); Node parentNode = node.getParent(); while(!path.equals("/") && path.length() > 0) { parentNode = (Node)node.getSession().getItem(path); if(parentNode.isNodeType(nodeType)) return false; <START> path = StringUtils.substringBeforeLast(path, path.substring(path.lastIndexOf("/"), path.length())); <END> } return true; }</code><technical_language>be? path = path.substring(0, path.lastIndexOf("/"));</technical_language>

Target:
private boolean allowEnrollInPublication(Node node, String nodeType) throws Exception { String path = node.getPath(); Node parentNode = node.getParent(); while(!path.equals("/") && path.length() > 0) { parentNode = (Node)node.getSession().getItem(path); if(parentNode.isNodeType(nodeType)) return false; path = path.substring(0, path.lastIndexOf("/")); } return true; }
Source:
<code>protected final boolean checkAssignmentBound(TType rhs) { if (fBounds.length == 0) return true; <START> for (TType fBound : fBounds) { <END> if (rhs.canAssignTo(fBound)) { return true; } } return false; }</code><technical_language>fix this</technical_language>

Target:
protected final boolean checkAssignmentBound(TType rhs) { if (fBounds.length == 0) return true; for (TType bound : fBounds) { if (rhs.canAssignTo(bound)) { return true; } } return false; }
Source:
<code>protected static List<URL> getClasspath(final Configuration configuration, final PackagedProgram program) { final List<URL> classpath = new ArrayList<>(); classpath.addAll( ConfigUtils.decodeListFromConfig( configuration, PipelineOptions.CLASSPATHS, <START> url -> { <END> try { return new URL(url); } catch (MalformedURLException e) { throw new IllegalArgumentException("Bad syntax for classpath: " + url, e); } })); classpath.addAll(program.getClasspaths()); return Collections.unmodifiableList(classpath.stream().distinct().collect(Collectors.toList())); }</code><technical_language>Instead of this code in places (see ExecutionConfigAccessor), sense change ConfigUtils.decodeListFromConfig() sth like: public static <IN, OUT, E extends Throwable> List<OUT> decodeListFromConfig( final ReadableConfig configuration, final ConfigOption<List<IN>> key, final FunctionWithException<IN, OUT, E> mapper) throws E { checkNotNull(configuration); checkNotNull(key); checkNotNull(mapper); final List<IN> encodedString = configuration.get(key); if (encodedString == null) { return Collections.emptyList(); } final List<OUT> result = new ArrayList<>(encodedString.size()); for (IN input : encodedString) { result.add(mapper.apply(input)); } return result; } this method simply: protected static List<URL> getClasspath(final Configuration configuration, final PackagedProgram program) throws MalformedURLException { final List<URL> classpath = ConfigUtils.decodeListFromConfig( configuration, PipelineOptions.CLASSPATHS, URL::new); classpath.addAll(program.getClasspaths()); return Collections.unmodifiableList(classpath.stream().distinct().collect(Collectors.toList())); } Of this require some more changes in ExecutionConfigAccessor classes affected thrown exception, e.g. executors do throw exception, bubble exception</technical_language>

Target:
private static List<URL> getClasspath(final Configuration configuration, final PackagedProgram program) throws MalformedURLException { final List<URL> classpath = ConfigUtils.decodeListFromConfig( configuration, PipelineOptions.CLASSPATHS, URL::new); classpath.addAll(program.getClasspaths()); return Collections.unmodifiableList(classpath.stream().distinct().collect(Collectors.toList())); }
Source:
<code><START> public void addMessage(@Valid final Message message) { <END> env.addMessage(message); }</code><technical_language>POST 202 CREATED is more</technical_language>

Target:
public Response addMessage(@Valid final Message message) { env.addMessage(message); return Response.status(Response.Status.CREATED).build(); }
Source:
<code>public void multiRequest() throws IOException { init(); ViewMultipleRequest<String, Object> multi = db.getViewRequestBuilder("example", "foo") .newMultipleRequest(Key.Type.STRING, Object.class) .keys("key-1").add() .keys("key-2").add() .keys("key-3").add() .build(); int i = 1; List<ViewResponse<String, Object>> responses = multi.getViewResponses(); <START> assertEquals(3, responses.size(), "There should be 3 respones for 3 requests"); <END> for (ViewResponse<String, Object> response : responses) { assertEquals(1, response.getRows().size(), "There should be 1 row in each response"); assertEquals("key-" + i, response.getKeys().get(0), "The returned key should be key-" + i); i++; } }</code><technical_language>respones -> responses</technical_language>

Target:
public void multiRequest() throws IOException { init(); ViewMultipleRequest<String, Object> multi = db.getViewRequestBuilder("example", "foo") .newMultipleRequest(Key.Type.STRING, Object.class) .keys("key-1").add() .keys("key-2").add() .keys("key-3").add() .build(); int i = 1; List<ViewResponse<String, Object>> responses = multi.getViewResponses(); assertEquals(3, responses.size(), "There should be 3 responses for 3 requests"); for (ViewResponse<String, Object> response : responses) { assertEquals(1, response.getRows().size(), "There should be 1 row in each response"); assertEquals("key-" + i, response.getKeys().get(0), "The returned key should be key-" + i); i++; } }
Source:
<code><START> private void parseContestZipArchive(FileInformationDTO fileInformationDTO) throws AppException { <END> ZipFile zipFile; try { zipFile = new ZipFile(fileInformationDTO.getFileName()); } catch (IOException e) { throw new AppException("Create zipFile object failed."); } String tempDirectory = settings.SETTING_UPLOAD_FOLDER + "/" + fileInformationDTO.getFileName(); ZipUtil.unzipFile(zipFile, tempDirectory, new ContestZipChecker()); Contest contest = parseContestInfo(tempDirectory); }</code><technical_language>public</technical_language>

Target:
public ContestDTO parseContestZipArchive(FileInformationDTO fileInformationDTO) throws AppException { ZipFile zipFile; try { zipFile = new ZipFile(fileInformationDTO.getFileName()); } catch (IOException e) { throw new AppException("Create zipFile object failed."); } String tempDirectory = settings.SETTING_UPLOAD_FOLDER + "/" + fileInformationDTO.getFileName(); ZipUtil.unzipFile(zipFile, tempDirectory, new ContestZipChecker()); return parseContestInfo(tempDirectory); }
Source:
<code>private String createAndRegisterUniqueAlias(String originalAlias) { String uniqueAlias = originalAlias; if (!aliasMap.containsKey(originalAlias)) { aliasMap.put(originalAlias, 0); uniqueAlias = 0 + uniqueAlias; } else { aliasMap.put(originalAlias, aliasMap.get(originalAlias) + 1); uniqueAlias = aliasMap.get(originalAlias).toString() + originalAlias; } if (aliasList.contains(nameCutter.trimByCamelCase(uniqueAlias, 19))) { <START> logger.warn("ALIAS CRASH AT :" + uniqueAlias + "\t as: " + nameCutter.trimByCamelCase(uniqueAlias, 19)); <END> uniqueAlias = uniqueAlias + "_NAME_CRASH_AS_19_CHAR_VALUE"; } else { uniqueAlias = nameCutter.trimByCamelCase(uniqueAlias, 19); aliasList.add(uniqueAlias); } return uniqueAlias; }</code><technical_language>Please change "ALIAS CRASH AT" message. "Ambiguous attribute name "+uniqueAlias+"..."</technical_language>

Target:
private String createAndRegisterUniqueAlias(String originalAlias) { String uniqueAlias = originalAlias; if (!aliasMap.containsKey(originalAlias)) { aliasMap.put(originalAlias, 0); uniqueAlias = 0 + uniqueAlias; } else { aliasMap.put(originalAlias, aliasMap.get(originalAlias) + 1); uniqueAlias = aliasMap.get(originalAlias).toString() + originalAlias; } final String uniqueAliasShort = nameCutter.trimByCamelCase(uniqueAlias, 19); if (aliasList.contains(uniqueAliasShort)) { logger.warn("Ambiguous alias name '{}'\t as '{}", uniqueAlias, uniqueAliasShort); uniqueAlias = uniqueAlias + "_NAME_CRASH_AS_19_CHAR_VALUE"; } else { uniqueAlias = uniqueAliasShort; aliasList.add(uniqueAlias); } return uniqueAlias; }
Source:
<code>public String getUserMessage() { StringBuffer sb = new StringBuffer(); String desc = exception.getDescription(); switch(desc) { case "Unclosed character class": sb.append("The regular expression is missing a closing ']' character, or has an empty pair of square brackets '[]'."); break; case "Unmatched closing ')'": sb.append("The regular expression is missing a opening '(' character."); break; case "Unclosed group": sb.append("The regular expression is missing a closing ')' character."); break; case "Dangling meta character '*'": case "Dangling meta character '+'": case "Dangling meta character '?'": sb.append("The regular expression has a '*','+' or '?' in the wrong place."); break; case "Unexpected internal error": sb.append("The regular expression has a backslash '\\' at the end."); break; case "Unclosed counted closure": sb.append("The regular expression is missing a closing '}' character, or has an incorrect quantifier statement in curly brackets '{}'."); break; case "Illegal repetition": sb.append("The regular expression has an incomplete or incorrect quantifier statement in curly brackets '{}'."); break; case "Illegal repetition range": sb.append("The regular expression has a quantifier statement where the minimum is larger than the maximum (e.g. {4,3})."); break; case "Illegal character range": sb.append("The regular expression has a range statement which is incomplete or has the characters in the incorrect order (e.g. [9-0])"); break; default: <START> sb.append(exception.getMessage()); <END> break; } return sb.toString(); }</code><technical_language>StringBuffer is necessary here. is time assign. String more efficient straightforward. consider a HashMap</technical_language>

Target:
public String getUserMessage() { String msg = ""; String desc = exception.getDescription(); switch(desc) { case "Unclosed character class": msg = "The regular expression is missing a closing ']' character, or has an empty pair of square brackets '[]'."; break; case "Unmatched closing ')'": msg = "The regular expression is missing a opening '(' character."; break; case "Unclosed group": msg = "The regular expression is missing a closing ')' character."; break; case "Dangling meta character '*'": case "Dangling meta character '+'": case "Dangling meta character '?'": msg = "The regular expression has a '*','+' or '?' in the wrong place."; break; case "Unexpected internal error": msg = "The regular expression has a backslash '\\' at the end."; break; case "Unclosed counted closure": msg = "The regular expression is missing a closing '}' character, or has an incorrect quantifier statement in curly brackets '{}'."; break; case "Illegal repetition": msg = "The regular expression has an incomplete or incorrect quantifier statement in curly brackets '{}'."; break; case "Illegal repetition range": msg = "The regular expression has a quantifier statement where the minimum is larger than the maximum (e.g. {4,3})."; break; case "Illegal character range": msg = "The regular expression has a range statement which is incomplete or has the characters in the incorrect order (e.g. [9-0])"; break; default: msg = exception.getMessage(); break; } return msg; }
Source:
<code>private double decomposedValueOnDefault(CDSAnalytic indexCDS, double indexCoupon, ISDACompliantYieldCurve yieldCurve, IntrinsicIndexDataBundle intrinsicData, int singleName) { double protection = intrinsicData.getLGD(singleName) * intrinsicData.getWeight(singleName); double singleNamePV = _pricer.pv(indexCDS, yieldCurve, intrinsicData.getCreditCurves()[singleName], indexCoupon) * intrinsicData.getWeight(singleName); <START> return protection - singleNamePV; <END> }</code><technical_language>rewrite this double w = intrinsicData.getWeight(singleName); double protection = intrinsicData.getLGD(singleName) ; double singleNamePV = _pricer.pv(indexCDS, yieldCurve, intrinsicData.getCreditCurves()[singleName], indexCoupon); return w*(protection - singleNamePV);</technical_language>

Target:
private double decomposedValueOnDefault(CDSAnalytic indexCDS, double indexCoupon, ISDACompliantYieldCurve yieldCurve, IntrinsicIndexDataBundle intrinsicData, int singleName) { double weight = intrinsicData.getWeight(singleName); double protection = intrinsicData.getLGD(singleName); double singleNamePV = _pricer.pv(indexCDS, yieldCurve, intrinsicData.getCreditCurves()[singleName], indexCoupon); return weight * (protection - singleNamePV); }
Source:
<code>protected void getInformationsFromContextManager(IContextManager contextManager) { List<IContext> internalContextList = new ArrayList<IContext>(); IContext newSelectedCopiedContext = null; <START> if (process != null && process.getUpdateManager() != null) { <END> process.getUpdateManager().updateAll(); } if (process != null && process.getLastRunContext() != null) { for (IContext context : contextManager.getListContext()) { IContext copiedContext = context.clone(); internalContextList.add(copiedContext); if (process.getLastRunContext().getName().equals(context.getName())) { newSelectedCopiedContext = copiedContext; } } } else { for (IContext context : contextManager.getListContext()) { IContext copiedContext = context.clone(); internalContextList.add(copiedContext); if (contextManager.getDefaultContext().equals(context)) { newSelectedCopiedContext = copiedContext; } } } Collections.sort(internalContextList, new ContextCompare()); contextComboViewer.setInput(internalContextList); ProcessManager processManager = ProcessManager.getInstance(); if (newSelectedCopiedContext != null) { setContextComboSelection(new StructuredSelection(newSelectedCopiedContext)); processManager.setSelectContext(newSelectedCopiedContext); contextTableViewer.setInput(newSelectedCopiedContext.getContextParameterList()); } else { IContext element = internalContextList.get(0); processManager.setSelectContext(element); setContextComboSelection(new StructuredSelection(element)); contextTableViewer.setInput(element.getContextParameterList()); } }</code><technical_language>impact more irrelevant cases</technical_language>

Target:
protected void getInformationsFromContextManager(IContextManager contextManager) { List<IContext> internalContextList = new ArrayList<IContext>(); IContext newSelectedCopiedContext = null; if (process != null && process.getLastRunContext() != null) { for (IContext context : contextManager.getListContext()) { IContext copiedContext = context.clone(); internalContextList.add(copiedContext); if (process.getLastRunContext().getName().equals(context.getName())) { newSelectedCopiedContext = copiedContext; } } } else { for (IContext context : contextManager.getListContext()) { IContext copiedContext = context.clone(); internalContextList.add(copiedContext); if (contextManager.getDefaultContext().equals(context)) { newSelectedCopiedContext = copiedContext; } } } Collections.sort(internalContextList, new ContextCompare()); contextComboViewer.setInput(internalContextList); ProcessManager processManager = ProcessManager.getInstance(); if (newSelectedCopiedContext != null) { setContextComboSelection(new StructuredSelection(newSelectedCopiedContext)); processManager.setSelectContext(newSelectedCopiedContext); contextTableViewer.setInput(newSelectedCopiedContext.getContextParameterList()); } else { IContext element = internalContextList.get(0); processManager.setSelectContext(element); setContextComboSelection(new StructuredSelection(element)); contextTableViewer.setInput(element.getContextParameterList()); } }
Source:
<code>public void contributeToCoolBar(ICoolBarManager coolBarManager) { if (coolBarManager instanceof SubCoolBarManager) { subManager = (SubCoolBarManager) coolBarManager; } else { subManager = new SubCoolBarManager(coolBarManager); } subManager.setVisible(true); ToolBarManager actionToolBarManager = new ToolBarManager(SWT.FLAT); ApplicationGIS.getToolManager().contributeActionTools(actionToolBarManager, getActionBars()); if ( actionToolBarManager.getItems().length > 0){ IContributionItem item = subManager.find(ToolConstants.ACTION_TOOLBAR_ID); if(item != null){ subManager.remove(ToolConstants.ACTION_TOOLBAR_ID); } ToolBarContributionItem toolBarContributionItem = new ToolBarContributionItem(actionToolBarManager, ToolConstants.ACTION_TOOLBAR_ID); subManager.add(toolBarContributionItem); } <START> if( isModalIncluded ){ <END> ToolBarManager modalToolBarManager = new ToolBarManager(SWT.FLAT); ApplicationGIS.getToolManager().contributeModalTools(modalToolBarManager, getActionBars()); if ( modalToolBarManager.getItems().length > 0){ IContributionItem item = subManager.find(ToolConstants.MODAL_TOOLBAR_ID); if(item != null){ subManager.remove(ToolConstants.MODAL_TOOLBAR_ID); } ToolBarContributionItem toolBarContributionItem = new ToolBarContributionItem(modalToolBarManager, ToolConstants.MODAL_TOOLBAR_ID); subManager.add(toolBarContributionItem); } } super.contributeToCoolBar(coolBarManager); }</code><technical_language>I that; this contribute tools a view toolbar</technical_language>

Target:
public void contributeToCoolBar(ICoolBarManager coolBarManager) { if (coolBarManager instanceof SubCoolBarManager) { subManager = (SubCoolBarManager) coolBarManager; } else { subManager = new SubCoolBarManager(coolBarManager); } subManager.setVisible(true); ToolBarManager actionToolBarManager = new ToolBarManager(SWT.FLAT); ApplicationGIS.getToolManager().contributeActionTools(actionToolBarManager, getActionBars()); if ( actionToolBarManager.getItems().length > 0){ IContributionItem item = subManager.find(ToolConstants.ACTION_TOOLBAR_ID); if(item != null){ subManager.remove(ToolConstants.ACTION_TOOLBAR_ID); } ToolBarContributionItem toolBarContributionItem = new ToolBarContributionItem(actionToolBarManager, ToolConstants.ACTION_TOOLBAR_ID); subManager.add(toolBarContributionItem); } super.contributeToCoolBar(coolBarManager); }
Source:
<code>private void deleteCredentialAndRedirect() { if (mCredential == null) { Log.w(TAG, "deleteCredentialAndRedirect: null credential"); startAuthMethodChoice(); return; } AuthUI.getInstance() <START> .delete(getActivity()) <END> .addOnCompleteListener(new OnCompleteListener<Void>() { @Override public void onComplete(@NonNull Task<Void> task) { if (!task.isSuccessful()) { Log.w(TAG, "deleteCredential:failure", task.getException()); } startAuthMethodChoice(); } }); }</code><technical_language>This deletes underlying Firebase Auth account in addition deleting credentials. This new properties: - fail if is currently signed in user - fail if authentication (last 5 minutes) intend change this behavior</technical_language>

Target:
private void deleteCredentialAndRedirect() { if (mCredential == null) { Log.w(TAG, "deleteCredentialAndRedirect: null credential"); startAuthMethodChoice(); return; } GoogleSignInHelper.getInstance(getActivity()) .delete(mCredential) .addOnCompleteListener(new OnCompleteListener<Status>() { @Override public void onComplete(@NonNull Task<Status> task) { if (!task.isSuccessful()) { Log.w(TAG, "deleteCredential:failure", task.getException()); } startAuthMethodChoice(); } }); }
Source:
<code>public void finishedLoadingLogs() { FragmentManager fm = getSupportFragmentManager(); Fragment fragment = fm.findFragmentById(R.id.fragment_geotag_layout); <START> if (fragment == null || !(fragment instanceof GeoTagImagesFragment)) { <END> fragment = new GeoTagImagesFragment(); fm.beginTransaction().replace(R.id.fragment_geotag_layout, fragment).commit(); } }</code><technical_language>@chaviw skip check for null. If fragment is null instanceof check fail</technical_language>

Target:
public void finishedLoadingLogs() { FragmentManager fm = getSupportFragmentManager(); Fragment fragment = fm.findFragmentById(R.id.fragment_geotag_layout); if (!(fragment instanceof GeoTagImagesFragment)) { fragment = new GeoTagImagesFragment(); fm.beginTransaction().replace(R.id.fragment_geotag_layout, fragment).commit(); } }