auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public void onSelectedThread(long threadId) { selectedThreadId = threadId; selectedFrameIndex = 0; <START> for (ThreadDump td : threadDump) { <END> if (td.getId() == selectedThreadId) { view.setFrames(td.getFrames()); } } updateStackFrameDump(); }</code><technical_language>I prefer streams for loops</technical_language>

Target:
public void onSelectedThread(long threadId) { updateStackFrameDump(threadId); onSelectedFrame(0); }
Source:
<code>public List<Integer> getFavoriteProjectLocationIds(final String programUUID) { final List<ProgramFavorite> programFavorites = <START> this.getProgramFavoriteDao().getProgramFavorites(ProgramFavorite.FavoriteType.LOCATION, Integer.MAX_VALUE, programUUID); <END> final List<Integer> favoriteLocationIds = new ArrayList<>(); if (programFavorites != null && !programFavorites.isEmpty()) { for (final ProgramFavorite programFavorite : programFavorites) { favoriteLocationIds.add(programFavorite.getEntityId()); } } return favoriteLocationIds; }</code><technical_language>@cuenyad please DaoFactory get programFavoriteDao</technical_language>

Target:
public List<Integer> getFavoriteProjectLocationIds(final String programUUID) { final List<ProgramFavorite> programFavorites = this.daoFactory.getProgramFavoriteDao().getProgramFavorites(ProgramFavorite.FavoriteType.LOCATION, Integer.MAX_VALUE, programUUID); final List<Integer> favoriteLocationIds = new ArrayList<>(); if (programFavorites != null && !programFavorites.isEmpty()) { for (final ProgramFavorite programFavorite : programFavorites) { favoriteLocationIds.add(programFavorite.getEntityId()); } } return favoriteLocationIds; }
Source:
<code>public DigitalTwinsClientBuilder httpLogOptions(HttpLogOptions logOptions) { <START> this.logOptions = Objects.requireNonNull(logOptions, "'logOptions' cannot be null."); <END> return this; }</code><technical_language>HttpLoggingPolicy allows for null HttpLogOptions effectively a no-op, needs null checked here</technical_language>

Target:
public DigitalTwinsClientBuilder httpLogOptions(HttpLogOptions logOptions) { this.logOptions = logOptions; return this; }
Source:
<code>public ClassDiagramPatternConfigurationPage() { super("PatternSelection"); setTitle("Pattern Creation"); <START> setDescription("Configure the Class Diagram tools."); <END> }</code><technical_language>page configure base id. Replacement proposition: Configure creation of Class Diagram skeleton</technical_language>

Target:
public ClassDiagramPatternConfigurationPage() { super("PatternSelection"); setTitle("Pattern Creation"); setDescription("Configure the creation of your Class Diagram skeleton."); }
Source:
<code>public VisualizationType getVisualizationType() { String uriParts[] = getContent().getUrl().split(":"); <START> String derivedType = uriParts[uriParts.length-1]; <END> VisualizationType visualizationType = VisualizationType.TABLE; if (isLocal()) { visualizationType = VisualizationType.get(derivedType); } return visualizationType; }</code><technical_language>array is empty? add a check</technical_language>

Target:
public VisualizationType getVisualizationType() { VisualizationType visualizationType = VisualizationType.TABLE; String uriParts[] = getContent().getUrl().split(":"); if (uriParts.length > 0 && isLocal()) { String derivedType = uriParts[uriParts.length-1]; visualizationType = VisualizationType.of(derivedType); } return visualizationType; }
Source:
<code>public Subscriber<? super T> call(final Subscriber<? super R> subscriber) { final AtomicReference<Subscriber<T>> result = new AtomicReference<Subscriber<T>>(); Observable<T> observable = Observable.create(new Observable.OnSubscribe<T>() { @Override public void call(final Subscriber<? super T> sub) { <START> Observer<T> observer = new Observer<T>() { <END> @Override public void onCompleted() { sub.onCompleted(); } @Override public void onError(Throwable e) { sub.onError(e); } @Override public void onNext(T t) { sub.onNext(t); } }; result.set(Subscribers.from(observer)); subscriber.add(result.get()); } }); function.call(observable).unsafeSubscribe(subscriber); return result.get(); }</code><technical_language>Is this wrapping necessary? pass out result</technical_language>

Target:
public Subscriber<? super T> call(final Subscriber<? super R> subscriber) { final AtomicReference<Subscriber<T>> result = new AtomicReference<Subscriber<T>>(); final CountDownLatch latch = new CountDownLatch(1); Observable<T> observable = Observable.create(new Observable.OnSubscribe<T>() { @Override public void call(final Subscriber<? super T> sub) { Observer<T> observer = new Observer<T>() { @Override public void onCompleted() { sub.onCompleted(); } @Override public void onError(Throwable e) { sub.onError(e); } @Override public void onNext(T t) { sub.onNext(t); } }; result.set(Subscribers.from(observer)); latch.countDown(); } }); function.call(observable).unsafeSubscribe(subscriber); try { latch.await(); } catch (InterruptedException e) { throw new RuntimeException(e); } subscriber.add(result.get()); return result.get(); }
Source:
<code>protected AbstractMessageActionCommand(@Nonnull final String op, final boolean isUid, final int start, final int end, @Nonnull final String targetFolder) { <START> this(op, isUid, start + ImapClientConstants.COLON + end, <END> targetFolder); }</code><technical_language>change StringBuilder</technical_language>

Target:
protected AbstractMessageActionCommand(@Nonnull final String op, final boolean isUid, final int start, final int end, @Nonnull final String targetFolder) { this(op, isUid, new StringBuilder(String.valueOf(start)).append(ImapClientConstants.COLON).append(end).toString(), targetFolder); }
Source:
<code>boolean isOAuth2Flow() { String authorizationMode = this.getClientConfiguration().getAuthorizationMode(); <START> return authorizationMode != null && authorizationMode.equals("PrivateKey"); <END> }</code><technical_language>block this sounds talked team. personal pref detect configuration possible, currently, need properties, orgUrl token, in cases assume SSWS Similar private key, assume if orgUrl, privateKey, scopes set assume PrivateKey. This done a future optimization (and compatible)</technical_language>

