auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public void setVideoConstraints(Map<String, VideoConstraints> newVideoConstraintsMap) { Map<String, VideoConstraints> videoConstraintsMapCopy = this.videoConstraintsMap; boolean needsUpdate = newVideoConstraintsMap.size() != videoConstraintsMapCopy.size(); if (!needsUpdate) { for (Map.Entry<String, VideoConstraints> videoConstraintsEntry : newVideoConstraintsMap.entrySet()) { String endpointId = videoConstraintsEntry.getKey(); VideoConstraints newVideoConstraints = videoConstraintsEntry.getValue(); VideoConstraints oldVideoConstraints = videoConstraintsMapCopy.get(endpointId); if (!newVideoConstraints.equals(oldVideoConstraints)) { needsUpdate = true; break; <START> } <END> } } if (needsUpdate) { this.videoConstraintsMap = newVideoConstraintsMap; update(); } }</code><technical_language>Instead of copy, I do: VideoConstraints oldVideoConstraints = videoConstraintsMap.put(endpointId, newVideoConstraints); if (!newVideoConstraints.equals(oldVideoConstraints)) { needsUpdate = true; } Though, closer now, if replace map I able do a map equals comparison if differ</technical_language>

Target:
public void setVideoConstraints(Map<String, VideoConstraints> newVideoConstraintsMap) { if (!this.videoConstraintsMap.equals(newVideoConstraintsMap)) { this.videoConstraintsMap = newVideoConstraintsMap; update(); } }
Source:
<code>private void writePreviousDirectory() { if (previousDirectory == null) { return; } try { FileWriter writer = new FileWriter("prev_directory.txt"); writer.write(previousDirectory.getAbsolutePath()); writer.close(); } catch (IOException e) { <START> } <END> }</code><technical_language>Empty catch is a nogo, a logger</technical_language>

Target:
private void writePreviousDirectory() { if (previousDirectory == null) { return; } try { FileWriter writer = new FileWriter("prev_directory.txt"); writer.write(previousDirectory.getAbsolutePath()); writer.close(); } catch (IOException e) { LOG.log(Level.WARNING, e.getMessage()); } }
Source:
<code>public void testGetJobManagerLogsList() throws Exception { List<LogInfo> logsList = Arrays.asList( new LogInfo("jobmanager.log", 0L), new LogInfo("jobmanager.out", 0L), new LogInfo("test.log", 0L)); JobManagerLogListHandler jobManagerLogListHandler = createHandler(logsList); LogListInfo logListInfo = jobManagerLogListHandler.handleRequest(testRequest, mockRestfulGateway).get(); <START> assertThat(logListInfo.getLogInfos(), hasSize(logsList.size())); <END> }</code><technical_language>good if test if file size is file names set correctly. Do idea this achieved</technical_language>

Target:
public void testGetJobManagerLogsList() throws Exception { String jobmanagerLogContent = "jobmanager log content"; String jobmanagerStdoutContent = "jobmanager stdout content"; String jobmanagerCustomLogContent = "jobmanager custom log content"; LogInfo jobmanagerLog = new LogInfo("jobmanager.log", jobmanagerLogContent.length()); LogInfo jobmanagerStdout = new LogInfo("jobmanager.out", jobmanagerStdoutContent.length()); LogInfo customLog = new LogInfo("test.log", jobmanagerCustomLogContent.length()); Map<LogInfo, String> logInfo2ContentMap = new HashMap<>(3); logInfo2ContentMap.put(jobmanagerLog, jobmanagerLogContent); logInfo2ContentMap.put(jobmanagerStdout, jobmanagerStdoutContent); logInfo2ContentMap.put(customLog, jobmanagerCustomLogContent); Map<String, LogInfo> fileNameAndLogInfoMap = new HashMap<>(3); fileNameAndLogInfoMap.put(jobmanagerLog.getName(), jobmanagerLog); fileNameAndLogInfoMap.put(jobmanagerStdout.getName(), jobmanagerStdout); fileNameAndLogInfoMap.put(customLog.getName(), customLog); JobManagerLogListHandler jobManagerLogListHandler = createHandler(logInfo2ContentMap); LogListInfo logListInfo = jobManagerLogListHandler.handleRequest(testRequest, mockRestfulGateway).get(); assertThat(logListInfo.getLogInfos(), hasSize(logInfo2ContentMap.size())); for (LogInfo logInfo : logListInfo.getLogInfos()) { assertEquals(logInfo, fileNameAndLogInfoMap.get(logInfo.getName())); } }
Source:
<code>private void createLinkedRename() { cursorPosition = textEditor.getCursorPosition(); LinkedModelParams params = dtoFactory.createDto(LinkedModelParams.class); params.setUri(textEditor.getDocument().getFile().getLocation().toString()); params.setOffset(textEditor.getCursorOffset()); <START> extensionServiceClient <END> .getLinkedModeModel(params) .then( linkedModeModel -> { clientServerEventService .sendFileTrackingSuspendEvent() .then( success -> { if (linkedModeModel == null) { showError(); isActiveLinkedEditor = false; return; } activateLinkedModeIntoEditor(linkedModeModel); }); }) .catchError( arg -> { isActiveLinkedEditor = false; showError(); }); }</code><technical_language>do ensure file tracking is if is error here</technical_language>

Target:
private void createLinkedRename() { cursorPosition = textEditor.getCursorPosition(); Document document = textEditor.getDocument(); TextDocumentPositionParams params = dtoBuildHelper.createTDPP(document, textEditor.getCursorOffset()); extensionServiceClient .getLinkedModeModel(params) .then( ranges -> { clientServerEventService .sendFileTrackingSuspendEvent() .then( success -> { if (ranges == null || ranges.isEmpty()) { showError(); isActiveLinkedEditor = false; clientServerEventService.sendFileTrackingResumeEvent(); return; } activateLinkedModeIntoEditor(ranges); }); }) .catchError( arg -> { isActiveLinkedEditor = false; showError(); }); }
Source:
<code>private static void waitUntilState(final String serverName, final String state) throws TimeoutException { RetryTaskExecutor<Void> taskExecutor = new RetryTaskExecutor<Void>(); taskExecutor.retryTask(new Callable<Void>() { public Void call() throws Exception { String serverStatus = this.checkServerStatus(); if (!serverStatus.equals(state)) throw new Exception("Server not in state " + state); return null; } private String checkServerStatus() { ModelNode op = new ModelNode(); <START> op.get(OP_ADDR).add(HOST, "master"); <END> op.get(OP_ADDR).add(SERVER_CONFIG, serverName); op.get(OP).set(READ_ATTRIBUTE_OPERATION); op.get(NAME).set(STATUS); return domainMasterLifecycleUtil.executeForResult(op).asString(); } }); }</code><technical_language>imported MASTER constant, instead of "master" string</technical_language>

