auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public void selectByQuery_on_empty_list_of_component_key() { ComponentQuery dbQuery = ComponentQuery.builder().setQualifiers(Qualifiers.PROJECT).setComponentKeys(emptySet()).build(); List<ComponentDto> result = underTest.selectByQuery(dbSession, dbQuery, 0, 10); <START> int count = underTest.countByQuery(dbSession, dbQuery); <END> assertThat(result).isEmpty(); assertThat(count).isEqualTo(0); }</code><technical_language>Please add of project in order check result is empty return empty list</technical_language>

Target:
public void selectByQuery_on_empty_list_of_component_key() { db.components().insertPrivateProject(); ComponentQuery dbQuery = ComponentQuery.builder().setQualifiers(Qualifiers.PROJECT).setComponentKeys(emptySet()).build(); List<ComponentDto> result = underTest.selectByQuery(dbSession, dbQuery, 0, 10); int count = underTest.countByQuery(dbSession, dbQuery); assertThat(result).isEmpty(); assertThat(count).isEqualTo(0); }
Source:
<code>private boolean executeSshSoftFencingCommand(String version) { boolean result = false; EngineSSHClient sshClient = null; try { sshClient = new EngineSSHClient(); sshClient.setVds(getVds()); sshClient.useDefaultKeyPair(); sshClient.connect(); sshClient.authenticate(); } catch (Exception ex) { log.errorFormat("SSH connection to host {0} failed: {1}", getVds().getHostName(), ex); closeSshConnection(sshClient); return result; } ByteArrayOutputStream cmdOut = new ByteArrayOutputStream(); ByteArrayOutputStream cmdErr = new ByteArrayOutputStream(); try { sshClient.executeCommand(Config.<String> GetValue(ConfigValues.SshSoftFencingCommand, version), null, cmdOut, cmdErr); <START> log.infoFormat("SSH Soft Fencing command executed on host {0}", getVds().getHostName()); <END> result = true; } catch (Exception ex) { log.errorFormat("SSH Soft Fencing command failed on host {0}: {1}\nStdout: {2}\nStderr: {3}\nStacktrace: {4}", getVds().getHostName(), ex.getMessage(), cmdOut.toString(), cmdErr.toString(), ex); } finally { closeSshConnection(sshClient); } return result; }</code><technical_language>I consider move info log execution of command. more info if sshClient hang for some time</technical_language>

Target:
private boolean executeSshSoftFencingCommand(String version) { boolean result = false; EngineSSHClient sshClient = null; try { sshClient = new EngineSSHClient(); sshClient.setVds(getVds()); sshClient.useDefaultKeyPair(); sshClient.connect(); sshClient.authenticate(); } catch (Exception ex) { log.errorFormat("SSH connection to host {0} failed: {1}", getVds().getHostName(), ex); closeSshConnection(sshClient); return result; } ByteArrayOutputStream cmdOut = new ByteArrayOutputStream(); ByteArrayOutputStream cmdErr = new ByteArrayOutputStream(); try { log.infoFormat("Executing SSH Soft Fencing command on host {0}", getVds().getHostName()); sshClient.executeCommand(Config.<String> GetValue(ConfigValues.SshSoftFencingCommand, version), null, cmdOut, cmdErr); result = true; } catch (Exception ex) { log.errorFormat("SSH Soft Fencing command failed on host {0}: {1}\nStdout: {2}\nStderr: {3}\nStacktrace: {4}", getVds().getHostName(), ex.getMessage(), cmdOut.toString(), cmdErr.toString(), ex); } finally { closeSshConnection(sshClient); } return result; }
Source:
<code>public TransactionToken createApplicabilityForView(ArtifactId viewId, String applicability) { XResultData access = isAccess(); if (access.isErrors()) { return TransactionToken.SENTINEL; } String featureName = applicability.substring(0, applicability.indexOf("=") - 1); String featureValue = applicability.substring(applicability.indexOf("=") + 2); if (applicabilityQuery.getFeatureExistsOnBranch(branch, featureName) && applicabilityQuery.getFeatureValueIsValid(branch, featureName, featureValue)) { String existingAppl = applicabilityQuery.getExistingFeatureApplicability(branch, viewId, featureName); if (existingAppl.equals(applicability)) { access.errorf("Applicability already exists."); return TransactionToken.SENTINEL; } else { TransactionBuilder tx = orcsApi.getTransactionFactory().createTransaction(branch, account, "Apply " + applicability + " applicability"); if (!existingAppl.isEmpty()) { tx.deleteTuple2(CoreTupleTypes.ViewApplicability, viewId, existingAppl); } tx.createApplicabilityForView(viewId, applicability); return tx.commit(); } <START> } else { <END> access.errorf("Feature not defined."); return TransactionToken.SENTINEL; } }</code><technical_language>access, need add error string</technical_language>

Target:
public XResultData createApplicabilityForView(ArtifactId viewId, String applicability) { XResultData results = isAccess(); if (results.isErrors()) { return results; } try { String featureName = applicability.substring(0, applicability.indexOf("=") - 1); String featureValue = applicability.substring(applicability.indexOf("=") + 2); if (applicabilityQuery.getFeatureExistsOnBranch(branch, featureName) && applicabilityQuery.getFeatureValueIsValid(branch, featureName, featureValue)) { String existingAppl = applicabilityQuery.getExistingFeatureApplicability(branch, viewId, featureName); if (existingAppl.equals(applicability)) { results.error("Applicability already exists."); } else { TransactionBuilder tx = orcsApi.getTransactionFactory().createTransaction(branch, account, "Apply " + applicability + " applicability"); if (!existingAppl.isEmpty()) { tx.deleteTuple2(CoreTupleTypes.ViewApplicability, viewId, existingAppl); } tx.createApplicabilityForView(viewId, applicability); tx.commit(); } } else { results.error("Feature not defined."); } } catch (Exception ex) { results.error(Lib.exceptionToString(ex)); } return results; }
Source:
<code>public PGobject convertToDatabaseColumn(ExternalMetadata externalMetadata) { PGobject pgObject = new PGobject(); pgObject.setType("jsonb"); <START> var metaData = externalMetadata == null ? null : externalMetadata.getMetadata(); <END> try { pgObject.setValue(mapper.writeValueAsString(metaData)); } catch (JsonProcessingException | SQLException e) { throw new ExternalMetadataConverterException("Failed to serialise externalMetadata"); } return pgObject; }</code><technical_language>I in this case declaring metaData (which a capital D!) is a Map var clearer</technical_language>