Target:
boolean isOAuth2Flow() { return this.getClientConfiguration().getAuthorizationMode() == AuthorizationMode.PRIVATE_KEY; }
Source:
<code>private void populateEntity(Cdn entity, CdnDTO dto) { if (entity == null) { throw new IllegalArgumentException("the Cdn model entity is null"); } if (dto == null) { throw new IllegalArgumentException("the Cdn dto is null"); } if (dto.getName() != null) { entity.setName(dto.getName()); } <START> if (dto.getLabel() != null) { <END> entity.setLabel(dto.getLabel()); } if (dto.getUrl() != null) { entity.setUrl(dto.getUrl()); } if (dto.getCertificate() != null) { CertificateDTO certDTO = dto.getCertificate(); CdnCertificate cdnCert; if (certDTO.getKey() != null && certDTO.getCert() != null) { cdnCert = new CdnCertificate(); cdnCert.setCert(certDTO.getCert()); cdnCert.setKey(certDTO.getKey()); if (certDTO.getSerial() != null) { CertificateSerialDTO certSerialDTO = certDTO.getSerial(); CertificateSerial certSerial = new CertificateSerial(); certSerial.setExpiration(certSerialDTO.getExpiration()); if (certSerialDTO.getSerial() != null) { certSerial.setSerial(certSerialDTO.getSerial().longValue()); } if (certSerialDTO.isCollected() != null) { certSerial.setCollected(certSerialDTO.isCollected()); } if (certSerialDTO.isRevoked() != null) { certSerial.setRevoked(certSerialDTO.isRevoked()); } cdnCert.setSerial(certSerial); } entity.setCertificate(cdnCert); } else { throw new BadRequestException(i18n.tr("cdn certificate has null key or cert.")); } } }</code><technical_language>allow setting label. This appears external ID for this entity</technical_language>

Target:
private void populateEntity(Cdn entity, CdnDTO dto) { if (entity == null) { throw new IllegalArgumentException("the Cdn model entity is null"); } if (dto == null) { throw new IllegalArgumentException("the Cdn dto is null"); } if (dto.getName() != null) { entity.setName(dto.getName()); } if (dto.getUrl() != null) { entity.setUrl(dto.getUrl()); } if (dto.getCertificate() != null) { CertificateDTO certDTO = dto.getCertificate(); CdnCertificate cdnCert; if (certDTO.getKey() != null && certDTO.getCert() != null) { cdnCert = new CdnCertificate(); cdnCert.setCert(certDTO.getCert()); cdnCert.setKey(certDTO.getKey()); if (certDTO.getSerial() != null) { CertificateSerialDTO certSerialDTO = certDTO.getSerial(); CertificateSerial certSerial = new CertificateSerial(); certSerial.setExpiration(certSerialDTO.getExpiration()); if (certSerialDTO.getSerial() != null) { certSerial.setSerial(certSerialDTO.getSerial().longValue()); } if (certSerialDTO.isCollected() != null) { certSerial.setCollected(certSerialDTO.isCollected()); } if (certSerialDTO.isRevoked() != null) { certSerial.setRevoked(certSerialDTO.isRevoked()); } cdnCert.setSerial(certSerial); } entity.setCertificate(cdnCert); } else { throw new BadRequestException(i18n.tr("cdn certificate has null key or cert.")); } } }
Source:
<code>static String[] parseForFormalTypeParameters(String s) { ArrayList<String> sigs = new ArrayList<>(10); int beginToken = 1; while (s.charAt(beginToken) != '>') { int endToken = FormalTypeParameter.formalTypeParameterEnds(s, beginToken); sigs.add(s.substring(beginToken, endToken)); beginToken = endToken; } Iterator<String> it = sigs.iterator(); String[] result = new String[sigs.size()]; <START> Arrays.setAll(result, j -> it.next()); <END> return result; }</code><technical_language>toArray</technical_language>

Target:
static String[] parseForFormalTypeParameters(String s) { ArrayList<String> sigs = new ArrayList<>(10); int beginToken = 1; while (s.charAt(beginToken) != '>') { int endToken = FormalTypeParameter.formalTypeParameterEnds(s, beginToken); sigs.add(s.substring(beginToken, endToken)); beginToken = endToken; } return sigs.toArray(new String[0]); }
Source:
<code>public void updateGist_OK() throws IOException { Gist gist = new Gist(); <START> gist.setId("test_repository"); <END> gistService.updateGist(gist); verify(gitHubClient).put("/gists/test_repository.json", gist, Gist.class); }</code><technical_language>gist.setId("1");</technical_language>

Target:
public void updateGist_OK() throws IOException { Gist gist = new Gist(); gist.setId("123"); gistService.updateGist(gist); verify(gitHubClient).put("/gists/123.json", gist, Gist.class); }
Source:
<code>public TrackedIssue setComponentKey(String componentKey) { <START> Preconditions.checkArgument(StringUtils.countMatches(componentKey, ":") <= 1, "componentKey should not have branch"); <END> this.componentKey = componentKey; return this; }</code><technical_language>":" is allowed in projet keys</technical_language>

Target:
public TrackedIssue setComponentKey(String componentKey) { this.componentKey = componentKey; return this; }
Source:
<code>public boolean hasMore() { if (it.hasNext()) { return true; } try { <START> jsonParser.close(); <END> if (++fileIndex >= files.size() || files.get(fileIndex).length() == 0) { return false; } jsonParser = jsonFactory.createParser(files.get(fileIndex)); it = jsonParser.readValuesAs(Row.class); return true; } catch (IOException e) { throw new RuntimeException(e); } }</code><technical_language>UT is failing, need a null check here</technical_language>