Target:
private static void waitUntilState(final String serverName, final String state) throws TimeoutException { RetryTaskExecutor<Void> taskExecutor = new RetryTaskExecutor<Void>(); taskExecutor.retryTask(new Callable<Void>() { public Void call() throws Exception { String serverStatus = this.checkServerStatus(); if (!serverStatus.equals(state)) throw new Exception("Server not in state " + state); return null; } private String checkServerStatus() { ModelNode op = new ModelNode(); op.get(OP_ADDR).add(HOST, MASTER); op.get(OP_ADDR).add(SERVER_CONFIG, serverName); op.get(OP).set(READ_ATTRIBUTE_OPERATION); op.get(NAME).set(STATUS); return domainMasterLifecycleUtil.executeForResult(op).asString(); } }); }
Source:
<code>protected void testExecute_searchCourseId_shouldSucceed() { loginAsAdmin(); String[] submissionParams = new String[] { Const.ParamsNames.ADMIN_SEARCH_KEY, acc.getCourseId() }; SearchInstructorsAction action = getAction(submissionParams); JsonResult result = getJsonResult(action); InstructorsData response = (InstructorsData) result.getOutput(); assertTrue(response.getInstructors().stream() <START> .anyMatch(i -> i.getName().equals(acc.getName()))); <END> }</code><technical_language>changes in this file unrelated</technical_language>

Target:
protected void testExecute_searchCourseId_shouldSucceed() { loginAsAdmin(); String[] submissionParams = new String[] { Const.ParamsNames.ADMIN_SEARCH_KEY, acc.getCourseId() }; SearchInstructorsAction action = getAction(submissionParams); JsonResult result = getJsonResult(action); InstructorsData response = (InstructorsData) result.getOutput(); assertTrue(response.getInstructors().stream() .filter(i -> i.getName().equals(acc.getName())) .findAny() .isPresent()); }
Source:
<code>public MegaDeviceHttpSocket(Socket s) { this.s = s; try { this.is = s.getInputStream(); this.os = s.getOutputStream(); } catch (IOException e) { <START> logger.debug("ERROR: " + e.getMessage()); <END> } }</code><technical_language>This a higher severity. Also, parameterized logging instead of string concatenation</technical_language>

Target:
public MegaDeviceHttpSocket(Socket s) { this.s = s; try { this.is = s.getInputStream(); this.os = s.getOutputStream(); } catch (IOException e) { logger.error("ERROR: {}. Unable to start socket. ", e.getMessage()); } }
Source:
<code>public VoidResult call() throws NoSuchChangeException, InvalidChangeOperationException, OrmException { final Change.Id changeId = patchSetId.getParentKey(); final ChangeControl ctl = changeControlFactory.validateFor(changeId); change = ctl.getChange(); patchSet = db.patchSets().get(patchSetId); if (patchSet == null) { throw new NoSuchChangeException(changeId); } drafts = drafts(); publishDrafts(); final boolean isCurrent = patchSetId.equals(change.currentPatchSetId()); if (isCurrent && change.getStatus().isOpen()) { <START> publishApprovals(ctl); <END> } else if (!approvals.isEmpty() && !forceMessage) { throw new InvalidChangeOperationException("Change is closed"); } else { publishMessageOnly(); } touchChange(); email(); fireHook(); return VoidResult.INSTANCE; }</code><technical_language>happen change is open applying approvals fails for another reason (permissions)? message skipped then</technical_language>

Target:
public VoidResult call() throws NoSuchChangeException, InvalidChangeOperationException, OrmException { final Change.Id changeId = patchSetId.getParentKey(); final ChangeControl ctl = changeControlFactory.validateFor(changeId); change = ctl.getChange(); patchSet = db.patchSets().get(patchSetId); if (patchSet == null) { throw new NoSuchChangeException(changeId); } drafts = drafts(); publishDrafts(); final boolean isCurrent = patchSetId.equals(change.currentPatchSetId()); if (isCurrent && change.getStatus().isOpen()) { publishApprovals(ctl); } else if (approvals.isEmpty() || forceMessage) { publishMessageOnly(); } else { throw new InvalidChangeOperationException("Change is closed"); } touchChange(); email(); fireHook(); return VoidResult.INSTANCE; }
Source:
<code>void addQueryParamIterable(String name, Iterable values, boolean urlEncodeValue) { <START> for (Object value: values) { <END> addQueryParamString(name, value.toString(), urlEncodeValue); } }</code><technical_language>space :</technical_language>

Target:
void addQueryParamIterable(String name, Iterable values, boolean urlEncodeValue) { for (Object value : values) { addQueryParam(name, value, urlEncodeValue); } }
Source:
<code>private ImmutableListMultimap<String, Availability> getAvailabilities(List<Episode> episodes) { ImmutableListMultimap<String, Availability> availabilities; try { <START> availabilities = availabilities(episodes); <END> } catch (GlycerinException e) { throw Throwables.propagate(e); } return availabilities; }</code><technical_language>do return availabilities(episodes) here. for rest of them</technical_language>

Target:
private ImmutableListMultimap<String, Availability> getAvailabilities(List<Episode> episodes) { ImmutableListMultimap<String, Availability> availabilities; try { return availabilities(episodes); } catch (GlycerinException e) { throw Throwables.propagate(e); } }
Source:
<code>private void replaceFilePathsWithBytes(ModelNode request, ModelNode opDescOutcome) throws CommandFormatException { <START> ModelNode requestProps = opDescOutcome.get("result", "request-properties"); <END> for (Property prop : requestProps.asPropertyList()) { ModelNode typeDesc = prop.getValue().get("type"); if (typeDesc.getType() == ModelType.TYPE && typeDesc.asType() == ModelType.BYTES) { String filePath = request.get(prop.getName()).asString(); File localFile = new File(filePath); try { request.get(prop.getName()).set(Util.readBytes(localFile)); } catch (OperationFormatException e) { throw new CommandFormatException(e); } } } }</code><technical_language>this produce NPE if L153 condition applies</technical_language>