Target:
public PGobject convertToDatabaseColumn(ExternalMetadata externalMetadata) { PGobject pgObject = new PGobject(); pgObject.setType("jsonb"); if (externalMetadata == null) { return pgObject; } try { pgObject.setValue(mapper.writeValueAsString(externalMetadata.getMetadata())); } catch (JsonProcessingException | SQLException e) { throw new ExternalMetadataConverterException("Failed to serialise externalMetadata"); } return pgObject; }
Source:
<code>public void testLeaseRenewSocketTimeout() throws Exception { String file1 = "/testFile1"; String file2 = "/testFile2"; conf.setInt(HdfsClientConfigKeys.Retry.WINDOW_BASE_KEY, 10); conf.setInt(DFS_CLIENT_SOCKET_TIMEOUT_KEY, 2 * 1000); MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf).build(); try { cluster.waitActive(); NamenodeProtocols spyNN = spy(cluster.getNameNodeRpc()); Mockito.doThrow(new SocketTimeoutException()).when(spyNN).renewLease( Mockito.anyString()); DFSClient client = new DFSClient(null, spyNN, conf, null); final LeaseRenewer leaseRenewer1 = client.getLeaseRenewer(); leaseRenewer1.setRenewalTime(100); OutputStream out1 = client.create(file1, false); Mockito.verify(spyNN, timeout(10000).times(1)).renewLease( Mockito.anyString()); verifyEmptyLease(leaseRenewer1); GenericTestUtils.waitFor(() -> !(leaseRenewer1.isRunning()), 100, 10000); try { out1.write(new byte[256]); fail("existing output stream should be aborted"); } catch (IOException e) { } client.exists(file2); Mockito.doNothing().when(spyNN).renewLease( Mockito.anyString()); <START> LeaseRenewer leaseRenewer2 = client.getLeaseRenewer(); <END> leaseRenewer2.setRenewalTime(100); OutputStream out2 = client.create(file2, false); Mockito.verify(spyNN, timeout(10000).times(2)).renewLease( Mockito.anyString()); out2.write(new byte[256]); out2.close(); verifyEmptyLease(leaseRenewer2); } finally { cluster.shutdown(); } }</code><technical_language>set final leaseRenewer2 leaseRenewer1</technical_language>

Target:
public void testLeaseRenewSocketTimeout() throws Exception { String file1 = "/testFile1"; String file2 = "/testFile2"; conf.setInt(HdfsClientConfigKeys.Retry.WINDOW_BASE_KEY, 10); conf.setInt(DFS_CLIENT_SOCKET_TIMEOUT_KEY, 2 * 1000); MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf).build(); try { cluster.waitActive(); NamenodeProtocols spyNN = spy(cluster.getNameNodeRpc()); Mockito.doThrow(new SocketTimeoutException()).when(spyNN).renewLease( Mockito.anyString()); DFSClient client = new DFSClient(null, spyNN, conf, null); final LeaseRenewer leaseRenewer1 = client.getLeaseRenewer(); leaseRenewer1.setRenewalTime(100); OutputStream out1 = client.create(file1, false); Mockito.verify(spyNN, timeout(10000).times(1)).renewLease( Mockito.anyString()); verifyEmptyLease(leaseRenewer1); GenericTestUtils.waitFor(() -> !(leaseRenewer1.isRunning()), 100, 10000); try { out1.write(new byte[256]); fail("existing output stream should be aborted"); } catch (IOException e) { } client.exists(file2); Mockito.doNothing().when(spyNN).renewLease( Mockito.anyString()); final LeaseRenewer leaseRenewer2 = client.getLeaseRenewer(); leaseRenewer2.setRenewalTime(100); OutputStream out2 = client.create(file2, false); Mockito.verify(spyNN, timeout(10000).times(2)).renewLease( Mockito.anyString()); out2.write(new byte[256]); out2.close(); verifyEmptyLease(leaseRenewer2); } finally { cluster.shutdown(); } }
Source:
<code>public void injectorCreated(Injector injector, InjectorConfig config) { <START> synchronized(this){ <END> injectorNames.add(config.getName()); } }</code><technical_language>CopyOnWriteArrayList for injectorNames remove synchronized() statements</technical_language>

Target:
public void injectorCreated(Injector injector, InjectorConfig config) { injectorNames.add(config.getName()); }
Source:
<code>private void updateMediaSessionMetadata() { executor.execute(() -> { Playable p = this.media; MediaMetadataCompat.Builder builder = new MediaMetadataCompat.Builder(); <START> builder.putString(MediaMetadataCompat.METADATA_KEY_ARTIST, p.getFeedTitle()); <END> builder.putString(MediaMetadataCompat.METADATA_KEY_TITLE, p.getEpisodeTitle()); builder.putLong(MediaMetadataCompat.METADATA_KEY_DURATION, p.getDuration()); builder.putString(MediaMetadataCompat.METADATA_KEY_DISPLAY_TITLE, p.getEpisodeTitle()); builder.putString(MediaMetadataCompat.METADATA_KEY_ALBUM, p.getFeedTitle()); if (p.getImageUri() != null) { if (UserPreferences.setLockscreenBackground()) { builder.putString(MediaMetadataCompat.METADATA_KEY_ART_URI, p.getImageUri().toString()); try { Bitmap art = Glide.with(context) .load(p.getImageUri()) .asBitmap() .diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY) .into(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL) .get(); builder.putBitmap(MediaMetadataCompat.METADATA_KEY_ART, art); } catch (Exception e) { Log.e(TAG, Log.getStackTraceString(e)); } } } mediaSession.setMetadata(builder.build()); }); }</code><technical_language>null pointer exceptions this line is executed in tests (after rebasing develop)</technical_language>