Target:
public boolean hasMore() { if (it.hasNext()) { return true; } try { if (jsonParser != null) { jsonParser.close(); } if (++fileIndex >= files.size() || files.get(fileIndex).length() == 0) { return false; } jsonParser = jsonFactory.createParser(files.get(fileIndex)); it = jsonParser.readValuesAs(Row.class); return true; } catch (IOException e) { throw new RuntimeException(e); } }
Source:
<code>public void run() { log.debug("Auth Token context persist consumer is started"); while (true) { try { AuthContextTokenDO authContextTokenDO = authContextTokenQueue.take(); if (authContextTokenDO != null) { if (authContextTokenDO.getAuthzCodeDO() == null) { log.debug("Auth Token Data removing Task is started to run"); TokenMgtDAO tokenMgtDAO = new TokenMgtDAO(); <START> tokenMgtDAO.doExpireAuthorizationCode(authContextTokenDO.getAuthzCode(), authContextTokenDO <END> .getTokenId()); } else { log.debug("Auth Token Data persisting Task is started to run"); TokenMgtDAO tokenMgtDAO = new TokenMgtDAO(); tokenMgtDAO.persistAuthorizationCode(authContextTokenDO.getAuthzCode(), authContextTokenDO.getConsumerKey(), authContextTokenDO.getCallbackUrl(), authContextTokenDO.getAuthzCodeDO()); } } } catch (InterruptedException | IdentityOAuth2Exception e) { log.error(e); } } }</code><technical_language>deactivate</technical_language>

Target:
public void run() { log.debug("Auth Token context persist consumer is started"); while (true) { try { AuthContextTokenDO authContextTokenDO = authContextTokenQueue.take(); if (authContextTokenDO != null) { if (authContextTokenDO.getAuthzCodeDO() == null) { log.debug("Auth Token Data removing Task is started to run"); TokenMgtDAO tokenMgtDAO = new TokenMgtDAO(); tokenMgtDAO.deactivateAuthorizationCode(authContextTokenDO.getAuthzCode(), authContextTokenDO .getTokenId()); } else { log.debug("Auth Token Data persisting Task is started to run"); TokenMgtDAO tokenMgtDAO = new TokenMgtDAO(); tokenMgtDAO.persistAuthorizationCode(authContextTokenDO.getAuthzCode(), authContextTokenDO.getConsumerKey(), authContextTokenDO.getCallbackUrl(), authContextTokenDO.getAuthzCodeDO()); } } } catch (InterruptedException | IdentityOAuth2Exception e) { log.error(e); } } }
Source:
<code>public boolean equals(Object o) { if (o == null) { return false; } if (this == o) { return true; } <START> if (!(this.getClass().equals(o.getClass()))) { <END> return false; } SitePropertySource that = (SitePropertySource) o; return Objects.equal(mFilename, that.mFilename); }</code><technical_language>is this of inheritance</technical_language>

Target:
public boolean equals(Object o) { if (this == o) { return true; } if (o == null || this.getClass() != o.getClass()) { return false; } SitePropertySource that = (SitePropertySource) o; return Objects.equal(mFilename, that.mFilename); }
Source:
<code>protected void validateParameters(VnicProfile vnicProfile) { validateParameters(vnicProfile, "name"); <START> if (!vnicProfile.isSetNetwork() || !vnicProfile.getNetwork().isSetId()) { <END> vnicProfile.setNetwork(new Network()); vnicProfile.getNetwork().setId(networkId); } }</code><technical_language>this is a part of validateParameters() logic</technical_language>

Target:
protected void validateParameters(VnicProfile vnicProfile) { validateParameters(vnicProfile, "name"); }
Source:
<code><START> public void setUp() throws Exception { <END> metadata = new MetadataImpl.MetadataImplBuilder(DEF_SET_ID).build(); when(definitionUtils.getQualifier(eq(DEF_SET_ID))).thenReturn(qualifier); preferencesHolders = spy(new ManagedInstanceStub<>(preferencesHolder)); doAnswer(invocation -> { ParameterizedCommand<Profile> callback = (ParameterizedCommand<Profile>) invocation.getArguments()[1]; callback.execute(profile); return null; }).when(profilePreferencesLoader).load(eq(metadata), any(ParameterizedCommand.class), any(ParameterizedCommand.class)); when(profile.getProfileId()).thenReturn(PROFILE_ID); tested = new StunnerProjectPreferencesRegistryLoader(definitionUtils, preferencesHolders, preferences, textPreferences, profilePreferencesLoader); }</code><technical_language>This method produce exception</technical_language>

Target:
public void setUp() { metadata = new MetadataImpl.MetadataImplBuilder(DEF_SET_ID).build(); when(definitionUtils.getQualifier(eq(DEF_SET_ID))).thenReturn(qualifier); preferencesHolders = spy(new ManagedInstanceStub<>(preferencesHolder)); doAnswer(invocation -> { ParameterizedCommand<Profile> callback = (ParameterizedCommand<Profile>) invocation.getArguments()[1]; callback.execute(profile); return null; }).when(profilePreferencesLoader).load(eq(metadata), any(ParameterizedCommand.class), any(ParameterizedCommand.class)); when(profile.getProfileId()).thenReturn(PROFILE_ID); tested = new StunnerProjectPreferencesRegistryLoader(definitionUtils, preferencesHolders, preferences, textPreferences, profilePreferencesLoader); }
Source:
<code>public static ProfileTypeBuilder<TriggerProfileType> newTrigger(ProfileTypeUID profileTypeUID, String label) { return new ProfileTypeBuilder<>(profileTypeUID, label, <START> (leProfileTypeUID, leLabel, leSupportedItemTypes, supportedItemTypesOfChannel, <END> leSupportedChannelTypeUIDs) -> new TriggerProfileTypeImpl(leProfileTypeUID, leLabel, leSupportedItemTypes, leSupportedChannelTypeUIDs)); }</code><technical_language>this called leSupportedItemTypesOfChannel</technical_language>

Target:
public static ProfileTypeBuilder<TriggerProfileType> newTrigger(ProfileTypeUID profileTypeUID, String label) { return new ProfileTypeBuilder<>(profileTypeUID, label, (leProfileTypeUID, leLabel, leSupportedItemTypes, leSupportedItemTypesOfChannel, leSupportedChannelTypeUIDs) -> new TriggerProfileTypeImpl(leProfileTypeUID, leLabel, leSupportedItemTypes, leSupportedChannelTypeUIDs)); }
Source:
<code>ChecksDetails extractChecksDetails() { String text = extractChecksText(); System.out.println(text); ChecksOutput output = new ChecksOutput.ChecksOutputBuilder() .withTitle(extractChecksTitle()) <START> .withSummary("<sub>Send us [feedback](<LINK_0>") <END> .withText(text) .build(); return new ChecksDetails.ChecksDetailsBuilder() .withName("Tests") .withStatus(ChecksStatus.COMPLETED) .withConclusion(summary.getFailCount() > 0 ? ChecksConclusion.FAILURE : ChecksConclusion.SUCCESS) .withDetailsURL(jenkinsFacade.getAbsoluteUrl(action.run.getUrl(), action.getUrlName())) .withOutput(output) .build(); }</code><technical_language>works for you. GitHub issues enough for developers, a survey is for common users</technical_language>