Target:
private void replaceFilePathsWithBytes(ModelNode request, ModelNode opDescOutcome) throws CommandFormatException { ModelNode requestProps = opDescOutcome.get("result", "request-properties"); for (Property prop : requestProps.asPropertyList()) { ModelNode typeDesc = prop.getValue().get("type"); if (typeDesc.getType() == ModelType.TYPE && typeDesc.asType() == ModelType.BYTES && request.hasDefined(prop.getName())) { String filePath = request.get(prop.getName()).asString(); File localFile = new File(filePath); if (!localFile.exists()) continue; try { request.get(prop.getName()).set(Util.readBytes(localFile)); } catch (OperationFormatException e) { throw new CommandFormatException(e); } } } }
Source:
<code>public TestDistributedQueriesNoHashGeneration() { <START> super(() -> createQueryRunner(ImmutableMap.of(), ImmutableMap.of("optimizer.optimize-hash-generation", "false")), FeatureSelection.all().without(ENGINE_ONLY).build()); <END> }</code><technical_language>shortcut for: FeatureSelection.all().without(ENGINE_ONLY).build()</technical_language>

Target:
public TestDistributedQueriesNoHashGeneration() { super(() -> createQueryRunner(ImmutableMap.of(), ImmutableMap.of("optimizer.optimize-hash-generation", "false"))); }
Source:
<code>public int getColumnIndex(String columnName) throws DDFException { <START> return mSchema != null ? mSchema.getColumnIndex(columnName) : -1; <END> }</code><technical_language>change this implementation like: if mSchema is null throw exception return mSchema.getColumnIndex ? implementation unsetFactor</technical_language>