Target:
private void updateMediaSessionMetadata() { executor.execute(() -> { final Playable p = this.media; if(p == null) { return; } MediaMetadataCompat.Builder builder = new MediaMetadataCompat.Builder(); builder.putString(MediaMetadataCompat.METADATA_KEY_ARTIST, p.getFeedTitle()); builder.putString(MediaMetadataCompat.METADATA_KEY_TITLE, p.getEpisodeTitle()); builder.putLong(MediaMetadataCompat.METADATA_KEY_DURATION, p.getDuration()); builder.putString(MediaMetadataCompat.METADATA_KEY_DISPLAY_TITLE, p.getEpisodeTitle()); builder.putString(MediaMetadataCompat.METADATA_KEY_ALBUM, p.getFeedTitle()); if (p.getImageUri() != null) { if (UserPreferences.setLockscreenBackground()) { builder.putString(MediaMetadataCompat.METADATA_KEY_ART_URI, p.getImageUri().toString()); try { Bitmap art = Glide.with(context) .load(p.getImageUri()) .asBitmap() .diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY) .into(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL) .get(); builder.putBitmap(MediaMetadataCompat.METADATA_KEY_ART, art); } catch (Exception e) { Log.e(TAG, Log.getStackTraceString(e)); } } } mediaSession.setMetadata(builder.build()); }); }
Source:
<code>public static URI createURI(URI baseURI, java.lang.Class< ? > resourceClass, java.lang.Object... pathElements) { UriBuilder uriBuilder = UriBuilder.fromUri(baseURI).path(resourceClass); List<String> pathVariableNames = null; if (pathElements.length > 0) { pathVariableNames = getVariableNamesFromPathTemplate(uriBuilder.toString()); } Object[] encodedPathElements = new String[pathElements.length]; for (int i = 0; i < pathElements.length; i++) { Object pathElement = pathElements[i]; if (pathElement != null) { try { if (i < pathVariableNames.size() && "spaceName".equals(pathVariableNames.get(i))) { if (!(pathElement instanceof List)) { throw new RuntimeException("The 'spaceName' parameter must be a list!"); } encodedPathElements[i] = generateEncodedSpacesURISegment((List) pathElements[i]); <START> } else if (i < pathVariableNames.size() && "jobId".equals(pathVariableNames.get(i))) { <END> if (!(pathElement instanceof List)) { throw new RuntimeException("The 'jobId' parameter must be a list!"); } encodedPathElements[i] = generateEncodedJobIdURISegment((List) pathElements[i]); } else if (pathElement instanceof EncodedElement) { encodedPathElements[i] = pathElement.toString(); } else { encodedPathElements[i] = URIUtil.encodePath(pathElement.toString()).replaceAll("/", "%2F"); } } catch (URIException e) { throw new RuntimeException("Failed to encode path element: " + pathElements[i], e); } } else { encodedPathElements[i] = null; } } return uriBuilder.buildFromEncoded(encodedPathElements); }</code><technical_language>I this. "jobId" parameter in this generic location</technical_language>

Target:
public static URI createURI(URI baseURI, java.lang.Class< ? > resourceClass, java.lang.Object... pathElements) { UriBuilder uriBuilder = UriBuilder.fromUri(baseURI).path(resourceClass); List<String> pathVariableNames = null; if (pathElements.length > 0) { pathVariableNames = getVariableNamesFromPathTemplate(uriBuilder.toString()); } Object[] encodedPathElements = new String[pathElements.length]; for (int i = 0; i < pathElements.length; i++) { Object pathElement = pathElements[i]; if (pathElement != null) { try { if (i < pathVariableNames.size() && "spaceName".equals(pathVariableNames.get(i))) { if (!(pathElement instanceof List)) { throw new RuntimeException("The 'spaceName' parameter must be a list!"); } encodedPathElements[i] = generateEncodedSpacesURISegment((List) pathElements[i]); } else if (pathElement instanceof List) { encodedPathElements[i] = generateEncodedListURISegment((List) pathElements[i]); } else if (pathElement instanceof EncodedElement) { encodedPathElements[i] = pathElement.toString(); } else { encodedPathElements[i] = URIUtil.encodePath(pathElement.toString()).replaceAll("/", "%2F"); } } catch (URIException e) { throw new RuntimeException("Failed to encode path element: " + pathElements[i], e); } } else { encodedPathElements[i] = null; } } return uriBuilder.buildFromEncoded(encodedPathElements); }
Source:
<code>public int andCardinality(BitmapContainer x) { int card = this.getCardinality(); int cardinality=0; if (card <= ArrayContainer.DEFAULT_MAX_SIZE) { <START> if(card > x.cardinality) card = x.cardinality; <END> cardinality=0; for (int rlepos=0; rlepos < this.nbrruns; ++rlepos) { int runStart = Util.toIntUnsigned(this.getValue(rlepos)); int runEnd = runStart + Util.toIntUnsigned(this.getLength(rlepos)); for (int runValue = runStart; runValue <= runEnd; ++runValue) { if ( x.contains((short) runValue)) { cardinality++; } } } return cardinality; } BitmapContainer answer = x.clone(); int start = 0; for(int rlepos = 0; rlepos < this.nbrruns; ++rlepos ) { int end = Util.toIntUnsigned(this.getValue(rlepos)); Util.resetBitmapRange(answer.bitmap, start, end); start = end + Util.toIntUnsigned(this.getLength(rlepos)) + 1; } Util.resetBitmapRange(answer.bitmap, start, Util.maxLowBitAsInteger() + 1); answer.computeCardinality(); return answer.getCardinality(); }</code><technical_language>This line removed card is afterwards</technical_language>

Target:
public int andCardinality(BitmapContainer x) { int cardinality=0; for (int rlepos=0; rlepos < this.nbrruns; ++rlepos) { int runStart = Util.toIntUnsigned(this.getValue(rlepos)); int runEnd = runStart + Util.toIntUnsigned(this.getLength(rlepos)); for (int runValue = runStart; runValue <= runEnd; ++runValue) { if ( x.contains((short) runValue)) { cardinality++; } } } return cardinality; }
Source:
<code>public void handleSuccess() { super.handleSuccess(); if (isCompleteTrace(trace)) { disposeProvider(false); } else { fNbRead += getNbRead(); synchronized (fRequestSyncObj) { final TmfTimeRange timeRange = fTimeRange; if (timeRange != null) { <START> if (getRange().getEndTime().getValue() > timeRange.getEndTime().getValue()) { <END> startRequest(); } } } } }</code><technical_language>this < instead? if end of time range of this request is time range updated in traceRangeUpdated signal handler</technical_language>

Target:
public void handleSuccess() { super.handleSuccess(); if (isCompleteTrace(trace)) { disposeProvider(false); } else { fNbRead += getNbRead(); synchronized (fRequestSyncObj) { final TmfTimeRange timeRange = fTimeRange; if (timeRange != null) { if (getRange().getEndTime().getValue() < timeRange.getEndTime().getValue()) { startRequest(); } } } } }
Source:
<code>public final <T> void unsafeSubscribe(final Subscriber<T> s) { requireNonNull(s); try { unsafeSubscribe(new CompletableSubscriber() { @Override public void onCompleted() { s.onCompleted(); } @Override public void onError(Throwable e) { s.onError(e); } @Override public void onSubscribe(Subscription d) { s.add(d); } }); <START> RxJavaPlugins.getInstance().getObservableExecutionHook().onSubscribeReturn(s); <END> } catch (NullPointerException ex) { throw ex; } catch (Throwable ex) { Exceptions.throwIfFatal(ex); ex = HOOK.onSubscribeError(ex); ERROR_HANDLER.handleError(ex); throw toNpe(ex); } }</code><technical_language>Completable hook here</technical_language>