Target:
ChecksDetails extractChecksDetails() { String testsURL = DisplayURLProvider.get().getTestsURL(action.run); ChecksOutput output = new ChecksOutput.ChecksOutputBuilder() .withTitle(extractChecksTitle()) .withSummary("<sub>Send us [feedback](<LINK_0>") .withText(extractChecksText(testsURL)) .build(); return new ChecksDetails.ChecksDetailsBuilder() .withName("Tests") .withStatus(ChecksStatus.COMPLETED) .withConclusion(summary.getFailCount() > 0 ? ChecksConclusion.FAILURE : ChecksConclusion.SUCCESS) .withDetailsURL(testsURL) .withOutput(output) .build(); }
Source:
<code>public MqttException(int reasonCode) { <START> super(); <END> this.reasonCode = reasonCode; }</code><technical_language>explicit call super() is unnecessary (see other constructors, too)</technical_language>

Target:
public MqttException(int reasonCode) { this.reasonCode = reasonCode; }
Source:
<code>private List<Object> getNearestMatches(ResourceInfo resourceInfo, DimensionInfo dimension, List<Object> values, String dimensionName) throws IOException { NearestMatchFinder finder = NearestMatchFinder.get(resourceInfo, dimension, dimensionName); List<Object> result = new ArrayList<>(); for (Object value : values) { <START> Object nearest = finder.getNearest(value); <END> if (nearest == null) { NearestMatchWarningAppender.addWarning(resourceInfo.prefixedName(), dimensionName, null, dimension.getUnits(), NotFound); result.add(value); } else if (value.equals(nearest)) { result.add(value); } else { NearestMatchWarningAppender.addWarning(resourceInfo.prefixedName(), dimensionName, nearest, dimension.getUnits(), Nearest); result.add(nearest); } } return result; }</code><technical_language>is timeout control (rendering timeout), source list ... long if call T1/T2/smallPeriod</technical_language>

Target:
private List<Object> getNearestMatches(ResourceInfo resourceInfo, DimensionInfo dimension, List<Object> values, String dimensionName) throws IOException { int maxRenderingTime = getMaxRenderingTime(); long maxTime = maxRenderingTime > 0 ? System.currentTimeMillis() + maxRenderingTime * 1000 : -1; NearestMatchFinder finder = NearestMatchFinder.get(resourceInfo, dimension, dimensionName); List<Object> result = new ArrayList<>(); for (Object value : values) { Object nearest = finder.getNearest(value); if (nearest == null) { NearestMatchWarningAppender.addWarning(resourceInfo.prefixedName(), dimensionName, null, dimension.getUnits(), NotFound); result.add(value); } else if (value.equals(nearest)) { result.add(value); } else { NearestMatchWarningAppender.addWarning(resourceInfo.prefixedName(), dimensionName, nearest, dimension.getUnits(), Nearest); result.add(nearest); } if (maxTime > 0 && System.currentTimeMillis() > maxTime) { throw new ServiceException( "Nearest matching dimension values required more time than allowed and has been forcefully stopped. " + "The max rendering time is " + (maxRenderingTime) + "s"); } } return result; }
Source:
<code>public void setTitle(CharSequence title) { final View toolbar = findViewById(R.id.toolbar); if (toolbar != null) { <START> final View titleView = toolbar.findViewById(R.id.toolbar_title_view); <END> if (titleView != null && titleView instanceof TextView) { ((TextView) titleView).setText(title); super.setTitle(null); return; } } super.setTitle(title); }</code><technical_language>getTitleView function instead</technical_language>

Target:
public void setTitle(CharSequence title) { final View toolbar = findViewById(R.id.toolbar); if (toolbar != null) { final TextView titleView = getTitleView(); if (titleView != null) { titleView.setText(title); } } super.setTitle(title); }
Source:
<code>void initWithConfig(IClientConfig clientConfig, IRule rule, IPing ping) { this.config = clientConfig; String clientName = clientConfig.getClientName(); this.name = clientName; int pingIntervalTime = Integer.parseInt("" + clientConfig.getProperty( CommonClientConfigKey.NFLoadBalancerPingInterval, Integer.parseInt("30"))); int maxTotalPingTime = Integer.parseInt("" + clientConfig.getProperty( CommonClientConfigKey.NFLoadBalancerMaxTotalPingTime, Integer.parseInt("2"))); setPingInterval(pingIntervalTime); setMaxTotalPingTime(maxTotalPingTime); setRule(rule); setPing(ping); setLoadBalancerStats(new LoadBalancerStats(clientName)); rule.setLoadBalancer(this); if (ping instanceof AbstractLoadBalancerPing) { ((AbstractLoadBalancerPing) ping).setLoadBalancer(this); } <START> logger.info("Client: instantiated a LoadBalancer: {}", name, toString()); <END> boolean enablePrimeConnections = clientConfig.get( CommonClientConfigKey.EnablePrimeConnections, DefaultClientConfigImpl.DEFAULT_ENABLE_PRIME_CONNECTIONS); if (enablePrimeConnections) { this.setEnablePrimingConnections(true); PrimeConnections primeConnections = new PrimeConnections( this.getName(), clientConfig); this.setPrimeConnections(primeConnections); } init(); }</code><technical_language>pass this instead of calling toString()? evaluate toString logging</technical_language>