Target:
public int getColumnIndex(String columnName) throws DDFException { return mSchema.getColumnIndex(columnName); }
Source:
<code>public void delete_a_simple_job() { FreeStyleJob j = jenkins.jobs.create(FreeStyleJob.class, "simple-job"); assertTrue(j.open().getTitle().contains(j.name)); j.delete(); <START> assertFalse(j.open().getTitle().contains(j.name)); <END> }</code><technical_language>I prefer asserting page object exists (Matchers#pageObjectExists)</technical_language>

Target:
public void delete_a_simple_job() { FreeStyleJob j = jenkins.jobs.create(FreeStyleJob.class, "simple-job"); assertThat(j, pageObjectExists()); j.delete(); assertThat(j,pageObjectDoesNotExist()); }
Source:
<code>DivType toDiv(Map<MediaUnit, String> mediaUnitIDs, LinkedList<Pair<String, String>> smLinkData, Mets mets) { DivType div = new DivType(); div.setID(metsReferrerId); div.setLABEL(super.getLabel()); div.setORDERLABEL(super.getOrderlabel()); div.setTYPE(super.getType()); smLinkData.addAll(super.getViews().parallelStream().map(View::getMediaUnit).map(mediaUnitIDs::get) .map(mediaUnitId -> Pair.of(metsReferrerId, mediaUnitId)).collect(Collectors.toList())); Optional<MdSecType> optionalDmdSec = createMdSec(MdSec.DMD_SEC); if (optionalDmdSec.isPresent()) { MdSecType dmdSec = optionalDmdSec.get(); String name = metsReferrerId + ':' + MdSec.DMD_SEC.toString(); dmdSec.setID(UUID.nameUUIDFromBytes(name.getBytes(StandardCharsets.UTF_8)).toString()); mets.getDmdSec().add(dmdSec); div.getDMDID().add(dmdSec); } Optional<AmdSecType> optionalAmdSec = createAmdSec(div); if (optionalAmdSec.isPresent()) { AmdSecType admSec = optionalAmdSec.get(); mets.getAmdSec().add(admSec); } for (ExistingOrLinkedStructure substructure : super.getChildren()) { div.getDiv().add(new DivXmlElementAccess((Structure) substructure).toDiv(mediaUnitIDs, smLinkData, mets)); } <START> return div; <END> }</code><technical_language>know, a Structure (instead of a mix of linked structure)? If this is "by Design" method "getChildren" return correct type</technical_language>

Target:
DivType toDiv(Map<MediaUnit, String> mediaUnitIDs, LinkedList<Pair<String, String>> smLinkData, Mets mets) { DivType div = new DivType(); div.setID(metsReferrerId); div.setLABEL(super.getLabel()); div.setORDERLABEL(super.getOrderlabel()); div.setTYPE(super.getType()); smLinkData.addAll(super.getViews().parallelStream().map(View::getMediaUnit).map(mediaUnitIDs::get) .map(mediaUnitId -> Pair.of(metsReferrerId, mediaUnitId)).collect(Collectors.toList())); Optional<MdSecType> optionalDmdSec = createMdSec(super.getMetadata(), MdSec.DMD_SEC); if (optionalDmdSec.isPresent()) { MdSecType dmdSec = optionalDmdSec.get(); String name = metsReferrerId + ':' + MdSec.DMD_SEC.toString(); dmdSec.setID(UUID.nameUUIDFromBytes(name.getBytes(StandardCharsets.UTF_8)).toString()); mets.getDmdSec().add(dmdSec); div.getDMDID().add(dmdSec); } Optional<AmdSecType> optionalAmdSec = createAmdSec(super.getMetadata(), metsReferrerId, div); if (optionalAmdSec.isPresent()) { AmdSecType admSec = optionalAmdSec.get(); mets.getAmdSec().add(admSec); } for (StructuralElement substructure : super.getChildren()) { div.getDiv().add(new DivXmlElementAccess((IncludedStructuralElement) substructure).toDiv(mediaUnitIDs, smLinkData, mets)); } return div; }
Source:
<code><START> public void updateMainBranchName(DbSession dbSession, String projectUuid, String newBranchKey) { <END> Optional<BranchDto> branch = selectByKey(dbSession, projectUuid, BranchKeyType.BRANCH, newBranchKey); if (branch.isPresent()) { throw new IllegalArgumentException("Impossible to update branch name: a branch with name \"" + newBranchKey + "\" already exists in the project."); } mapper(dbSession).updateMainBranchName(projectUuid, newBranchKey); }</code><technical_language>logic in this method => do check in WS call upsert</technical_language>

Target:
public int updateMainBranchName(DbSession dbSession, String projectUuid, String newBranchKey) { long now = system2.now(); return mapper(dbSession).updateMainBranchName(projectUuid, newBranchKey, now); }
Source:
<code>public TarArchiveEntry(final Path file, final String fileName) { final String normalizedName = normalizeFileName(fileName, false); this.file = file; if (Files.isDirectory(file)) { this.mode = DEFAULT_DIR_MODE; this.linkFlag = LF_DIR; final int nameLength = normalizedName.length(); if (nameLength == 0 || normalizedName.charAt(nameLength - 1) != '/') { this.name = normalizedName + "/"; } else { this.name = normalizedName; } } else { this.mode = DEFAULT_FILE_MODE; this.linkFlag = LF_NORMAL; try { this.size = Files.size(file); } catch (IOException e) { <START> e.printStackTrace(); <END> } this.name = normalizedName; } this.userName = ""; Set<String> availableAttributeViews = file.getFileSystem().supportedFileAttributeViews(); if (availableAttributeViews.contains("posix")) { try { final PosixFileAttributes posixFileAttributes = Files.readAttributes(file, PosixFileAttributes.class); setModTime(posixFileAttributes.lastModifiedTime()); this.userName = posixFileAttributes.owner().getName(); this.groupName = posixFileAttributes.group().getName(); if (availableAttributeViews.contains("unix")) { this.userId = ((Number) Files.getAttribute(file, "unix:uid")).longValue(); this.groupId = ((Number) Files.getAttribute(file, "unix:gid")).longValue(); } } catch (IOException e) { e.printStackTrace(); } } else if (availableAttributeViews.contains("dos")) { try { final DosFileAttributes dosFileAttributes = Files.readAttributes(file, DosFileAttributes.class); setModTime(dosFileAttributes.lastModifiedTime()); this.userName = Files.getOwner(file).getName(); } catch (IOException e) { e.printStackTrace(); } } else { try { final BasicFileAttributes basicFileAttributes = Files.readAttributes(file, BasicFileAttributes.class); setModTime(basicFileAttributes.lastModifiedTime()); this.userName = Files.getOwner(file).getName(); } catch (IOException e) { e.printStackTrace(); } } preserveAbsolutePath = false; }</code><technical_language>helpful</technical_language>

Target:
public TarArchiveEntry(final Path file, final String fileName) throws IOException { final String normalizedName = normalizeFileName(fileName, false); this.file = file; readFileMode(file, normalizedName); this.userName = ""; readOsSpecificProperties(file); preserveAbsolutePath = false; }
Source:
<code><START> public ParseInModule(Module seedModule) { <END> this.seedModule = seedModule; this.extensionModule = seedModule; this.disambModule = seedModule; this.parsingModule = seedModule; this.grammar = KSyntax2GrammarStatesFilter.getGrammar(parsingModule); }</code><technical_language>this constructor feels wrong now... I a Module a Definition constructor calls getCombinedGrammar</technical_language>

Target:
ParseInModule(Module seedModule) { this(seedModule, seedModule, seedModule, seedModule); }
Source:
<code>public String getWelcomePageUrl() { String welcomePageUrl = null; IService service = OpenShiftServerUtils.getService(server); IProject project = service.getProject(); if (project != null) { List<IRoute> routes = project.getResources(ResourceKind.ROUTE); String url = OpenShiftServerUtils.getRouteURL(server); if(!StringUtils.isEmpty(url)) { for (IRoute route: routes) { if(url.equals(route.getURL())) { return welcomePageUrl = url; } } <START> } <END> IRoute route = getRoute(routes); if (route != null) { welcomePageUrl = route.getURL(); } } return welcomePageUrl; }</code><technical_language>this block excellent candidate for a method #getRoute(String url). invoking code more more clear (we're pick right route settings stored in adapter/project fall user choosing it): IRoute route = getRoute(OpenShiftServerUtils.getRouteURL(server), routes); if (route != null) { welcomePageUrl = route.getURL(); } else { route = getRoute(routes); if (route != null) { welcomePageUrl = route.getURL(); } } return welcomePageUrl;</technical_language>

Target:
public String getWelcomePageUrl() { String welcomePageUrl = null; IService service = OpenShiftServerUtils.getService(server); IProject project = service.getProject(); if (project != null) { List<IRoute> routes = project.getResources(ResourceKind.ROUTE); IRoute route = getRoute(OpenShiftServerUtils.getRouteURL(server), routes); if (route == null) { route = getRoute(routes); } if (route != null) { welcomePageUrl = route.getURL(); } } return welcomePageUrl; }
Source:
<code>public static HostnameResolver chooseResolver( Config config, LogProvider logProvider, LogProvider userLogProvider ) { CausalClusteringSettings.DiscoveryType discoveryType = config.get( CausalClusteringSettings.discovery_type ); if ( discoveryType == CausalClusteringSettings.DiscoveryType.DNS ) { return new DnsHostnameResolver( logProvider, userLogProvider, new DomainNameResolverImpl() ); } else if ( discoveryType == CausalClusteringSettings.DiscoveryType.SRV ) { <START> return new SrvHostnameResolver( logProvider, userLogProvider, new SrvRecordResolverImpl() ); <END> } else { return new NoOpHostnameResolver(); } }</code><technical_language>refactor store a factory BiFunction DiscoveryType enum dispose of this if block.</technical_language>

Target:
public static HostnameResolver chooseResolver( Config config, LogProvider logProvider, LogProvider userLogProvider ) { CausalClusteringSettings.DiscoveryType discoveryType = config.get( CausalClusteringSettings.discovery_type ); return discoveryType.getHostnameResolver( logProvider, userLogProvider ); }
Source:
<code>public void start() { try { if ( !checkRequiredSettings() ) { <START> throw new HibernateException( "Please configure Redis on hibernate.properties correctly." ); <END> } log.info( "Redis starting ..." ); setUpRedis(); } catch ( Exception ex ) { stop(); } }</code><technical_language>here, great if JBoss Logger recommended approach (although this is wrong, optional: I change this if prefer). approach in this case somethin throw log.missingPropertiesAtStartup(); I read message, for this if include message in _checkRequiredSettings_ property is missing. pretty save a lot of time swearing this code</technical_language>

Target:
public void start() { try { Map<String, String> unSetRequiredProperties = checkRequiredSettings(); if ( !unSetRequiredProperties.isEmpty() ) { throw log.missingPropertiesAtStartup( unSetRequiredProperties.toString() ); } log.redisStarting(); setUpRedis(); } catch ( Exception ex ) { stop(); throw log.cannotStartRedis( ex ); } }
Source:
<code>private void updateOptionInDb(final GlusterVolumeOption option) { TransactionSupport.executeInNewTransaction(new TransactionMethod<Void>() { @Override public Void runInTransaction() { <START> if(getGlusterVolume().getOptionValue(option.getKey()) != null) { <END> glusterVolumeDao.updateVolumeOption(option); } else { glusterVolumeDao.addVolumeOption(option); } return null; } }); }</code><technical_language>this null? a check in canDoAction block this null</technical_language>

Target:
private void updateOptionInDb(final GlusterVolumeOption option) { if (getGlusterVolume().getOptionValue(option.getKey()) != null) { getGlusterVolumeDao().updateVolumeOption(option); } else { getGlusterVolumeDao().addVolumeOption(option); } }
Source:
<code>public void testDeserialization() throws Exception { final Subscription subscription = readObjectFromResource("/notification/subscription.json", Subscription.class); assertThat(subscription.getMeta(), is(notNullValue())); assertThat(subscription.getMeta().getUri(), is("/gdc/projects/be2lnpzun7cybpvd7gs1mvtczzr9ijv7/users/876ec68f5630b38de65852ed5d6236ff/subscriptions/59dca8f260b2c601f3c72e1c")); assertThat(subscription.getMeta().getTitle(), is("test subscription")); <START> assertThat(subscription.getChannels(), hasItems("/gdc/account/profile/876ec68f5630b38de65852ed5d6236ff/channelConfigurations/59dca8f160b2c601f3c72e1b")); <END> assertThat(subscription.getCondition(), is(notNullValue())); assertThat(subscription.getCondition().getExpression(), is("true")); assertThat(subscription.getTriggers(), hasSize(2)); assertThat(subscription.getTemplate(), is(notNullValue())); assertThat(subscription.getTemplate().getExpression(), is("test message")); }</code><technical_language>I suggest strict in unit tests... In this case testing list contains items, testing contains items. I suggest is(singletonList("..."))</technical_language>

Target:
public void testDeserialization() throws Exception { final Subscription subscription = readObjectFromResource("/notification/subscription.json", Subscription.class); assertThat(subscription.getMeta(), is(notNullValue())); assertThat(subscription.getMeta().getUri(), is("/gdc/projects/be2lnpzun7cybpvd7gs1mvtczzr9ijv7/users/876ec68f5630b38de65852ed5d6236ff/subscriptions/59dca8f260b2c601f3c72e1c")); assertThat(subscription.getMeta().getTitle(), is("test subscription")); assertThat(subscription.getChannels(), is(singletonList("/gdc/account/profile/876ec68f5630b38de65852ed5d6236ff/channelConfigurations/59dca62e60b2c601f3c72e18"))); assertThat(subscription.getCondition(), is(notNullValue())); assertThat(subscription.getCondition().getExpression(), is("true")); assertThat(subscription.getTriggers(), hasSize(2)); assertThat(subscription.getTemplate(), is(notNullValue())); assertThat(subscription.getTemplate().getExpression(), is("test message")); }
Source:
<code>protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setTheme(R.style.Theme_MaterialComponents_NoActionBar_App); setContentView(R.layout.activity_running); ButterKnife.bind(this); Bundle extra = getIntent().getBundleExtra(TEST); testSuites = (ArrayList<AbstractSuite>) extra.getSerializable(TEST); if (testSuites == null) <START> finish(); <END> runtTest(); }</code><technical_language>returning here? I weird finish runTest</technical_language>