Target:
public final <T> void unsafeSubscribe(final Subscriber<T> s) { unsafeSubscribe(s, true); }
Source:
<code>private DatePicker.OnDateChangedListener buildDateListener() { final Handler mainHandler = new Handler(getContext().getMainLooper()); final Runnable updateFormRelevancyRunnable = new Runnable() { @Override public void run() { widgetEntryChanged(); isRelevancyUpdateScheduled = false; <START> blockingActionsManager.registerActionCompletion( <END> BlockingActionsManager.BlockingActionIdentifier.OnDateChanged); } }; return new DatePicker.OnDateChangedListener() { @Override public void onDateChanged(DatePicker view, int year, int month, int day) { if (mPrompt.isReadOnly()) { setAnswer(); } else { Calendar c = Calendar.getInstance(); c.set(year, month, 1); int max = c.getActualMaximum(Calendar.DAY_OF_MONTH); if (day > max) { mDatePicker.updateDate(year, month, max); } else { if (!(mDatePicker.getDayOfMonth() == day && mDatePicker.getMonth() == month && mDatePicker.getYear() == year)) { mDatePicker.updateDate(year, month, day); } } } if (!isRelevancyUpdateScheduled) { blockingActionsManager.registerActionStart( BlockingActionsManager.BlockingActionIdentifier.OnDateChanged); isRelevancyUpdateScheduled = true; mainHandler.postDelayed(updateFormRelevancyRunnable, 750); } } }; }</code><technical_language>In general kinds of callback-centric workflows pretty dangerous for callback completed rely callback handled in this kind of manner. (sorry, clicked enter soon, elaborating)</technical_language>

Target:
private DatePicker.OnDateChangedListener buildDateListener() { return new DatePicker.OnDateChangedListener() { @Override public void onDateChanged(DatePicker view, int year, int month, int day) { if (mPrompt.isReadOnly()) { setAnswer(); } else { Calendar c = Calendar.getInstance(); c.set(year, month, 1); int max = c.getActualMaximum(Calendar.DAY_OF_MONTH); if (day > max) { mDatePicker.updateDate(year, month, max); } else { if (!(mDatePicker.getDayOfMonth() == day && mDatePicker.getMonth() == month && mDatePicker.getYear() == year)) { mDatePicker.updateDate(year, month, day); } } } widgetEntryChangedDelayed(); } }; }
Source:
<code>private void fillVMOrTemplateDetailOptions(final Map<String, List<String>> options, final HypervisorType hypervisorType) { if (options == null) { throw new CloudRuntimeException("Invalid/null detail-options response object passed"); } <START> options.put(VmDetailConstants.KEYBOARD, Arrays.asList("uk", "us", "jp", "fr")); <END> options.put(VmDetailConstants.CPU_CORE_PER_SOCKET, Collections.emptyList()); if (HypervisorType.KVM.equals(hypervisorType)) { options.put(VmDetailConstants.ROOT_DISK_CONTROLLER, Arrays.asList("ide", "scsi", "virtio")); } if (HypervisorType.VMware.equals(hypervisorType)) { options.put(VmDetailConstants.NIC_ADAPTER, Arrays.asList("E1000", "PCNet32", "Vmxnet2", "Vmxnet3")); options.put(VmDetailConstants.ROOT_DISK_CONTROLLER, Arrays.asList("osdefault", "ide", "scsi", "lsilogic", "lsisas1068", "buslogic", "pvscsi")); options.put(VmDetailConstants.DATA_DISK_CONTROLLER, Arrays.asList("osdefault", "ide", "scsi", "lsilogic", "lsisas1068", "buslogic", "pvscsi")); options.put(VmDetailConstants.NESTED_VIRTUALIZATION_FLAG, Arrays.asList("true", "false")); options.put(VmDetailConstants.SVGA_VRAM_SIZE, Collections.emptyList()); } }</code><technical_language>I maintain values in queryService. ask VO</technical_language>

Target:
private void fillVMOrTemplateDetailOptions(final Map<String, List<String>> options, final HypervisorType hypervisorType) { if (options == null) { throw new CloudRuntimeException("Invalid/null detail-options response object passed"); } options.put(VmDetailConstants.KEYBOARD, Arrays.asList("uk", "us", "jp", "fr")); options.put(VmDetailConstants.CPU_CORE_PER_SOCKET, Collections.emptyList()); options.put(VmDetailConstants.ROOT_DISK_SIZE, Collections.emptyList()); if (HypervisorType.KVM.equals(hypervisorType)) { options.put(VmDetailConstants.ROOT_DISK_CONTROLLER, Arrays.asList("osdefault", "ide", "scsi", "virtio")); } if (HypervisorType.VMware.equals(hypervisorType)) { options.put(VmDetailConstants.NIC_ADAPTER, Arrays.asList("E1000", "PCNet32", "Vmxnet2", "Vmxnet3")); options.put(VmDetailConstants.ROOT_DISK_CONTROLLER, Arrays.asList("osdefault", "ide", "scsi", "lsilogic", "lsisas1068", "buslogic", "pvscsi")); options.put(VmDetailConstants.DATA_DISK_CONTROLLER, Arrays.asList("osdefault", "ide", "scsi", "lsilogic", "lsisas1068", "buslogic", "pvscsi")); options.put(VmDetailConstants.NESTED_VIRTUALIZATION_FLAG, Arrays.asList("true", "false")); options.put(VmDetailConstants.SVGA_VRAM_SIZE, Collections.emptyList()); } }
Source:
<code>public static EsLocation fromMap(Map<String, Object> map) { EsLocation esLocation = new EsLocation(); if (map.get(AVAILABILITY_TIME) != null) { esLocation.availabilityTime(new DateTime(map.get(AVAILABILITY_TIME)).toDate()); } if (map.get(AVAILABILITY_END_TIME) != null) { esLocation.availabilityEndTime(new DateTime(map.get(AVAILABILITY_END_TIME)).toDate()); } if (map.get(ALIASES) != null) { <START> if(((Iterable)map.get(ALIASES)).iterator().next().getClass() != Alias.class) { <END> esLocation.aliasesFromEs((List<EsAlias>) ((List<Map>)map.get(ALIASES)).stream() .map(EsAlias::fromMap) .collect(Collectors.toList()) ); } else { esLocation.aliases((Iterable)map.get(ALIASES)); } } return esLocation; }</code><technical_language>This check is unnecessary a misleading. implies get Iterable<Alias> happen</technical_language>