Target:
void initWithConfig(IClientConfig clientConfig, IRule rule, IPing ping) { this.config = clientConfig; String clientName = clientConfig.getClientName(); this.name = clientName; int pingIntervalTime = Integer.parseInt("" + clientConfig.getProperty( CommonClientConfigKey.NFLoadBalancerPingInterval, Integer.parseInt("30"))); int maxTotalPingTime = Integer.parseInt("" + clientConfig.getProperty( CommonClientConfigKey.NFLoadBalancerMaxTotalPingTime, Integer.parseInt("2"))); setPingInterval(pingIntervalTime); setMaxTotalPingTime(maxTotalPingTime); setRule(rule); setPing(ping); setLoadBalancerStats(new LoadBalancerStats(clientName)); rule.setLoadBalancer(this); if (ping instanceof AbstractLoadBalancerPing) { ((AbstractLoadBalancerPing) ping).setLoadBalancer(this); } logger.info("Client: instantiated a LoadBalancer: {}", name, this); boolean enablePrimeConnections = clientConfig.get( CommonClientConfigKey.EnablePrimeConnections, DefaultClientConfigImpl.DEFAULT_ENABLE_PRIME_CONNECTIONS); if (enablePrimeConnections) { this.setEnablePrimingConnections(true); PrimeConnections primeConnections = new PrimeConnections( this.getName(), clientConfig); this.setPrimeConnections(primeConnections); } init(); }
Source:
<code>public void noData() { <START> FlowPanel noDataPanel = new FlowPanel(); <END> noDataPanel.setWidth(width + "px"); noDataPanel.setHeight(height + "px"); Label lblNoData = new Label(C3DisplayerConstants.INSTANCE.common_noData()); noDataPanel.add(lblNoData); displayerPanel.clear(); displayerPanel.add(noDataPanel); }</code><technical_language>@jesuino please GWT.create here</technical_language>

Target:
public void noData() { FlowPanel noDataPanel = GWT.create(FlowPanel.class); noDataPanel.setWidth(width + "px"); noDataPanel.setHeight(height + "px"); Label lblNoData = GWT.create(Label.class); lblNoData.setText(C3DisplayerConstants.INSTANCE.common_noData()); noDataPanel.add(lblNoData); displayerPanel.clear(); displayerPanel.add(noDataPanel); }
Source:
<code>public void doPut(HttpServletRequest request, HttpServletResponse response) { this.path = getPath(request); <START> org.geoserver.platform.resource.Resource script; <END> try { if (path.contains(":")) { path = path.replace(":","/"); } script = scriptMgr.script(path); } catch(IllegalStateException e) { throw new RestException(format("Error creating script file %s", path), HttpStatus.INTERNAL_SERVER_ERROR, e); } try { BufferedWriter w = new BufferedWriter(new OutputStreamWriter(script.out())); try { IOUtils.copy(request.getInputStream(), w); w.flush(); } finally { IOUtils.closeQuietly(w); } } catch(IOException e) { throw new RestException(format("Error writing script file %s", path), HttpStatus.INTERNAL_SERVER_ERROR, e); } response.setStatus(201); }</code><technical_language>need package name</technical_language>

Target:
public void doPut(HttpServletRequest request, HttpServletResponse response) { this.path = getPath(request); try { if (path.contains(":")) { path = path.replace(":","/"); } script = scriptMgr.script(path); } catch(IllegalStateException e) { throw new RestException(format("Error creating script file %s", path), HttpStatus.INTERNAL_SERVER_ERROR, e); } try { BufferedWriter w = new BufferedWriter(new OutputStreamWriter(script.out())); try { IOUtils.copy(request.getInputStream(), w); w.flush(); } finally { IOUtils.closeQuietly(w); } } catch(IOException e) { throw new RestException(format("Error writing script file %s", path), HttpStatus.INTERNAL_SERVER_ERROR, e); } response.setStatus(201); }
Source:
<code>public void registerSegmentHandoffCallback( SegmentDescriptor descriptor, Executor exec, Runnable handOffRunnable ) { log.info("Adding SegmentHandoffCallback for dataSource[%s] Segment[%s]", dataSource, descriptor); <START> handOffCallbacks.put(descriptor, new Pair<>(exec, handOffRunnable)); <END> }</code><technical_language>putIfAbsent, return false if there? current pretty easy accidentally overwrite a callback</technical_language>

Target:
public boolean registerSegmentHandoffCallback( SegmentDescriptor descriptor, Executor exec, Runnable handOffRunnable ) { log.info("Adding SegmentHandoffCallback for dataSource[%s] Segment[%s]", dataSource, descriptor); Pair<Executor, Runnable> prev = handOffCallbacks.putIfAbsent( descriptor, new Pair<>(exec, handOffRunnable) ); return prev == null; }
Source:
<code>public static void init(Context context, String baseUrl, String dsn) { <START> Sentry.getInstance().context = context; <END> Sentry.getInstance().baseUrl = baseUrl; Sentry.getInstance().dsn = dsn; Sentry.getInstance().packageName = context.getPackageName(); Sentry.getInstance().client = new ProtocolClient(baseUrl); Sentry.getInstance().client.setDebug(true); submitStackTraces(context); UncaughtExceptionHandler currentHandler = Thread.getDefaultUncaughtExceptionHandler(); if (currentHandler != null) { Log.d("Debugged", "current handler class="+currentHandler.getClass().getName()); } if (!(currentHandler instanceof SentryUncaughtExceptionHandler)) { Thread.setDefaultUncaughtExceptionHandler( new SentryUncaughtExceptionHandler(currentHandler, context)); } }</code><technical_language>tabbing</technical_language>

Target:
public static void init(Context context, String baseUrl, String dsn) { Sentry.getInstance().context = context; Sentry.getInstance().baseUrl = baseUrl; Sentry.getInstance().dsn = dsn; Sentry.getInstance().packageName = context.getPackageName(); submitStackTraces(context); UncaughtExceptionHandler currentHandler = Thread.getDefaultUncaughtExceptionHandler(); if (currentHandler != null) { Log.d("Debugged", "current handler class="+currentHandler.getClass().getName()); } if (!(currentHandler instanceof SentryUncaughtExceptionHandler)) { Thread.setDefaultUncaughtExceptionHandler( new SentryUncaughtExceptionHandler(currentHandler, context)); } }
Source:
<code>private boolean updateNote(long noteId, String[] fields, Set<String> tags) { <START> if (!canUpdateNotesForModelId(-1L)) { END> throw new IllegalStateException("update permission not granted"); } Uri.Builder builder = FlashCardsContract.Note.CONTENT_URI.buildUpon(); Uri contentUri = builder.appendPath(Long.toString(noteId)).build(); ContentValues values = new ContentValues(); if (fields != null) { values.put(FlashCardsContract.Note.FLDS, Utils.joinFields(fields)); } if (tags != null) { values.put(FlashCardsContract.Note.TAGS, Utils.joinTags(tags)); } int numRowsUpdated = mResolver.update(contentUri, values, null, null); return numRowsUpdated > 0; }</code><technical_language>This is kind of pointless permissions check is/should in provider</technical_language>