Target:
protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setTheme(R.style.Theme_MaterialComponents_NoActionBar_App); setContentView(R.layout.activity_running); ButterKnife.bind(this); Bundle extra = getIntent().getBundleExtra(TEST); testSuites = (ArrayList<AbstractSuite>) extra.getSerializable(TEST); if (testSuites == null) { finish(); return; } runTest(); }
Source:
<code><START> public void testNothing() { <END> assertNotNull("asciidoc parser was not created", parseToHtml("test")); }</code><technical_language>consider renaming "simpleParagraph", "placeholder" base class extends TestCase, annotation unnecessary. Consider annotations removing TestCase a base class in hierarchy. prefixing method "test" is redundant annotation present</technical_language>

Target:
public void testNothing() { assertNotNull("This test method is here since if I don't have it surefire complains there are no tests"); }
Source:
<code>protected Void doInBackground() { HttpURLConnection urlConnection = null; File updateFile = null; try { URL url = new URL(myDownloadURL); urlConnection = (HttpURLConnection) url.openConnection(); int responseCode = urlConnection.getResponseCode(); String saveFilePath = System.getProperty("java.io.tmpdir") + File.separator + "gantt-update"; <START> updateFile = File.createTempFile(saveFilePath, ".tmp"); <END> if (responseCode == HttpURLConnection.HTTP_OK) { downloadZip(urlConnection, updateFile); } else { throw new IOException("No file to download. Server replied HTTP code: " + responseCode); } unzipUpdates(updateFile); } catch (IOException ex) { ex.printStackTrace(); cancel(true); } finally { urlConnection.disconnect(); updateFile.delete(); } return null; }</code><technical_language>createTempFile [uses temporary directory](<LINK_0>,%20java.lang.String) ) automatically. construct full path</technical_language>