Target:
public static EsLocation fromMap(Map<String, Object> map) { EsLocation esLocation = new EsLocation(); if (map.get(AVAILABILITY_TIME) != null) { esLocation.availabilityTime(new DateTime(map.get(AVAILABILITY_TIME)).toDate()); } if (map.get(AVAILABILITY_END_TIME) != null) { esLocation.availabilityEndTime(new DateTime(map.get(AVAILABILITY_END_TIME)).toDate()); } if (map.get(ALIASES) != null) { esLocation.aliasesFromEs( (List<EsAlias>) ((List<Map>)map.get(ALIASES)).stream() .map(EsAlias::fromMap) .collect(Collectors.toList()) ); } return esLocation; }
Source:
<code>public void putObjectWithSyncNotSupportedVersion() throws Exception { final Arguments args = new Arguments(new String[]{"ds3_java_cli", "-e", "localhost:8080", "-k", "key!", "-a", "access", "-c", "put_object", "-b", "bucketName", "-o", "obj.txt", "--sync"}); final SystemInformation.BuildInformation buildInformation = mock(SystemInformation.BuildInformation.class); when(buildInformation.getVersion()).thenReturn("1.2.0"); final SystemInformation systemInformation = mock(SystemInformation.class); when(systemInformation.getBuildInformation()).thenReturn(buildInformation); final GetSystemInformationResponse systemInformationResponse = mock(GetSystemInformationResponse.class); when(systemInformationResponse.getSystemInformation()).thenReturn(systemInformation); final Ds3Client client = mock(Ds3Client.class); when(client.getSystemInformation(any(GetSystemInformationRequest.class))).thenReturn(systemInformationResponse); final Ds3ClientHelpers helpers = mock(Ds3ClientHelpers.class); final FileUtils mockedFileUtils = mock(FileUtils.class); when(mockedFileUtils.exists(any(Path.class))).thenReturn(true); when(mockedFileUtils.isRegularFile(any(Path.class))).thenReturn(true); when(mockedFileUtils.size(any(Path.class))).thenReturn(100L); PowerMockito.mockStatic(BlackPearlUtils.class); final Ds3Cli cli = new Ds3Cli(new Ds3ProviderImpl(client, helpers), args, mockedFileUtils); cli.call(); <START> fail(); <END> }</code><technical_language>fail is required. test fail expected is above</technical_language>

Target:
public void putObjectWithSyncNotSupportedVersion() throws Exception { final Arguments args = new Arguments(new String[]{"ds3_java_cli", "-e", "localhost:8080", "-k", "key!", "-a", "access", "-c", "put_object", "-b", "bucketName", "-o", "obj.txt", "--sync"}); final SystemInformation.BuildInformation buildInformation = mock(SystemInformation.BuildInformation.class); when(buildInformation.getVersion()).thenReturn("1.2.0"); final SystemInformation systemInformation = mock(SystemInformation.class); when(systemInformation.getBuildInformation()).thenReturn(buildInformation); final GetSystemInformationResponse systemInformationResponse = mock(GetSystemInformationResponse.class); when(systemInformationResponse.getSystemInformation()).thenReturn(systemInformation); final Ds3Client client = mock(Ds3Client.class); when(client.getSystemInformation(any(GetSystemInformationRequest.class))).thenReturn(systemInformationResponse); final Ds3ClientHelpers helpers = mock(Ds3ClientHelpers.class); final FileUtils mockedFileUtils = mock(FileUtils.class); when(mockedFileUtils.exists(any(Path.class))).thenReturn(true); when(mockedFileUtils.isRegularFile(any(Path.class))).thenReturn(true); when(mockedFileUtils.size(any(Path.class))).thenReturn(100L); PowerMockito.mockStatic(BlackPearlUtils.class); final Ds3Cli cli = new Ds3Cli(new Ds3ProviderImpl(client, helpers), args, mockedFileUtils); cli.call(); }
Source:
<code>private boolean detectBarCodeInImage(ArrayList<Uri> selectedImages) { InputStream imageStream = null; for (Uri uri : selectedImages) { if (uri == null) return false; try { <START> imageStream = getContentResolver().openInputStream(uri); <END> } catch (FileNotFoundException e) { e.printStackTrace(); } Bitmap bMap = BitmapFactory.decodeStream(imageStream); int[] intArray = new int[bMap.getWidth() * bMap.getHeight()]; bMap.getPixels(intArray, 0, bMap.getWidth(), 0, 0, bMap.getWidth(), bMap.getHeight()); LuminanceSource source = new RGBLuminanceSource(bMap.getWidth(), bMap.getHeight(), intArray); BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source)); Reader reader = new MultiFormatReader(); try { Hashtable<DecodeHintType, Object> decodeHints = new Hashtable<DecodeHintType, Object>(); decodeHints.put(DecodeHintType.TRY_HARDER, Boolean.TRUE); decodeHints.put(DecodeHintType.PURE_BARCODE, Boolean.TRUE); Result result = reader.decode(bitmap, decodeHints); if (result != null) { mBarcode = result.getText(); } if (mBarcode != null) { return true; } } catch (NotFoundException e) { e.printStackTrace(); } catch (ChecksumException e) { e.printStackTrace(); } catch (FormatException e) { Toast.makeText(getApplicationContext(), getString(R.string.format_error), Toast.LENGTH_SHORT).show(); e.printStackTrace(); } catch (NullPointerException e) { e.printStackTrace(); } } return false; }</code><technical_language>do in another PR maybe: InputStream is closed ( memory leak...)</technical_language>