Target:
private boolean updateNote(long noteId, String[] fields, Set<String> tags) { Uri.Builder builder = FlashCardsContract.Note.CONTENT_URI.buildUpon(); Uri contentUri = builder.appendPath(Long.toString(noteId)).build(); ContentValues values = new ContentValues(); if (fields != null) { values.put(FlashCardsContract.Note.FLDS, Utils.joinFields(fields)); } if (tags != null) { values.put(FlashCardsContract.Note.TAGS, Utils.joinTags(tags)); } int numRowsUpdated = mResolver.update(contentUri, values, null, null); return numRowsUpdated > 0; }
Source:
<code>public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) { if (registry.containsBeanDefinition(MESSAGE_HISTORY_CONFIGURER)) { throw new BeanDefinitionStoreException("At most one 'MessageHistoryConfigurer' can be registered within a context."); <START> } <END> Map<String,Object> annotationAttributes = importingClassMetadata.getAnnotationAttributes(MessageHistory.class.getName()); AbstractBeanDefinition messageHistoryConfigurer = BeanDefinitionBuilder.genericBeanDefinition(MessageHistoryConfigurer.class) .addPropertyValue("componentNamePatterns", annotationAttributes.get("value")) .getBeanDefinition(); registry.registerBeanDefinition(MESSAGE_HISTORY_CONFIGURER, messageHistoryConfigurer); }</code><technical_language>a bit more forgiving - skip multiples, long attribute content registered</technical_language>

Target:
public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) { Map<String,Object> annotationAttributes = importingClassMetadata.getAnnotationAttributes(EnableMessageHistory.class.getName()); Object componentNamePatterns = annotationAttributes.get("value"); if (componentNamePatterns instanceof String[]) { StringBuilder componentNamePatternsString = new StringBuilder(); for (String s : (String[]) componentNamePatterns) { componentNamePatternsString.append(s).append(","); } componentNamePatterns = componentNamePatternsString.substring(0, componentNamePatternsString.length() - 1); } if (!registry.containsBeanDefinition(MESSAGE_HISTORY_CONFIGURER)) { Set<Object> componentNamePatternsSet = new ManagedSet<Object>(); componentNamePatternsSet.add(componentNamePatterns); AbstractBeanDefinition messageHistoryConfigurer = BeanDefinitionBuilder.genericBeanDefinition(MessageHistoryConfigurer.class) .addPropertyValue("componentNamePatternsSet", componentNamePatternsSet) .getBeanDefinition(); registry.registerBeanDefinition(MESSAGE_HISTORY_CONFIGURER, messageHistoryConfigurer); } else { @SuppressWarnings("unchecked") Set<Object> currentComponentNamePatternsSet = (Set<Object>) registry.getBeanDefinition(MESSAGE_HISTORY_CONFIGURER) .getPropertyValues().getPropertyValue("componentNamePatternsSet").getValue(); currentComponentNamePatternsSet.add(componentNamePatterns); } }
Source:
<code>public PagedReferenceImpl(final PagePosition position, final PagedMessage message, final PageSubscription subscription) { this.position = position; this.message = new WeakReference<>(message); this.subscription = subscription; if (message != null) { this.largeMessage = message.getMessage().isLargeMessage() ? IS_LARGE_MESSAGE : IS_NOT_LARGE_MESSAGE; this.transactionID = message.getTransactionID(); this.messageID = message.getMessage().getMessageID(); <START> this.priority = message.getMessage().getPriority(); <END> this.durable = message.getMessage().isDurable() ? IS_DURABLE : IS_NOT_DURABLE; getPersistentSize(); } else { this.largeMessage = UNDEFINED_IS_LARGE_MESSAGE; this.transactionID = -2; this.messageID = -1; this.messageSize = -1; this.priority = -1; this.durable = UNDEFINED_IS_DURABLE; } }</code><technical_language>deliveryTime set in constructor transactionID , messageID , :)</technical_language>

Target:
public PagedReferenceImpl(final PagePosition position, final PagedMessage message, final PageSubscription subscription) { this.position = position; this.message = new WeakReference<>(message); this.subscription = subscription; if (message != null) { this.largeMessage = message.getMessage().isLargeMessage() ? IS_LARGE_MESSAGE : IS_NOT_LARGE_MESSAGE; this.transactionID = message.getTransactionID(); this.messageID = message.getMessage().getMessageID(); this.durable = message.getMessage().isDurable() ? IS_DURABLE : IS_NOT_DURABLE; this.deliveryTime = message.getMessage().getScheduledDeliveryTime(); getPersistentSize(); } else { this.largeMessage = UNDEFINED_IS_LARGE_MESSAGE; this.transactionID = -2; this.messageID = -1; this.messageSize = -1; this.durable = UNDEFINED_IS_DURABLE; this.deliveryTime = UNDEFINED_DELIVERY_TIME; } }
Source:
<code>protected static boolean isProductionBuild() { final Properties props = new Properties(); final InputStream input = XmlOutput.class.getClassLoader().getResourceAsStream("/config.properties"); if (input == null) { <START> System.err.println("Could not find property file."); <END> } else { try { props.load(input); final String productionBuild = (String) props.get("productionBuild"); if (productionBuild.equals("true")) { return true; } else { System.err.println("Unknown productionBuild value[" + productionBuild + "]. Defaulting to fail for unknown XML elements."); } } catch (final IOException e) { System.err.println("Failed to load property file."); } } return false; }</code><technical_language>Instead of logging stdout log sl4fj logger</technical_language>