Target:
protected Void doInBackground() { HttpURLConnection urlConnection = null; File updateFile = null; try { URL url = new URL(myDownloadURL); urlConnection = (HttpURLConnection) url.openConnection(); int responseCode = urlConnection.getResponseCode(); updateFile = File.createTempFile("gantt-update", ".tmp"); if (responseCode == HttpURLConnection.HTTP_OK) { downloadZip(urlConnection, updateFile); } else { throw new IOException("No file to download. Server replied HTTP code: " + responseCode); } unzipUpdates(updateFile); } catch (IOException ex) { GPLogger.log(ex); cancel(true); } finally { if (urlConnection != null) { urlConnection.disconnect(); } if (updateFile != null) { updateFile.delete(); } } return null; }
Source:
<code>public void handleModifyEvent(CatalogModifyEvent event) throws CatalogException { CatalogInfo source = event.getSource(); if (!(source instanceof StyleInfo)) { return; } final List<String> propertyNames = event.getPropertyNames(); <START> if (!propertyNames.contains("name") && !propertyNames.contains("workspace")) { <END> return; } final int nameIdx = propertyNames.indexOf("name"); final String oldName = (String) event.getOldValues().get(nameIdx); final String newName = (String) event.getNewValues().get(nameIdx); final int workspaceIdx = propertyNames.indexOf("wokspace"); final String oldWorkspaceName = workspaceIdx != -1 ? (String) event.getOldValues().get( workspaceIdx) : null; final String newWorkspaceName = workspaceIdx != -1 ? (String) event.getNewValues().get( workspaceIdx) : null; final String oldStyleName = getPrefixedName(oldWorkspaceName, oldName); final String newStyleName = getPrefixedName(newWorkspaceName, newName); if (oldName.equals(newName)) { return; } List<GeoServerTileLayer> affectedLayers; affectedLayers = mediator.getTileLayersForStyle(oldName); for (GeoServerTileLayer tl : affectedLayers) { LayerInfo layerInfo = tl.getLayerInfo(); if (layerInfo == null) { continue; } GeoServerTileLayerInfo info = tl.getInfo(); ImmutableSet<String> styleNames = info.cachedStyles(); if (styleNames.contains(oldStyleName)) { tl.resetParameterFilters(); mediator.truncateByLayerAndStyle(tl.getName(), oldStyleName); Set<String> newStyles = new HashSet<String>(styleNames); newStyles.remove(oldStyleName); newStyles.add(newStyleName); String defaultStyle = layerInfo.getDefaultStyle() == null ? null : layerInfo .getDefaultStyle().prefixedName(); TileLayerInfoUtil.setCachedStyles(info, defaultStyle, newStyles); mediator.save(tl); } } }</code><technical_language>this catch moving a new workspace workspace's name changed</technical_language>

Target:
public void handleModifyEvent(CatalogModifyEvent event) throws CatalogException { CatalogInfo source = event.getSource(); if (source instanceof StyleInfo) { final List<String> propertyNames = event.getPropertyNames(); if (!propertyNames.contains("name") && !propertyNames.contains("workspace")) { return; } final int nameIdx = propertyNames.indexOf("name"); final String oldName = (String) event.getOldValues().get(nameIdx); final String newName = (String) event.getNewValues().get(nameIdx); final int workspaceIdx = propertyNames.indexOf("wokspace"); final String oldWorkspaceName = workspaceIdx != -1 ? (String) event.getOldValues().get( workspaceIdx) : null; final String newWorkspaceName = workspaceIdx != -1 ? (String) event.getNewValues().get( workspaceIdx) : null; final String oldStyleName = getPrefixedName(oldWorkspaceName, oldName); final String newStyleName = getPrefixedName(newWorkspaceName, newName); handleStyleRenamed(oldStyleName, newStyleName); } else if (source instanceof WorkspaceInfo) { PRE_MODIFY_EVENT.set(event); } }
Source:
<code>@Override public void checkPageCompressionSupported(Path storagePath, int pageSize) throws IgniteCheckedException { <START> if (testMode) <END> return; if (!U.isLinux()) throw new IgniteCheckedException("Currently page compression is supported only for Linux."); FileSystemUtils.checkSupported(); int fsBlockSize = FileSystemUtils.getFileSystemBlockSize(storagePath); if (fsBlockSize <= 0) throw new IgniteCheckedException("Failed to get file system block size: " + storagePath); if (!U.isPow2(fsBlockSize)) throw new IgniteCheckedException("Storage block size must be power of 2: " + fsBlockSize); if (pageSize < fsBlockSize * 2) { throw new IgniteCheckedException("Page size (now configured to " + pageSize + " bytes) " + "must be at least 2 times larger than the underlying storage block size (detected to be " + fsBlockSize + " bytes at '" + storagePath + "') for page compression."); } }</code><technical_language>Please create a separate subclass for test mode if is needed</technical_language>

Target:
@Override public void checkPageCompressionSupported(Path storagePath, int pageSize) throws IgniteCheckedException { if (!U.isLinux()) throw new IgniteCheckedException("Currently page compression is supported only for Linux."); FileSystemUtils.checkSupported(); int fsBlockSize = FileSystemUtils.getFileSystemBlockSize(storagePath); if (fsBlockSize <= 0) throw new IgniteCheckedException("Failed to get file system block size: " + storagePath); if (!U.isPow2(fsBlockSize)) throw new IgniteCheckedException("Storage block size must be power of 2: " + fsBlockSize); if (pageSize < fsBlockSize * 2) { throw new IgniteCheckedException("Page size (now configured to " + pageSize + " bytes) " + "must be at least 2 times larger than the underlying storage block size (detected to be " + fsBlockSize + " bytes at '" + storagePath + "') for page compression."); } }
Source:
<code>public RecentWikiActivity openDiffPage() { wait.forElementClickable(seeDiffArrow); String urlToBeRedirected = seeDiffArrow.getAttribute("href"); seeDiffArrow.click(); loading.handleAsyncPageReload(); PageObjectLogging.logInfo("The arrow redirecting to the diff page was clicked"); <START> Assertion.assertTrue(driver.getCurrentUrl().contains(urlToBeRedirected), <END> "You were not redirected to the diff page"); PageObjectLogging.logInfo("You were redirected to the diff page"); return this; }</code><technical_language>Is this assertion is needed</technical_language>

Target:
public RecentWikiActivity openDiffPage() { wait.forElementClickable(seeDiffArrow); String urlPath = seeDiffArrow.getAttribute("href"); seeDiffArrow.click(); loading.handleAsyncPageReload(); Assertion.assertTrue(driver.getCurrentUrl().contains(urlPath), "Url does not contain: " + urlPath); PageObjectLogging.logInfo("Diff page: " + urlPath + ", was opened"); return this; }
Source:
<code><START> public void removeAccounts() { <END> Account[] accountList = mAcctManager .getAccountsByType(AuthenticationConstants.Broker.BROKER_ACCOUNT_TYPE); SharedPreferences prefs = mContext.getSharedPreferences(KEY_SHARED_PREF_ACCOUNT_LIST, Activity.MODE_PRIVATE); String delAccount = prefs.getString(KEY_APP_ACCOUNTS_FOR_TOKEN_REMOVAL, ""); StringTokenizer st = new StringTokenizer(delAccount, KEY_ACCOUNT_LIST_DELIM); while (st.hasMoreTokens()) { String name = st.nextToken(); if (name != null && !name.isEmpty()) { Logger.v(TAG, "Removing account:" + name); Account targetAccount = getAccount(accountList, name); if (targetAccount != null) { mAcctManager.removeAccount(targetAccount, null, null); Logger.v(TAG, "Account exists and removed:" + name); } } } }</code><technical_language>thread safety issues here</technical_language>