Target:
private boolean detectBarCodeInImage(ArrayList<Uri> selectedImages) { InputStream imageStream = null; for (Uri uri : selectedImages) { try { imageStream = getContentResolver().openInputStream(uri); } catch (FileNotFoundException e) { e.printStackTrace(); } Bitmap bMap = BitmapFactory.decodeStream(imageStream); int[] intArray = new int[bMap.getWidth() * bMap.getHeight()]; bMap.getPixels(intArray, 0, bMap.getWidth(), 0, 0, bMap.getWidth(), bMap.getHeight()); LuminanceSource source = new RGBLuminanceSource(bMap.getWidth(), bMap.getHeight(), intArray); BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source)); Reader reader = new MultiFormatReader(); try { Hashtable<DecodeHintType, Object> decodeHints = new Hashtable<DecodeHintType, Object>(); decodeHints.put(DecodeHintType.TRY_HARDER, Boolean.TRUE); decodeHints.put(DecodeHintType.PURE_BARCODE, Boolean.TRUE); Result result = reader.decode(bitmap, decodeHints); if (result != null) { mBarcode = result.getText(); } if (mBarcode != null) { return true; } } catch (NotFoundException e) { e.printStackTrace(); } catch (ChecksumException e) { e.printStackTrace(); } catch (FormatException e) { Toast.makeText(getApplicationContext(), getString(R.string.format_error), Toast.LENGTH_SHORT).show(); e.printStackTrace(); } catch (NullPointerException e) { e.printStackTrace(); } } return false; }
Source:
<code>protected TypeBinding findNextTypeBinding(int tokenIndex, Scope scope, PackageBinding packageBinding) { LookupEnvironment env = scope.environment(); try { env.missingClassFileLocation = this; if (this.resolvedType == null) { this.resolvedType = scope.getType(this.tokens[tokenIndex], packageBinding); } else { this.resolvedType = scope.getMemberType(this.tokens[tokenIndex], (ReferenceBinding) this.resolvedType); if (!this.resolvedType.isValidBinding()) { this.resolvedType = new ProblemReferenceBinding( CharOperation.subarray(this.tokens, 0, tokenIndex + 1), (ReferenceBinding)this.resolvedType.closestMatch(), this.resolvedType.problemId()); } } for (int j = 0; j < env.resolutionListeners.length; j++) { <START> env.resolutionListeners[j].recordResolution(this, this.resolvedType); <END> } return this.resolvedType; } catch (AbortCompilation e) { e.updateContext(this, scope.referenceCompilationUnit().compilationResult); throw e; } finally { env.missingClassFileLocation = null; } }</code><technical_language>is this loop executed for valid bindings. pass along, null problem bindings listeners</technical_language>

Target:
protected TypeBinding findNextTypeBinding(int tokenIndex, Scope scope, PackageBinding packageBinding) { LookupEnvironment env = scope.environment(); try { env.missingClassFileLocation = this; if (this.resolvedType == null) { this.resolvedType = scope.getType(this.tokens[tokenIndex], packageBinding); } else { this.resolvedType = scope.getMemberType(this.tokens[tokenIndex], (ReferenceBinding) this.resolvedType); if (!this.resolvedType.isValidBinding()) { this.resolvedType = new ProblemReferenceBinding( CharOperation.subarray(this.tokens, 0, tokenIndex + 1), (ReferenceBinding)this.resolvedType.closestMatch(), this.resolvedType.problemId()); } } return this.resolvedType; } catch (AbortCompilation e) { e.updateContext(this, scope.referenceCompilationUnit().compilationResult); throw e; } finally { env.missingClassFileLocation = null; } }
Source:
<code>public int process(List<File> files) throws CheckstyleException { fireAuditStarted(); for (final FileSetCheck fsc : fileSetChecks) { fsc.beginProcessing(charset); } for (final File file : files) { try { if (!CommonUtils.matchesFileExtension(file, fileExtensions)) { continue; } final String fileName = file.getAbsolutePath(); fireFileStarted(fileName); final SortedSet<LocalizedMessage> fileMessages = Sets.newTreeSet(); try { final FileText theText = new FileText(file.getAbsoluteFile(), charset); for (final FileSetCheck fsc : fileSetChecks) { fileMessages.addAll(fsc.process(file, theText)); } } catch (final IOException ioe) { LOG.debug("IOException occurred.", ioe); fileMessages.add(new LocalizedMessage(0, Definitions.CHECKSTYLE_BUNDLE, "general.exception", new String[] {ioe.getMessage()}, null, getClass(), null)); } fireErrors(fileName, fileMessages); fireFileFinished(fileName); } <START> catch (Exception ex) { <END> throw new CheckstyleException("Exception happens during processing of " + file.getPath(), ex); } } for (final FileSetCheck fsc : fileSetChecks) { fsc.finishProcessing(); } for (final FileSetCheck fsc : fileSetChecks) { fsc.destroy(); } final int errorCount = counter.getCount(); fireAuditFinished(); return errorCount; }</code><technical_language>need catch checked exceptions here, RuntimeException is enough</technical_language>

Target:
public int process(List<File> files) throws CheckstyleException { fireAuditStarted(); for (final FileSetCheck fsc : fileSetChecks) { fsc.beginProcessing(charset); } for (final File file : files) { try { if (!CommonUtils.matchesFileExtension(file, fileExtensions)) { continue; } final String fileName = file.getAbsolutePath(); fireFileStarted(fileName); final SortedSet<LocalizedMessage> fileMessages = Sets.newTreeSet(); try { final FileText theText = new FileText(file.getAbsoluteFile(), charset); for (final FileSetCheck fsc : fileSetChecks) { fileMessages.addAll(fsc.process(file, theText)); } } catch (final IOException ioe) { LOG.debug("IOException occurred.", ioe); fileMessages.add(new LocalizedMessage(0, Definitions.CHECKSTYLE_BUNDLE, "general.exception", new String[] {ioe.getMessage()}, null, getClass(), null)); } fireErrors(fileName, fileMessages); fireFileFinished(fileName); } catch (Exception ex) { throw new CheckstyleException("Exception was thrown while processing " + file.getPath(), ex); } } for (final FileSetCheck fsc : fileSetChecks) { fsc.finishProcessing(); } for (final FileSetCheck fsc : fileSetChecks) { fsc.destroy(); } final int errorCount = counter.getCount(); fireAuditFinished(); return errorCount; }
Source:
<code>public boolean mightContain(Write write) { Type valueType = write.getValue().getType(); <START> incrementCounter(numberOfVerifiesInitiated, 1); <END> boolean mightContain = writeCache.mightContainCached(write.getRecord(), write.getKey(), write.getValue()); int increment = mightContain ? 1 : 0; incrementCounter(numberOfVerifiesTouchingPage, increment); if(valueType == Type.STRING) { mightContain = writeCache.mightContainCached(write.getRecord(), write.getKey(), Value.wrap(Convert.javaToThrift(Tag.create((String) write.getValue().getObject())))); increment = mightContain ? 1 : 0; incrementCounter(numberOfVerifiesTouchingPage, increment); } else if(valueType == Type.TAG) { mightContain = writeCache.mightContainCached(write.getRecord(), write.getKey(), Value.wrap(Convert.javaToThrift(write.getValue().getObject().toString()))); increment = mightContain ? 1 : 0; incrementCounter(numberOfVerifiesTouchingPage, increment); } scanned = mightContain; return mightContain; }</code><technical_language>whats here, formatting hard for whats change. In case, i need changes here</technical_language>