Target:
protected static boolean isProductionBuild() { final Properties props = new Properties(); final InputStream input = XmlOutput.class.getClassLoader().getResourceAsStream("/config.properties"); if (input == null) { LOG.error("Could not find property file."); } else { try { props.load(input); final String productionBuild = (String) props.get("productionBuild"); if (productionBuild.equals("true")) { return true; } else { LOG.error("Unknown productionBuild value[" + productionBuild + "]. Defaulting to fail for unknown XML elements."); } } catch (final IOException e) { LOG.error("Failed to load property file: ", e); } } return false; }
Source:
<code>private synchronized void startLogMaker() { if (nextLogMaker != null) { return; } nextLogMaker = new SimpleThreadPool(1, "WALog creator"); nextLogMaker.submit(new LoggingRunnable(log, new Runnable() { @Override public void run() { final ServerResources conf = tserver.getServerConfig(); final VolumeManager fs = conf.getFileSystem(); while (!nextLogMaker.isShutdown()) { DfsLogger alog = null; try { <START> if (log.isDebugEnabled()) <END> log.debug("Creating next WAL"); alog = new DfsLogger(tserver.getContext(), conf, syncCounter, flushCounter); alog.open(tserver.getClientAddressString()); String fileName = alog.getFileName(); if (log.isDebugEnabled()) log.debug("Created next WAL " + fileName); tserver.addNewLogMarker(alog); while (!nextLog.offer(alog, 12, TimeUnit.HOURS)) { log.info("Our WAL was not used for 12 hours: {}", fileName); } } catch (Exception t) { log.error("Failed to open WAL", t); if (alog != null) { try { alog.close(); } catch (Exception e) { log.error("Failed to close WAL after it failed to open", e); } try { Path path = alog.getPath(); if (fs.exists(path)) { fs.delete(path); } } catch (Exception e) { log.warn("Failed to delete a WAL that failed to open", e); } } try { nextLog.offer(t, 12, TimeUnit.HOURS); } catch (InterruptedException ex) { } } } } })); }</code><technical_language>this check removed</technical_language>

Target:
private synchronized void startLogMaker() { if (nextLogMaker != null) { return; } nextLogMaker = new SimpleThreadPool(1, "WALog creator"); nextLogMaker.submit(new LoggingRunnable(log, new Runnable() { @Override public void run() { final ServerResources conf = tserver.getServerConfig(); final VolumeManager fs = conf.getFileSystem(); while (!nextLogMaker.isShutdown()) { DfsLogger alog = null; try { log.debug("Creating next WAL"); alog = new DfsLogger(tserver.getContext(), conf, syncCounter, flushCounter); alog.open(tserver.getClientAddressString()); String fileName = alog.getFileName(); log.debug("Created next WAL {}", fileName); tserver.addNewLogMarker(alog); while (!nextLog.offer(alog, 12, TimeUnit.HOURS)) { log.info("Our WAL was not used for 12 hours: {}", fileName); } } catch (Exception t) { log.error("Failed to open WAL", t); if (alog != null) { try { alog.close(); } catch (Exception e) { log.error("Failed to close WAL after it failed to open", e); } try { Path path = alog.getPath(); if (fs.exists(path)) { fs.delete(path); } } catch (Exception e) { log.warn("Failed to delete a WAL that failed to open", e); } } try { nextLog.offer(t, 12, TimeUnit.HOURS); } catch (InterruptedException ex) { } } } } })); }
Source:
<code>public void showLastAccessedView(final String lastAccessedSubSectionId, final String courseId, final View view) { if ( isActivityStarted() ) { if (!AppConstants.offline_flag) { if(courseId!=null && lastAccessedSubSectionId!=null){ logger.debug("lastAccessedSubSectionId : " + lastAccessedSubSectionId); CourseComponent lastAccessComponent = courseManager.getComponentById(courseId, lastAccessedSubSectionId); if (lastAccessComponent != null) { if (!lastAccessComponent.isContainer()) { if (lastAccessComponent.getParent() != null) lastAccessComponent = lastAccessComponent.getParent(); if (lastAccessComponent.getParent() != null) { lastAccessComponent = lastAccessComponent.getParent(); } } PrefManager.UserPrefManager userPrefManager = new PrefManager.UserPrefManager(MainApplication.instance()); if ( userPrefManager.isUserPrefVideoModel() && lastAccessComponent.getVideos().isEmpty() ) return; <START> final CourseComponent finalLastAccessComponent = lastAccessComponent; <END> super.showLastAccessedView(null, " " + lastAccessComponent.getName(), new View.OnClickListener() { @Override public void onClick(View v) { long currentTime = SystemClock.elapsedRealtime(); if (currentTime - lastClickTime > 1000) { lastClickTime = currentTime; environment.getRouter().showCourseContainerOutline( CourseVideoListActivity.this, courseData, finalLastAccessComponent.getId()); } } }); } else { hideLastAccessedView(view); } } } else { hideLastAccessedView(view); } } }</code><technical_language>declare original variable final create another extra variable..</technical_language>

Target:
public void showLastAccessedView(final String lastAccessedSubSectionId, final String courseId, final View view) { if ( isActivityStarted() ) { if (!AppConstants.offline_flag) { if(courseId!=null && lastAccessedSubSectionId!=null){ CourseComponent lastAccessComponent = courseManager.getComponentById(courseId, lastAccessedSubSectionId); if (lastAccessComponent != null) { if (!lastAccessComponent.isContainer()) { if (lastAccessComponent.getParent() != null) lastAccessComponent = lastAccessComponent.getParent(); if (lastAccessComponent.getParent() != null) { lastAccessComponent = lastAccessComponent.getParent(); } } PrefManager.UserPrefManager userPrefManager = new PrefManager.UserPrefManager(MainApplication.instance()); if ( userPrefManager.isUserPrefVideoModel() && lastAccessComponent.getVideos().isEmpty() ) return; final CourseComponent finalLastAccessComponent = lastAccessComponent; super.showLastAccessedView(null, " " + lastAccessComponent.getName(), new View.OnClickListener() { @Override public void onClick(View v) { long currentTime = SystemClock.elapsedRealtime(); if (currentTime - lastClickTime > 1000) { lastClickTime = currentTime; environment.getRouter().showCourseContainerOutline( CourseVideoListActivity.this, courseData, finalLastAccessComponent.getId()); } } }); } else { hideLastAccessedView(view); } } } else { hideLastAccessedView(view); } } }
Source:
<code>public String getError() { return String.format("getModificationTime mismatch - s3: %s, ms: %s", getS3FileStatus().getModificationTime(), getMsFileStatus().getModificationTime()); <START> } <END></code><technical_language>Changed file timestamp mismatch</technical_language>