Target:
public void removeAccounts() { Account[] accountList = mAcctManager .getAccountsByType(AuthenticationConstants.Broker.BROKER_ACCOUNT_TYPE); SharedPreferences prefs = mContext.getSharedPreferences(KEY_SHARED_PREF_ACCOUNT_LIST, Activity.MODE_PRIVATE); String delAccount = prefs.getString(KEY_APP_ACCOUNTS_FOR_TOKEN_REMOVAL, ""); StringTokenizer st = new StringTokenizer(delAccount, KEY_ACCOUNT_LIST_DELIM); while (st.hasMoreTokens()) { String name = st.nextToken(); if (name != null && !name.isEmpty()) { Logger.v(TAG, "Removing account:" + name); Account targetAccount = getAccount(accountList, name); if (targetAccount != null) { mAcctManager.removeAccount(targetAccount, null, null); Logger.v(TAG, "Account exists and removed:" + name); } else { Logger.w(TAG, "Account does not exists" + name, "", ADALError.BROKER_ACCOUNT_DOES_NOT_EXIST); } } } }
Source:
<code>public void testStitchCommandHashCode() { Sprite sprite = new Sprite("firstSprite"); StitchCommand command1 = new DSTStitchCommand(0, 0, 0, sprite); StitchCommand command2 = new DSTStitchCommand(0, 1, 0, sprite); StitchCommand command3 = new DSTStitchCommand(0, 0, 1, sprite); StitchCommand command4 = new DSTStitchCommand(0, 0, 0, new Sprite("secondSprite")); <START> StitchCommand command5 = command1; <END> assertEquals(command1.hashCode(), command5.hashCode()); assertNotEquals(command1.hashCode(), command2.hashCode()); assertNotEquals(command1.hashCode(), command3.hashCode()); assertNotEquals(command1.hashCode(), command4.hashCode()); }</code><technical_language>new DSTStitchCommand(0, 0, 0, sprite);</technical_language>

Target:
public void testStitchCommandHashCode() { Sprite sprite = new Sprite("firstSprite"); StitchCommand command1 = new DSTStitchCommand(0, 0, 0, sprite); StitchCommand command2 = new DSTStitchCommand(0, 1, 0, sprite); StitchCommand command3 = new DSTStitchCommand(0, 0, 1, sprite); StitchCommand command4 = new DSTStitchCommand(0, 0, 0, new Sprite("secondSprite")); StitchCommand command5 = new DSTStitchCommand(0, 0, 0, sprite); assertEquals(command1.hashCode(), command5.hashCode()); assertNotEquals(command1.hashCode(), command2.hashCode()); assertNotEquals(command1.hashCode(), command3.hashCode()); assertNotEquals(command1.hashCode(), command4.hashCode()); }
Source:
<code>protected boolean isGitRepository() { <START> return appContext.getActiveProject().isTypeOf("git"); <END> }</code><technical_language>need NPE checking, appContext.getActiveProject() null</technical_language>

Target:
protected boolean isGitRepository() { if (appContext.getActiveProject() == null) { return false; } else { return appContext.getActiveProject().isTypeOf("git"); } }
Source:
<code>private String getSortValue() { if (account != null) { if (account.email != null) { return account.email; } return <START> account.name; <END> } return group; }</code><technical_language>name null, causing compareTo NPE if wrong side. In cases treat name ""</technical_language>

Target:
private String getSortValue() { if (account != null) { if (account.email != null) { return account.email; } return Strings.nullToEmpty(account.name); } return group; }
Source:
<code><START> public void <END> performHaResevationCheck() { log.debug("HA Reservation check timer entered."); List<Cluster> clusters = getClusterDao().getAll(); if (clusters != null) { HaReservationHandling haReservationHandling = new HaReservationHandling(getPendingResourceManager()); for (Cluster cluster : clusters) { if (cluster.supportsHaReservation()) { List<VDS> returnedFailedHosts = new ArrayList<>(); boolean clusterHaStatus = haReservationHandling.checkHaReservationStatusForCluster(cluster, returnedFailedHosts); if (!clusterHaStatus) { AuditLogable logable = createEventForCluster(cluster); String failedHostsStr = returnedFailedHosts.stream().map(VDS::getName).collect(Collectors.joining(", ")); logable.addCustomValue("Hosts", failedHostsStr); auditLogDirector.log(logable, AuditLogType.CLUSTER_ALERT_HA_RESERVATION); log.info("Cluster '{}' fail to pass HA reservation check.", cluster.getName()); } boolean clusterHaStatusFromPreviousCycle = clusterId2isHaReservationSafe.containsKey(cluster.getId()) ? clusterId2isHaReservationSafe.get(cluster.getId()) : true; clusterId2isHaReservationSafe.put(cluster.getId(), clusterHaStatus); if (!clusterHaStatusFromPreviousCycle && clusterHaStatus) { AuditLogable logable = createEventForCluster(cluster); auditLogDirector.log(logable, AuditLogType.CLUSTER_ALERT_HA_RESERVATION_DOWN); } } } } log.debug("HA Reservation check timer finished."); }</code><technical_language>changed performLoadBalancing private, sense do well</technical_language>