Target:
public boolean mightContain(Write write) { Type valueType = write.getValue().getType(); if(writeCache.mightContainCached(write.getRecord(), write.getKey(), write.getValue())) { return true; } else if(valueType == Type.STRING) { return writeCache.mightContainCached(write.getRecord(), write.getKey(), Value.wrap(Convert.javaToThrift(Tag.create( (String) write.getValue().getObject())))); } else if(valueType == Type.TAG) { return writeCache.mightContainCached(write.getRecord(), write.getKey(), Value.wrap(Convert.javaToThrift( write.getValue().getObject().toString()))); } else { return false; } }
Source:
<code>private synchronized void unregisterDiscoveryService(ThingUID bridgeUID) { ServiceRegistration<?> serviceReg = discoveryServiceRegs.get(bridgeUID); if (serviceReg != null) { WeatherUndergroundDiscoveryService service = (WeatherUndergroundDiscoveryService) bundleContext .getService(serviceReg.getReference()); service.deactivate(); <START> serviceReg.unregister(); <END> discoveryServiceRegs.remove(bridgeUID); } }</code><technical_language>reference implementation in hue binding I guess this turned around: unregister service first, DS remove service usages. this safely deactivate service</technical_language>

Target:
private synchronized void unregisterDiscoveryService(ThingUID bridgeUID) { ServiceRegistration<?> serviceReg = discoveryServiceRegs.remove(bridgeUID); if (serviceReg != null) { WeatherUndergroundDiscoveryService service = (WeatherUndergroundDiscoveryService) bundleContext .getService(serviceReg.getReference()); serviceReg.unregister(); service.deactivate(); } }
Source:
<code>public ProblemModule(boolean stacktraces, Map<Integer, StatusType> statuses) { this.stacktraces = stacktraces; <START> this.statuses = Collections.unmodifiableMap(statuses); <END> }</code><technical_language>I a defensive copy ore suitable</technical_language>

Target:
private ProblemModule(boolean stacktraces, Map<Integer, StatusType> statuses) { this.stacktraces = stacktraces; this.statuses = statuses; }
Source:
<code>public TkCORS(final Take take, final String... domains) { this.origin = take; this.alloweddomains = new HashSet<String>(); if (domains != null) { for (final String domain : domains) { <START> this.alloweddomains.add(domain); <END> } } }</code><technical_language>@antonini Collections.addAll instead of a loop</technical_language>