Target:
public String getError() { return String.format("File timestamp mismatch - S3: %s, MS: %s", getS3FileStatus().getModificationTime(), getMsFileStatus().getModificationTime()); }
Source:
<code><START> public StreamEmitterAnnotationBeanPostProcessor streamEmitterAnnotationBeanPostProcessor() { <END> return new StreamEmitterAnnotationBeanPostProcessor(); }</code><technical_language>BeanPostProcessor s static bean methods: <LINK_0> > Also, careful BeanPostProcessor BeanFactoryPostProcessor definitions @Bean. declared static @Bean methods, triggering instantiation of configuration class. Otherwise, @Autowired @Value work configuration class is created a bean instance early</technical_language>

Target:
public static StreamEmitterAnnotationBeanPostProcessor streamEmitterAnnotationBeanPostProcessor() { return new StreamEmitterAnnotationBeanPostProcessor(); }
Source:
<code>public ReactiveCouchbaseOperations getCouchbaseOperations(){ <START> return operations; <END> }</code><technical_language>bit converted reactive type adoption repository layer</technical_language>

Target:
public RxJavaCouchbaseOperations getCouchbaseOperations(){ return operations; }
Source:
<code>public static <T> void forEach(T[] array, Consumer<T> consumer) { Objects.requireNonNull(array, "Array must be non-null."); final int size = array.length; if (size == 0) { return; } else if (size == 1) { consumer.accept(array[0]); return; } <START> for (int i = 0; i < size; ++i) { <END> consumer.accept(array[i]); } }</code><technical_language>I for loop good enough - allocation, do 0 < size, 1 < size comparisons</technical_language>

Target:
public static <T> void forEach(T[] array, Consumer<T> consumer) { final int size = Objects.requireNonNull(array, "Array must be non-null.").length; for (int i = 0; i < size; ++i) { consumer.accept(array[i]); } }
Source:
<code>private void enableHook() { if (getEntity() == null || getSelectedItems() == null || getSelectedItems().size() == 0) { return; } ArrayList<VdcActionParametersBase> list = new ArrayList<VdcActionParametersBase>(); for (Object item : getSelectedItems()) { GlusterHookEntity hook = (GlusterHookEntity) item; list.add(new GlusterHookParameters(getEntity().getId(), hook.getId())); } <START> Frontend.RunMultipleAction(VdcActionType.EnableGlusterHook, list); <END> }</code><technical_language>need for this change</technical_language>

Target:
private void enableHook() { if (getEntity() == null || getSelectedItems() == null || getSelectedItems().size() == 0) { return; } ArrayList<VdcActionParametersBase> list = new ArrayList<VdcActionParametersBase>(); for (Object item : getSelectedItems()) { GlusterHookEntity hook = (GlusterHookEntity) item; list.add(new GlusterHookParameters(getEntity().getId(), hook.getId())); } Frontend.RunMultipleAction(VdcActionType.EnableGlusterHook, list, null, null); }
Source:
<code>public byte[] transform(String name, String transformedName, byte[] basicClass) { if (TrackerRegistry.TRACKER_CLASSES.contains(name)) { return basicClass; } final ClassReader classReader = new ClassReader(basicClass); final ClassNode classNode = new ClassNode(ASM5); classReader.accept(classNode, ClassReader.EXPAND_FRAMES); final Set<String> addedMethods = new HashSet<>(); boolean change = false; for (MethodNode methodNode : new ArrayList<>(classNode.methods)) { <START> if (processMethodNode(classNode, methodNode, addedMethods)) { <END> change = true; } } if (!change) { return basicClass; } final ClassWriter classWriter = new ClassWriter(ASM5); classNode.accept(classWriter); return classWriter.toByteArray(); }</code><technical_language>This reeks of needing visitor pattern tree pattern. tree for this</technical_language>

Target:
public byte[] transform(String name, String transformedName, byte[] basicClass) { if (basicClass == null || TrackerRegistry.trackerClasses.contains(name)) { return basicClass; } final ClassReader classReader = new ClassReader(basicClass); final ClassWriter classWriter = new ClassWriter(classReader, 0); final TrackerClassVisitor classVisitor = new TrackerClassVisitor(classWriter); classReader.accept(classVisitor, 0); return classWriter.toByteArray(); }
Source:
<code>protected synchronized void removeHandler(ThingHandler thingHandler) { if (thingHandler instanceof BluetoothAdapter) { UID uid = ((BluetoothAdapter) thingHandler).getUID(); <START> ServiceRegistration<?> serviceReg = this.serviceRegs.get(uid); <END> if (serviceReg != null) { serviceReg.unregister(); serviceRegs.remove(uid); } } }</code><technical_language>optimization: if remove(uid) need do 3 lines</technical_language>

Target:
protected synchronized void removeHandler(ThingHandler thingHandler) { if (thingHandler instanceof BluetoothAdapter) { UID uid = ((BluetoothAdapter) thingHandler).getUID(); ServiceRegistration<?> serviceReg = this.serviceRegs.remove(uid); if (serviceReg != null) { serviceReg.unregister(); } } }
Source:
<code>protected FormModelHandler getHandlerForForm( FormDefinition form, Path path ) { FormModelHandler handler = modelHandlerManager.getFormModelHandler( form.getModel().getClass() ); <START> if ( handler == null ) { <END> return null; } handler.init( form.getModel(), path ); return handler; }</code><technical_language>"Common opinion" appears try Optional<V> in *new* code; this is a refactor live null values</technical_language>

Target:
protected FormModelHandler getHandlerForForm( FormDefinition form, Path path ) { Optional<FormModelHandler> optional = Optional.ofNullable( modelHandlerManager.getFormModelHandler( form.getModel().getClass() ) ); if ( optional.isPresent() ) { optional.get().init( form.getModel(), path ); } return optional.orElse( null ); }