Target:
private void performHaResevationCheck() { log.debug("HA Reservation check timer entered."); List<Cluster> clusters = getClusterDao().getAll(); if (clusters != null) { HaReservationHandling haReservationHandling = new HaReservationHandling(getPendingResourceManager()); for (Cluster cluster : clusters) { if (cluster.supportsHaReservation()) { List<VDS> returnedFailedHosts = new ArrayList<>(); boolean clusterHaStatus = haReservationHandling.checkHaReservationStatusForCluster(cluster, returnedFailedHosts); if (!clusterHaStatus) { AuditLogable logable = createEventForCluster(cluster); String failedHostsStr = returnedFailedHosts.stream().map(VDS::getName).collect(Collectors.joining(", ")); logable.addCustomValue("Hosts", failedHostsStr); auditLogDirector.log(logable, AuditLogType.CLUSTER_ALERT_HA_RESERVATION); log.info("Cluster '{}' fail to pass HA reservation check.", cluster.getName()); } boolean clusterHaStatusFromPreviousCycle = clusterId2isHaReservationSafe.containsKey(cluster.getId()) ? clusterId2isHaReservationSafe.get(cluster.getId()) : true; clusterId2isHaReservationSafe.put(cluster.getId(), clusterHaStatus); if (!clusterHaStatusFromPreviousCycle && clusterHaStatus) { AuditLogable logable = createEventForCluster(cluster); auditLogDirector.log(logable, AuditLogType.CLUSTER_ALERT_HA_RESERVATION_DOWN); } } } } log.debug("HA Reservation check timer finished."); }
Source:
<code>private CompletionStage<Void> startTransfer(StateRequestCommand.Type type) { if (isCancelled) return completionFuture; IntSet segmentsCopy = getSegments(); if (segmentsCopy.isEmpty()) { <START> log.tracef("Segments list is empty, skipping source %s", source); <END> completionFuture.complete(null); return completionFuture; } if (trace) { log.tracef("Requesting state (%s) from node %s for segments %s", type, source, segmentsCopy); } StateRequestCommand cmd = commandsFactory.buildStateRequestCommand(type, rpcManager.getAddress(), topologyId, segmentsCopy); CompletionStage<Response> remoteStage = rpcManager.invokeCommand(source, cmd, PassthroughSingleResponseCollector.INSTANCE, rpcOptions); return handleAndCompose(remoteStage, (response, throwable) -> { if (throwable != null) { if (!isCancelled) { log.failedToRequestSegments(cacheName, source, segmentsCopy, throwable); completionFuture.completeExceptionally(throwable); } } else if (response instanceof SuccessfulResponse) { if (trace) { log.tracef("Successfully requested state (%s) from node %s for segments %s", type, source, segmentsCopy); } } else if (response instanceof CacheNotFoundResponse) { if (trace) log.tracef("State source %s was suspected, another source will be selected", source); completionFuture.completeExceptionally(new SuspectException()); } else { Exception e = new CacheException(String.valueOf(response)); log.failedToRequestSegments(cacheName, source, segmentsCopy, e); completionFuture.completeExceptionally(e); } return completionFuture; }); }</code><technical_language>Missing if (trace) { check</technical_language>

Target:
private CompletionStage<Void> startTransfer(StateRequestCommand.Type type) { if (isCancelled) return completionFuture; IntSet segmentsCopy = getSegments(); if (segmentsCopy.isEmpty()) { if (trace) log.tracef("Segments list is empty, skipping source %s", source); completionFuture.complete(null); return completionFuture; } if (trace) { log.tracef("Requesting state (%s) from node %s for segments %s", type, source, segmentsCopy); } StateRequestCommand cmd = commandsFactory.buildStateRequestCommand(type, rpcManager.getAddress(), topologyId, segmentsCopy); CompletionStage<Response> remoteStage = rpcManager.invokeCommand(source, cmd, PassthroughSingleResponseCollector.INSTANCE, rpcOptions); return handleAndCompose(remoteStage, (response, throwable) -> { if (throwable != null) { if (!isCancelled) { log.failedToRequestSegments(cacheName, source, segmentsCopy, throwable); completionFuture.completeExceptionally(throwable); } } else if (response instanceof SuccessfulResponse) { if (trace) { log.tracef("Successfully requested state (%s) from node %s for segments %s", type, source, segmentsCopy); } } else if (response instanceof CacheNotFoundResponse) { if (trace) log.tracef("State source %s was suspected, another source will be selected", source); completionFuture.completeExceptionally(new SuspectException()); } else { Exception e = new CacheException(String.valueOf(response)); log.failedToRequestSegments(cacheName, source, segmentsCopy, e); completionFuture.completeExceptionally(e); } return completionFuture; }); }
Source:
<code>public boolean equals(Object obj) { return obj != null && obj instanceof GlusterGeoRepSessionConfiguration && ObjectUtils.objectsEqual(getId(), ((GlusterGeoRepSessionConfiguration) obj).getId()) <START> && ObjectUtils.haveSameElements(allowedValues, <END> ((GlusterGeoRepSessionConfiguration) obj).getAllowedValues()) && super.equals(obj); }</code><technical_language>allowedValues considered for object equality</technical_language>

Target:
public boolean equals(Object obj) { return obj != null && obj instanceof GlusterGeoRepSessionConfiguration && ObjectUtils.objectsEqual(getId(), ((GlusterGeoRepSessionConfiguration) obj).getId()) && super.equals(obj); }
Source:
<code>void addSegment(Segment seg) { if (seg == null) return; MapKey me = new MapKey(seg); if (segmentPreferences.containsKey(me)) { segmentPreferences.get(me).setInSource(convertSegment(seg)); try { <START> segmentPreferences.get(me).setXUnits(xunits); <END> segmentPreferences.get(me).setYUnits(yunits); } catch (UnitsException ex) { throw new RuntimeException(ex); } return; } SegmentLayer layer = new SegmentLayer(convertSegment(seg)); int count = 0; String id = layer.getSuffix(); while (!isUniqueLayerSuffix(id)) { count++; id = layer.getSuffix() + " " + count; } layer.setSuffix(id); layer.getInSource().setName(id); String hexColor = ColorPalette.colorToHex(colors.getNextColor()); layer.setMarkColor(hexColor); layer.setLabel(id); setUnits(seg, layer); segmentPreferences.put(me, layer); }</code><technical_language>this early, worth replace of String class variables units type. need of try catches. pass type classes needed - convert String xunit time</technical_language>

Target:
void addSegment(Segment seg) { if (seg == null) return; MapKey me = new MapKey(seg); if (segmentPreferences.containsKey(me)) { segmentPreferences.get(me).setInSource(convertSegment(seg)); return; } SegmentLayer layer = new SegmentLayer(convertSegment(seg)); int count = 0; String id = layer.getSuffix(); while (!isUniqueLayerSuffix(id)) { count++; id = layer.getSuffix() + " " + count; } layer.setSuffix(id); layer.getInSource().setName(id); String hexColor = ColorPalette.colorToHex(colors.getNextColor()); layer.setMarkColor(hexColor); layer.setLabel(id); setUnits(seg, layer); segmentPreferences.put(me, layer); }