Target:
public TkCORS(final Take take, final String... domains) { this.origin = take; this.allowed = new HashSet<String>(Arrays.asList(domains)); }
Source:
<code>public void onAdClicked() { if (mInterstitialListener != null) { DuAdMediation.d(TAG, "Interstitial onAdClicked "); <START> mInterstitialListener.onAdClicked(mAdapter); <END> } }</code><technical_language>onAdLeftApplication() callback is missing for Interstitial Ads. Please [this](<LINK_0> existing adapter for implementation</technical_language>

Target:
public void onAdClicked() { if (mInterstitialListener != null) { DuAdMediation.d(TAG, "Interstitial onAdClicked "); mInterstitialListener.onAdClicked(mAdapter); mInterstitialListener.onAdLeftApplication(mAdapter); } }
Source:
<code>public SimSwitcherQuery(Similarity similarity, Query subQuery) { this.similarity = <START> Objects.requireNonNull(similarity); <END> this.subQuery = Objects.requireNonNull(subQuery); }</code><technical_language>static import</technical_language>

Target:
public SimSwitcherQuery(Similarity similarity, Query subQuery) { this.similarity = requireNonNull(similarity); this.subQuery = requireNonNull(subQuery); }
Source:
<code>private Intent makeTimerIntent() { if (checkBox.isChecked()) { <START> return new Intent(getActivity(), MusicService.class) <END> .setAction(MusicService.ACTION_PENDING_QUIT); } return new Intent(getActivity(), MusicService.class) .setAction(MusicService.ACTION_QUIT); }</code><technical_language>Nitpick: a redundant if a variable assignment for action</technical_language>

Target:
private Intent makeTimerIntent() { Intent intent = new Intent(getActivity(), MusicService.class); if (shouldFinishLastSong.isChecked()) { return intent.setAction(MusicService.ACTION_PENDING_QUIT); } return intent.setAction(MusicService.ACTION_QUIT); }
Source:
<code>public void setConnection(final IDockerConnection connection) { if (connection != null && connection.equals(this.connection)) { return; } if (this.connection != null) { this.connection.removeContainerListener(this); } this.connection = connection; if (this.viewer != null && this.connection != null) { final Job refreshJob = new Job( DVMessages.getString("ContainersRefresh.msg")) { @Override protected IStatus run(IProgressMonitor monitor) { connection.getContainers(true); return Status.OK_STATUS; } }; <START> refreshJob.addJobChangeListener(new <END> JobChangeAdapter() { @Override public void done(IJobChangeEvent event) { connection.addContainerListener(DockerContainersView.this); Display.getDefault().asyncExec(() -> { viewer.setInput(connection); refreshViewTitle(); }); } }); refreshJob.schedule(); } else if (this.viewer != null) { viewer.setInput(new IDockerContainer[0]); form.setText(DVMessages.getString(NoConnectionSelected)); } }</code><technical_language>I remove this flow before</technical_language>

Target:
public void setConnection(final IDockerConnection connection) { if (connection != null && connection.equals(this.connection)) { return; } if (this.connection != null) { this.connection.removeContainerListener(this); } this.connection = connection; if (this.viewer != null && this.connection != null) { final Job refreshJob = new Job( DVMessages.getString("ContainersRefresh.msg")) { @Override protected IStatus run(IProgressMonitor monitor) { connection.getContainers(true); connection.addContainerListener(DockerContainersView.this); Display.getDefault().asyncExec(() -> { viewer.setInput(connection); refreshViewTitle(); }); return Status.OK_STATUS; } }; refreshJob.schedule(); } else if (this.viewer != null) { viewer.setInput(new IDockerContainer[0]); form.setText(DVMessages.getString(NoConnectionSelected)); } }
Source:
<code>private void checkServiceAccountRoles(UserRepresentation serviceAccount, boolean rolesExpected) { Assert.assertTrue("User is a service account", serviceAccount.getUsername().startsWith(ServiceAccountConstants.SERVICE_ACCOUNT_USER_PREFIX)); Assert.assertNull("Password should be null", serviceAccount.getCredentials()); if (rolesExpected) { List<String> realmRoles = serviceAccount.getRealmRoles(); Assert.assertEquals(3, realmRoles.size()); Assert.assertTrue(realmRoles.containsAll(Arrays.asList("uma_authorization", "user", "offline_access"))); Map<String, List<String>> clientRoles = serviceAccount.getClientRoles(); <START> Assert.assertNotNull(clientRoles.get("test-app-service-account")); Assert.assertEquals(2, clientRoles.get("test-app-service-account").size()); Assert.assertTrue(clientRoles.get("test-app-service-account").containsAll(Arrays.asList("test-app-service-account", "test-app-service-account-parent"))); <END> Assert.assertEquals(2, clientRoles.get("account").size()); Assert.assertTrue(clientRoles.get("account").containsAll(Arrays.asList("manage-account", "view-profile"))); } else { Assert.assertNull("Service account should be exported without realm roles", serviceAccount.getRealmRoles()); Assert.assertNull("Service account should be exported without client roles", serviceAccount.getClientRoles()); } }</code><technical_language>a suggestion write this in a more simple way. stay is if want. suggestion assertThat(clientRoles.get("test-app-service-account"), containsInAnyOrder("test-app-service-account", "test-app-service-account-parent")); This approach applied other asserts in this method</technical_language>

Target:
private void checkServiceAccountRoles(UserRepresentation serviceAccount, boolean rolesExpected) { Assert.assertTrue("User is a service account", serviceAccount.getUsername().startsWith(ServiceAccountConstants.SERVICE_ACCOUNT_USER_PREFIX)); Assert.assertNull("Password should be null", serviceAccount.getCredentials()); if (rolesExpected) { List<String> realmRoles = serviceAccount.getRealmRoles(); Assert.assertThat("Realm roles are OK", realmRoles, Matchers.containsInAnyOrder("uma_authorization", "user", "offline_access")); Map<String, List<String>> clientRoles = serviceAccount.getClientRoles(); Assert.assertNotNull("Client roles are exported", clientRoles); Assert.assertThat("Client roles for test-app-service-account are OK", clientRoles.get("test-app-service-account"), Matchers.containsInAnyOrder("test-app-service-account", "test-app-service-account-parent")); Assert.assertThat("Client roles for account are OK", clientRoles.get("account"), Matchers.containsInAnyOrder("manage-account", "view-profile")); } else { Assert.assertNull("Service account should be exported without realm roles", serviceAccount.getRealmRoles()); Assert.assertNull("Service account should be exported without client roles", serviceAccount.getClientRoles()); } }
Source:
<code><START> private Class getValueType(String name) { <END> switch (name) { case KEY_TABLE : return OmKeyInfo.class; case VOLUME_TABLE : return OmVolumeArgs.class; case BUCKET_TABLE : return OmBucketInfo.class; default: return null; } }</code><technical_language>of a unit test fail if OM schema changes</technical_language>

Target:
protected Class getValueType(String name) { switch (name) { case KEY_TABLE : return OmKeyInfo.class; case VOLUME_TABLE : return OmVolumeArgs.class; case BUCKET_TABLE : return OmBucketInfo.class; default: return null; } }
Source:
<code>void verifySetterBraceStyle(SetterClauseContext ctx) { ParseTree leftSibling = ParseTreeUtil.getLeftSibling(ctx.codeBlock()); <START> Token set = (leftSibling instanceof TerminalNodeImpl) ? ((TerminalNodeImpl) leftSibling).getSymbol() <END> : ((ParserRuleContext) leftSibling).getStop(); verifyCodeBlockOpenBraceStyle(ctx.codeBlock(), set, Messages.SETTER); verifyBodyCloseBraceStyle(ctx.codeBlock(), Messages.SETTER); }</code><technical_language>Please remove extra space =</technical_language>

Target:
void verifySetterBraceStyle(SetterClauseContext ctx) { ParseTree leftSibling = ParseTreeUtil.getLeftSibling(ctx.codeBlock()); Token set = ParseTreeUtil.getStopTokenForNode(leftSibling); verifyCodeBlockOpenBraceStyle(ctx.codeBlock(), set, Messages.SETTER); verifyBodyCloseBraceStyle(ctx.codeBlock(), Messages.SETTER); }
Source:
<code>public Set<Tag> updateTags(@ApiParam(hidden = true) @Auth User user, @ApiParam(value = "Tool to modify.", required = true) @PathParam("containerId") Long containerId, @ApiParam(value = "List of modified tags", required = true) List<Tag> tags) { Tool c = toolDAO.findById(containerId); Helper.checkEntry(c); Helper.checkUser(user, c); Map<Long, Tag> mapOfExistingTags = new HashMap<>(); for (Tag tag : c.getTags()) { mapOfExistingTags.put(tag.getId(), tag); } for (Tag tag : tags) { if (mapOfExistingTags.containsKey(tag.getId())) { Tag existingTag = mapOfExistingTags.get(tag.getId()); <START> if (!existingTag.getCwlPath().equals(tag.getCwlPath()) || !existingTag.getWdlPath().equals(tag.getWdlPath()) <END> || !existingTag.getDockerfilePath().equals(tag.getDockerfilePath()) || !existingTag.getCwlTestParameterFile().equals(tag.getCwlTestParameterFile()) || !existingTag.getWdlTestParameterFile().equals(tag.getWdlTestParameterFile())) { existingTag.setDirtyBit(true); } existingTag.updateByUser(tag); } } Tool result = toolDAO.findById(containerId); Helper.checkEntry(result); return result.getTags(); }</code><technical_language>Kinda if this cleaner <LINK_0> normal of</technical_language>

Target:
public Set<Tag> updateTags(@ApiParam(hidden = true) @Auth User user, @ApiParam(value = "Tool to modify.", required = true) @PathParam("containerId") Long containerId, @ApiParam(value = "List of modified tags", required = true) List<Tag> tags) { Tool c = toolDAO.findById(containerId); Helper.checkEntry(c); Helper.checkUser(user, c); Map<Long, Tag> mapOfExistingTags = new HashMap<>(); for (Tag tag : c.getTags()) { mapOfExistingTags.put(tag.getId(), tag); } for (Tag tag : tags) { if (mapOfExistingTags.containsKey(tag.getId())) { Tag existingTag = mapOfExistingTags.get(tag.getId()); boolean dirtyBitCheck = new EqualsBuilder() .append(existingTag.getCwlPath(), tag.getCwlPath()) .append(existingTag.getWdlPath(), tag.getWdlPath()) .append(existingTag.getDockerfilePath(), tag.getDockerfilePath()) .append(existingTag.getCwlTestParameterFile(), tag.getCwlTestParameterFile()) .append(existingTag.getWdlTestParameterFile(), tag.getWdlTestParameterFile()) .isEquals(); if (!dirtyBitCheck) { existingTag.setDirtyBit(true); } existingTag.updateByUser(tag); } } Tool result = toolDAO.findById(containerId); Helper.checkEntry(result); return result.getTags(); }