auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>String getNext(boolean first) { if (first && inheritNamespaceToken != null && !wrapToken) { String rootTokenNamespacesString = getNamespacesFromNamespaceToken(scanner.findWithinHorizon(inheritNamespaceTokenPattern, 0)); <START> rootTokenNamespaces = rootTokenNamespacesString == null ? null : rootTokenNamespacesString.split(" "); <END> } String next = scanner.findWithinHorizon(tagTokenPattern, 0); if (next == null) { return null; } if (first && wrapToken) { MatchResult mres = scanner.match(); wrapHead = ((RecordableInputStream)in).getText(mres.start()); wrapTail = buildXMLTail(wrapHead); } if (inheritNamespaceToken != null && rootTokenNamespaces != null) { String head = StringHelper.before(next, ">"); boolean empty = false; if (head.endsWith("/")) { head = head.substring(0, head.length() - 1); empty = true; } StringBuilder sb = new StringBuilder(); String tail = StringHelper.after(next, ">"); next = sb.append(head).append(getMissingInherritNamespaces(head)).append(empty ? "/>" : ">").append(tail).toString(); } else if (wrapToken) { StringBuilder sb = new StringBuilder(); next = sb.append(wrapHead).append(next).append(wrapTail).toString(); } return next; }</code><technical_language>Remove double space</technical_language>

Target:
String getNext(boolean first) { if (first && inheritNamespaceToken != null && !wrapToken) { rootTokenNamespaces = getNamespacesFromNamespaceTokenSplitter(scanner.findWithinHorizon(inheritNamespaceTokenPattern, 0)); } String next = scanner.findWithinHorizon(tagTokenPattern, 0); if (next == null) { return null; } if (first && wrapToken) { MatchResult mres = scanner.match(); wrapHead = ((RecordableInputStream)in).getText(mres.start()); wrapTail = buildXMLTail(wrapHead); } if (inheritNamespaceToken != null && rootTokenNamespaces != null) { String head = StringHelper.before(next, ">"); boolean empty = false; if (head.endsWith("/")) { head = head.substring(0, head.length() - 1); empty = true; } StringBuilder sb = new StringBuilder(); String tail = StringHelper.after(next, ">"); next = sb.append(head).append(getMissingInherritNamespaces(head)).append(empty ? "/>" : ">").append(tail).toString(); } else if (wrapToken) { StringBuilder sb = new StringBuilder(); next = sb.append(wrapHead).append(next).append(wrapTail).toString(); } return next; }
Source:
<code>protected void serialize(EntityType model, Property field, Type type, CodeWriter writer, String factoryMethod, String... args) throws IOException { String constantFieldName = constantFieldName(field.getEscapedName()); <START> writer.publicStaticFinal(new ClassType(String.class), constantFieldName, "\"" + field.getName() + "\""); <END> Supertype superType = model.getSuperType(); StringBuilder value = new StringBuilder(); if (field.isInherited() && superType != null) { if (!superType.getEntityType().hasEntityFields()) { value.append("_super." + field.getEscapedName()); } } else { value.append(factoryMethod + "(" + constantFieldName); for (String arg : args) { value.append(COMMA + arg); } value.append(")"); } if (field.isInherited()) { writer.line(" } if (value.length() > 0) { writer.publicFinal(type, field.getEscapedName(), value.toString()); } else { writer.publicFinal(type, field.getEscapedName()); } }</code><technical_language>Types.String instead of new ClassType(String.class) additions toggable option</technical_language>

Target:
protected void serialize( EntityType model, Property field, Type type, CodeWriter writer, String factoryMethod, String... args ) throws IOException { String constantFieldName = null; if (namesAsConstants) { constantFieldName = constantFieldName(field.getEscapedName()); writer.publicStaticFinal(new ClassType(String.class), constantFieldName, QUOTE + field.getName() + QUOTE); } Supertype superType = model.getSuperType(); StringBuilder value = new StringBuilder(); if (field.isInherited() && superType != null) { if (!superType.getEntityType().hasEntityFields()) { value.append("_super." + field.getEscapedName()); } } else { if (namesAsConstants) { value.append(factoryMethod + "(" + constantFieldName); } else { value.append(factoryMethod + "(" + QUOTE + field.getName() + QUOTE); } for (String arg : args) { value.append(COMMA + arg); } value.append(")"); } if (field.isInherited()) { writer.line(" } if (value.length() > 0) { writer.publicFinal(type, field.getEscapedName(), value.toString()); } else { writer.publicFinal(type, field.getEscapedName()); } }
Source:
<code>private void createSimpleCache() { try { manager.administration().createCache("SimpleCache", (String)null); System.out.println("SimpleCache created"); <START> } catch (Exception e) { <END> System.out.println("Expected to fail for multiple invocations as the cache exists message: " + e.getMessage()); } }</code><technical_language>I put this method example. This API is just... for me. more error API. Is this users @wfink ? If 'not really', for remove IMO This API of creating caches runtime changed I mentioned in thread in zulip @tristantarrant @wburns</technical_language>

Target:
private void createSimpleCache() { try { manager.administration().createCache("SimpleCache", (String)null); System.out.println("SimpleCache created."); } catch (Exception e) { System.out.println("Expected to fail for multiple invocations as the cache exists message: " + e.getMessage()); } }
Source:
<code>public Collection<Metadata> getAll() { try { lock.readLock().lock(); <START> return Collections.unmodifiableSet(metadata); <END> } finally { lock.readLock().unlock(); } }</code><technical_language>java return Collections.unmodifiableSet(new HashSet<>(metadata));</technical_language>

Target:
public Collection<Metadata> getAll() { try { lock.readLock().lock(); return Collections.unmodifiableSet(new HashSet<>(metadata)); } finally { lock.readLock().unlock(); } }
Source:
<code>public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } CoordinatorDynamicConfig that = (CoordinatorDynamicConfig) o; if (millisLagSinceCoordinatorBecomesLeaderBeforeCanMarkAsUnusedOvershadowedSegments != <START> that.millisLagSinceCoordinatorBecomesLeaderBeforeCanMarkAsUnusedOvershadowedSegments) { <END> return false; } if (mergeBytesLimit != that.mergeBytesLimit) { return false; } if (mergeSegmentsLimit != that.mergeSegmentsLimit) { return false; } if (maxSegmentsToMove != that.maxSegmentsToMove) { return false; } if (replicantLifetime != that.replicantLifetime) { return false; } if (replicationThrottleLimit != that.replicationThrottleLimit) { return false; } if (balancerComputeThreads != that.balancerComputeThreads) { return false; } if (emitBalancingStats != that.emitBalancingStats) { return false; } if (killUnusedSegmentsInAllDataSources != that.killUnusedSegmentsInAllDataSources) { return false; } if (maxSegmentsInNodeLoadingQueue != that.maxSegmentsInNodeLoadingQueue) { return false; } if (!Objects.equals(specificDataSourcesToKillUnusedSegmentsIn, that.specificDataSourcesToKillUnusedSegmentsIn)) { return false; } if (!Objects.equals(dataSourcesToNotKillStalePendingSegmentsIn, that.dataSourcesToNotKillStalePendingSegmentsIn)) { return false; } if (!Objects.equals(decommissioningNodes, that.decommissioningNodes)) { return false; } return decommissioningMaxPercentOfMaxSegmentsToMove == that.decommissioningMaxPercentOfMaxSegmentsToMove; }</code><technical_language>Whoa, takes a deal of concentration check variables represent property. I bigger is variable naming</technical_language>

Target:
public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } CoordinatorDynamicConfig that = (CoordinatorDynamicConfig) o; if (leadingTimeMillisBeforeCanMarkAsUnusedOvershadowedSegments != that.leadingTimeMillisBeforeCanMarkAsUnusedOvershadowedSegments) { return false; } if (mergeBytesLimit != that.mergeBytesLimit) { return false; } if (mergeSegmentsLimit != that.mergeSegmentsLimit) { return false; } if (maxSegmentsToMove != that.maxSegmentsToMove) { return false; } if (replicantLifetime != that.replicantLifetime) { return false; } if (replicationThrottleLimit != that.replicationThrottleLimit) { return false; } if (balancerComputeThreads != that.balancerComputeThreads) { return false; } if (emitBalancingStats != that.emitBalancingStats) { return false; } if (killUnusedSegmentsInAllDataSources != that.killUnusedSegmentsInAllDataSources) { return false; } if (maxSegmentsInNodeLoadingQueue != that.maxSegmentsInNodeLoadingQueue) { return false; } if (!Objects.equals(specificDataSourcesToKillUnusedSegmentsIn, that.specificDataSourcesToKillUnusedSegmentsIn)) { return false; } if (!Objects.equals(dataSourcesToNotKillStalePendingSegmentsIn, that.dataSourcesToNotKillStalePendingSegmentsIn)) { return false; } if (!Objects.equals(decommissioningNodes, that.decommissioningNodes)) { return false; } return decommissioningMaxPercentOfMaxSegmentsToMove == that.decommissioningMaxPercentOfMaxSegmentsToMove; }
Source:
<code>public String getHadoopJobIdFileName() { <START> String hadoopJobIdFileName = "mapReduceJobId.json"; <END> StringBuilder fileName = new StringBuilder(getContext().getOrDefault(ForkingTaskRunner.INDEX_TASK_DIR, Strings.EMPTY).toString()); fileName.append("/"); fileName.append(hadoopJobIdFileName); return fileName.toString(); }</code><technical_language>this a constant</technical_language>

Target:
public String getHadoopJobIdFileName() { return new File(taskConfig.getTaskDir(getId()), HADOOP_JOB_ID_FILENAME).getAbsolutePath(); }
Source:
<code>public void testSafelyLoadNullFileBytesFile() { try { File nullFile = null; byte[] nullFIleContents = LoadFileUtils.safelyLoadFileBytes(nullFile); } catch (IllegalArgumentException iae) { assertTrue(true); return; } <START> assertTrue("Expected to cause illegal argument exception, but did not.", false); <END> }</code><technical_language>Another method assertions simplified (remove always-succeeding assertion, replace always-failing assertTrue() fail(), etc.)</technical_language>

Target:
public void testSafelyLoadNullFileBytesFile() { try { File nullFile = null; byte[] nullFIleContents = LoadFileUtils.safelyLoadFileBytes(nullFile); fail("Expected to cause illegal argument exception, but did not."); } catch (IllegalArgumentException iae) { } }
Source:
<code>protected boolean addVmImages() { if (getVmTemplate().getDiskTemplateMap().size() > 0) { if (getVm().getStatus() != VMStatus.Down) { log.error("Cannot add images. VM is not Down"); throw new EngineException(EngineError.IRS_IMAGE_STATUS_ILLEGAL); } VmHandler.lockVm(getVm().getDynamicData(), getCompensationContext()); Collection<DiskImage> templateDisks = getVmTemplate().getDiskTemplateMap().values(); List<DiskImage> diskImages = ImagesHandler.filterImageDisks(templateDisks, true, false, true); for (DiskImage disk : diskImages) { VdcReturnValueBase result = runInternalActionWithTasksContext( VdcActionType.CreateCloneOfTemplate, buildCreateCloneOfTemplateParameters(disk) ); if (!result.getSucceeded()) { throw new EngineException(result.getFault().getError()); } getTaskIdList().addAll(result.getInternalVdsmTaskIdList()); DiskImage newImage = (DiskImage) result.getActionReturnValue(); getSrcDiskIdToTargetDiskIdMapping().put(disk.getId(), newImage.getId()); } List<CinderDisk> cinderDisks = ImagesHandler.filterDisksBasedOnCinder(templateDisks); if (!cinderDisks.isEmpty()) { addVmCinderDisks(cinderDisks); <START> } <END> } return true; }</code><technical_language>consider moving if addVmCinderDisks method</technical_language>

Target:
protected boolean addVmImages() { if (getVmTemplate().getDiskTemplateMap().size() > 0) { if (getVm().getStatus() != VMStatus.Down) { log.error("Cannot add images. VM is not Down"); throw new EngineException(EngineError.IRS_IMAGE_STATUS_ILLEGAL); } VmHandler.lockVm(getVm().getDynamicData(), getCompensationContext()); Collection<DiskImage> templateDisks = getVmTemplate().getDiskTemplateMap().values(); List<DiskImage> diskImages = ImagesHandler.filterImageDisks(templateDisks, true, false, true); for (DiskImage disk : diskImages) { VdcReturnValueBase result = runInternalActionWithTasksContext( VdcActionType.CreateCloneOfTemplate, buildCreateCloneOfTemplateParameters(disk) ); if (!result.getSucceeded()) { throw new EngineException(result.getFault().getError()); } getTaskIdList().addAll(result.getInternalVdsmTaskIdList()); DiskImage newImage = (DiskImage) result.getActionReturnValue(); getSrcDiskIdToTargetDiskIdMapping().put(disk.getId(), newImage.getId()); } addVmCinderDisks(templateDisks); } return true; }
Source:
<code>public void undo(long tid, Master env) throws Exception { for (ImportedTableInfo.DirectoryMapping dm : tableInfo.directories) { env.getFileSystem().deleteRecursively(new Path(dm.importDir)); } <START> } <END></code><technical_language>I if exists in directory, deleting dangerous...</technical_language>

Target:
public void undo(long tid, Master env) throws Exception { for (ImportedTableInfo.DirectoryMapping dm : tableInfo.directories) { env.getVolumeManager().deleteRecursively(new Path(dm.importDir)); } }
Source:
<code>public Element(String locator) { <START> this.locatorType = null; <END> this.locator = locator; }</code><technical_language>I agree Mike. deprecate constructor</technical_language>

Target:
public Element(String locator) { this(null, locator); }
Source:
<code>protected void captureThrowable(Runnable c) { try { c.run(); } catch (Throwable e) { <START> e.printStackTrace(); <END> asyncExceptions.add(e); } }</code><technical_language>logger</technical_language>

Target:
protected void captureThrowable(Runnable c) { try { c.run(); } catch (Throwable e) { LOG.error("Captured error: {}", e); asyncExceptions.add(e); } }
Source:
<code>protected List<ShowRoomCategory> getShowRoomCategories() { Random random = new Random(); int recommendedPage; <START> if (recommendedShowRoomPageCount > 0) { <END> recommendedPage = random.nextInt(recommendedShowRoomPageCount) + 1; } else { recommendedPage = 1; } return Arrays.asList( new ShowRoomCategory(() -> mapService.getRecommendedMapsWithPageCount(TOP_ELEMENT_COUNT, recommendedPage), SearchType.RECOMMENDED, "mapVault.recommended"), new ShowRoomCategory(() -> mapService.getHighestRatedMapsWithPageCount(TOP_ELEMENT_COUNT, 1), SearchType.HIGHEST_RATED, "mapVault.mostLikedMaps"), new ShowRoomCategory(() -> mapService.getNewestMapsWithPageCount(TOP_ELEMENT_COUNT, 1), SearchType.NEWEST, "mapVault.newestMaps"), new ShowRoomCategory(() -> mapService.getMostPlayedMapsWithPageCount(TOP_ELEMENT_COUNT, 1), SearchType.PLAYED, "mapVault.mostPlayed"), new ShowRoomCategory(() -> mapService.getOwnedMapsWithPageCount(TOP_ELEMENT_COUNT, 1), SearchType.OWN, "mapVault.owned")); }</code><technical_language>null check if null set showRoomCategory I</technical_language>

Target:
protected List<ShowRoomCategory> getShowRoomCategories() { Random random = new Random(); int recommendedPage; if (recommendedShowRoomPageCount != null && recommendedShowRoomPageCount > 0) { recommendedPage = random.nextInt(recommendedShowRoomPageCount) + 1; } else { recommendedPage = 1; } return Arrays.asList( new ShowRoomCategory(() -> mapService.getRecommendedMapsWithPageCount(TOP_ELEMENT_COUNT, recommendedPage), SearchType.RECOMMENDED, "mapVault.recommended"), new ShowRoomCategory(() -> mapService.getHighestRatedMapsWithPageCount(TOP_ELEMENT_COUNT, 1), SearchType.HIGHEST_RATED, "mapVault.mostLikedMaps"), new ShowRoomCategory(() -> mapService.getNewestMapsWithPageCount(TOP_ELEMENT_COUNT, 1), SearchType.NEWEST, "mapVault.newestMaps"), new ShowRoomCategory(() -> mapService.getMostPlayedMapsWithPageCount(TOP_ELEMENT_COUNT, 1), SearchType.PLAYED, "mapVault.mostPlayed"), new ShowRoomCategory(() -> mapService.getOwnedMapsWithPageCount(TOP_ELEMENT_COUNT, 1), SearchType.OWN, "mapVault.owned")); }
Source:
<code>public long nextRequestSequence() { <START> return this.requestSequence.get() + 1; <END> }</code><technical_language>a volatile long AtomicLongFieldUpdater</technical_language>

Target:
public long nextRequestSequence() { return this.requestSequence + 1; }
Source:
<code>public KeyInfo getKeyInfo(final PublicKey publicKey) throws SAMLComponentBuilderException { final KeyInfoBean keyInfoBean = new KeyInfoBean(); KeyInfo keyInfo = null; keyInfoBean.setPublicKey(publicKey); try { keyInfo = SAML1ComponentBuilder.createKeyInfo(keyInfoBean); <START> } catch (org.opensaml.security.SecurityException | org.apache.wss4j.common.ext.WSSecurityException e) { <END> LOG.error(e.getLocalizedMessage(), e); throw new SAMLComponentBuilderException(e.getLocalizedMessage(), e); } return keyInfo; }</code><technical_language>importing classes top of file</technical_language>

Target:
public KeyInfo getKeyInfo(final PublicKey publicKey) throws SAMLComponentBuilderException { final KeyInfoBean keyInfoBean = new KeyInfoBean(); KeyInfo keyInfo = null; keyInfoBean.setPublicKey(publicKey); try { keyInfo = SAML1ComponentBuilder.createKeyInfo(keyInfoBean); } catch (SecurityException | WSSecurityException e) { LOG.error(e.getLocalizedMessage(), e); throw new SAMLComponentBuilderException(e.getLocalizedMessage(), e); } return keyInfo; }
Source:
<code>public void testPolymorphicReturnSubclass() throws Exception { FlyingSheep flyingSheep = dao.get(FlyingSheep.class, "Fluffy"); assertEquals("Fluffy", flyingSheep.getName()); <START> assertEquals(5, flyingSheep.getNumWings()); <END> }</code><technical_language>Alternatively, AssertJ goodness: java assertThat(flyingSheep).extracting("name", "numWings").containsExactly("Fluffy", 5);</technical_language>

Target:
public void testPolymorphicReturnSubclass() throws Exception { FlyingSheep flyingSheep = dao.get(FlyingSheep.class, "Fluffy"); assertThat(flyingSheep.getName()).isEqualTo("Fluffy"); assertThat(flyingSheep.getNumWings()).isEqualTo(5); }
Source:
<code>public boolean isRoot() { <START> return parentResource == null && !(rawSource instanceof GraphQLContainer); <END> }</code><technical_language>Do need of checks</technical_language>

Target:
public boolean isRoot() { return !(rawSource instanceof GraphQLContainer); }
Source:
<code>public void beginWindow(long windowId) { currentWindowId = windowId; if (currentWindowId <= windowManager.getLargestRecoveryWindow()) { try { replay(currentWindowId); return; } catch (SQLException e) { LOG.error("Exception in replayed windows", e); throw new RuntimeException(e); } } if (isPollerPartition) { updatePollQuery(); <START> isPolled = false; <END> } lowerBound = lastEmittedRecord; }</code><technical_language>isPolled false irrespective of is a poller partition not</technical_language>

Target:
public void beginWindow(long windowId) { currentWindowId = windowId; if (currentWindowId <= windowManager.getLargestRecoveryWindow()) { try { replay(currentWindowId); return; } catch (SQLException e) { LOG.error("Exception in replayed windows", e); throw new RuntimeException(e); } } if (isPollerPartition) { updatePollQuery(); isPolled = false; } lowerBound = lastEmittedRow; }
Source:
<code>public void onStop() { super.onStop(); mGoogleApiClient.stopAutoManage(getActivity()); <START> if (mGoogleApiClient != null && mGoogleApiClient.isConnected()) { <END> mGoogleApiClient.disconnect(); } }</code><technical_language>move null check mGoogleApiClient a level protect access stopAutoManage. wdyt</technical_language>

Target:
public void onStop() { super.onStop(); if (mGoogleApiClient != null) { mGoogleApiClient.stopAutoManage(getActivity()); if (mGoogleApiClient.isConnected()) { mGoogleApiClient.disconnect(); } } }
Source:
<code>public void testGetAllInterfacesByLabelForCluster() { List<VdsNetworkInterface> interfaces = dao.getAllInterfacesByLabelForCluster(CLUSTER_ID, LABEL); assertNotNull(interfaces); <START> assertEquals(1, interfaces.size()); <END> }</code><technical_language>check for specific size? more sense returned list LABEL is contained in labels field of interface</technical_language>

Target:
public void testGetAllInterfacesByLabelForCluster() { List<VdsNetworkInterface> interfaces = dao.getAllInterfacesByLabelForCluster(CLUSTER_ID, LABEL); assertNotNull(interfaces); assertFalse(interfaces.isEmpty()); for (VdsNetworkInterface nic : interfaces) { assertTrue(nic.getLabels().contains(LABEL)); } }
Source:
<code><START> FNatsTransport(Connection conn, String subject, String inbox, boolean isTTransport) { <END> super(NATS_MAX_MESSAGE_SIZE, FRAME_BUFFER_SIZE, LOGGER); this.conn = conn; this.subject = subject; this.inbox = inbox; this.isTTransport = isTTransport; }</code><technical_language>create a class isTTransport is true</technical_language>

Target:
FNatsTransport(Connection conn, String subject, String inbox, boolean isTTransport) { super(NATS_MAX_MESSAGE_SIZE, FRAME_BUFFER_SIZE); this.conn = conn; this.subject = subject; this.inbox = inbox; this.isTTransport = isTTransport; }
Source:
<code><START> Map<WAL, Boolean> getWalNeedsRoll() { <END> Map<WAL, Boolean> walNeedsRoll = new HashMap<>(); for (Map.Entry<WAL, RollController> entry : this.walNeedsRoll.entrySet()) { walNeedsRoll.put(entry.getKey(), entry.getValue().isRequestRoll()); } return walNeedsRoll; }</code><technical_language>This is exposed for test cases only. This is a private class.. ok change return type. new RollController clear idea a wal instance needs roll of periodic roll explicitly asked for. is better. A return type of Map<WAL, RollController> dont need synchronized block. Else, if do is done in patch, need synchronized block</technical_language>

Target:
Map<WAL, RollController> getWalNeedsRoll() { return this.wals; }
Source:
<code>private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL, Class<?> clazz, String name) throws NoSuchMethodException { if (!type.isAssignableFrom(clazz)) { throw new IllegalStateException("Error occurred when loading extension class (interface: " + type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface."); } if (clazz.isAnnotationPresent(Adaptive.class)) { cacheAdaptiveClass(clazz); } else if (isWrapperClass(clazz)) { cacheWrapperClass(clazz); } else { clazz.getConstructor(); if (StringUtils.isEmpty(name)) { name = findAnnotationName(clazz); if (name.length() == 0) { throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL); } } String[] names = NAME_SEPARATOR.split(name); <START> cacheActivateClass(clazz, names[0]); <END> cacheNames(clazz, names); saveInExtensionClasses(extensionClasses, clazz, names); } }</code><technical_language>defensive programming judge **names** is null empty, plus, I suggest loop **names** once, below: suggestion String[] names = NAME_SEPARATOR.split(name); if (ArrayUtils.isNotEmpty(names)) { cacheActivateClass(clazz, names[0]); for (String n : names) { cacheName(clazz, n); saveInExtensionClass(extensionClasses, clazz, name); } } loop outside, change cacheNames cacheName, change saveInExtensionClasses saveInExtensionClass</technical_language>

Target:
private void loadClass(Map<String, Class<?>> extensionClasses, java.net.URL resourceURL, Class<?> clazz, String name) throws NoSuchMethodException { if (!type.isAssignableFrom(clazz)) { throw new IllegalStateException("Error occurred when loading extension class (interface: " + type + ", class line: " + clazz.getName() + "), class " + clazz.getName() + " is not subtype of interface."); } if (clazz.isAnnotationPresent(Adaptive.class)) { cacheAdaptiveClass(clazz); } else if (isWrapperClass(clazz)) { cacheWrapperClass(clazz); } else { clazz.getConstructor(); if (StringUtils.isEmpty(name)) { name = findAnnotationName(clazz); if (name.length() == 0) { throw new IllegalStateException("No such extension name for the class " + clazz.getName() + " in the config " + resourceURL); } } String[] names = NAME_SEPARATOR.split(name); if (ArrayUtils.isNotEmpty(names)) { cacheActivateClass(clazz, names[0]); for (String n : names) { cacheName(clazz, n); saveInExtensionClass(extensionClasses, clazz, name); } } } }
Source:
<code>public ValidationResult supportedFirewallTypeForClusterVersion() { return ValidationResult .failWith( EngineMessage.UNSUPPORTED_FIREWALL_TYPE_FOR_CLUSTER_VERSION, <START> String.format("$clusterVersion %s", cluster.getCompatibilityVersion()), <END> String.format("$firewallType %s", cluster.getFirewallType()) ) .when(cluster.getCompatibilityVersion().equals(Version.v3_6) && FirewallType.FIREWALLD.equals(cluster.getFirewallType())); }</code><technical_language>pls ReplacementUtils.createSetVariableString, i.e.: ReplacementUtils.createSetVariableString(clusterVersion, cluster.getCompatibilityVersion())</technical_language>

Target:
public ValidationResult supportedFirewallTypeForClusterVersion() { return ValidationResult .failWith( EngineMessage.UNSUPPORTED_FIREWALL_TYPE_FOR_CLUSTER_VERSION, ReplacementUtils.createSetVariableString("$clusterVersion", cluster.getCompatibilityVersion()), ReplacementUtils.createSetVariableString("$firewallType", cluster.getFirewallType()) ) .when(cluster.getCompatibilityVersion().lessOrEquals(Version.v3_6) && FirewallType.FIREWALLD.equals(cluster.getFirewallType())); }
Source:
<code><START> public PosDataCode (byte[] b) { <END> if (b != null) { int copyLen= Math.min(b.length, 16); System.arraycopy(b, 0, this.b, 0, copyLen); } }</code><technical_language>changing this constructor public? a PosDataCode.valueOf(byte[]) factory method. OK null validation, understand need public constructor</technical_language>

Target:
private PosDataCode (byte[] b) { if (b != null) { int copyLen= Math.min(b.length, 16); System.arraycopy(b, 0, this.b, 0, copyLen); } }
Source:
<code>public SchemaCompatibilityResult mergedWith(SchemaCompatibilityResult toMerge) { List<Incompatibility> mergedIncompatibilities = new ArrayList<Incompatibility>(mIncompatibilities); mergedIncompatibilities.addAll(toMerge.getIncompatibilities()); <START> SchemaCompatibilityType compatibilityType = mCompatibilityType == SchemaCompatibilityType.COMPATIBLE <END> && toMerge.mCompatibilityType == SchemaCompatibilityType.COMPATIBLE ? SchemaCompatibilityType.COMPATIBLE : SchemaCompatibilityType.INCOMPATIBLE; return new SchemaCompatibilityResult(compatibilityType, mergedIncompatibilities); }</code><technical_language>in case of RECURSION_IN_PROGRESS? need && toMerge.mCompatibilityType == SchemaCompatibilityType.COMPATIBLE, this simpler a bit: SchemaCompatibilityType compatibilityType = mCompatibilityType == SchemaCompatibilityType.COMPATIBLE ? toMerge.getCompatibility() : SchemaCompatibilityType.INCOMPATIBLE;</technical_language>

Target:
public SchemaCompatibilityResult mergedWith(SchemaCompatibilityResult toMerge) { List<Incompatibility> mergedIncompatibilities = new ArrayList<Incompatibility>(mIncompatibilities); mergedIncompatibilities.addAll(toMerge.getIncompatibilities()); SchemaCompatibilityType compatibilityType = mCompatibilityType == SchemaCompatibilityType.COMPATIBLE ? toMerge.mCompatibilityType : SchemaCompatibilityType.INCOMPATIBLE; return new SchemaCompatibilityResult(compatibilityType, mergedIncompatibilities); }
Source:
<code>public String toString() { <START> return rejectionReasons.size() < 2 ? Iterables.getFirst(rejectionReasons, "") : Joiner.on(", ").join(rejectionReasons); <END> }</code><technical_language>Joiner handle empty single-element Iterable in expected manner: java if (parts.hasNext()) { appendable.append(toString(parts.next())); while (parts.hasNext()) { appendable.append(separator); appendable.append(toString(parts.next())); } }</technical_language>

Target:
public String toString() { return Joiner.on(", ").join(rejectionReasons); }
Source:
<code>private static boolean hasSafeType( Object value ) { <START> if ( value instanceof Value ) <END> { return true; } else if ( value instanceof String ) { return true; } else if ( value instanceof Long ) { return true; } else if ( value instanceof Integer ) { return true; } else if ( value instanceof Boolean ) { return true; } else if ( value instanceof Double ) { return true; } else if ( value instanceof Float ) { return true; } else if ( value instanceof Short ) { return true; } else if ( value instanceof Byte ) { return true; } else if ( value.getClass().isArray() && value.getClass().getComponentType().isPrimitive() ) { return true; } else { return false; } }</code><technical_language>I this if/else is phrased single boolean expression</technical_language>

Target:
private static boolean hasSafeType( Object value ) { return value instanceof Value || value instanceof String || value instanceof Long || value instanceof Integer || value instanceof Boolean || value instanceof Double || value instanceof Float || value instanceof Short || value instanceof Byte || (value.getClass().isArray() && value.getClass().getComponentType().isPrimitive()); }
Source:
<code>public String takeElementScreenshot(String baseName, WebElement element) { String result = null; WebDriver d = driver(); if (!(d instanceof TakesScreenshot)) { d = new Augmenter().augment(d); } if (d instanceof TakesScreenshot) { TakesScreenshot ts = (TakesScreenshot) d; <START> File screenshot = ts.getScreenshotAs(OutputType.FILE); <END> try { BufferedImage fullWindow = ImageIO.read(screenshot); Point location = element.getLocation(); int w = element.getSize().getWidth(); int h = element.getSize().getHeight(); BufferedImage elementScreenshot = fullWindow.getSubimage(location.getX(), location.getY(), w, h); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ImageIO.write(elementScreenshot, "png", baos); result = writeScreenshot(baseName, baos.toByteArray()); } catch (IOException e) { throw new SlimFixtureException(true, "Unable to create element screenshot"); } } return result; }</code><technical_language>This part share logic existing screenshot functionality. extracted reduce code/functionality duplication</technical_language>

Target:
public String takeElementScreenshot(String baseName, WebElement element) { String result = null; TakesScreenshot ts = screenshotCapableDriver(); if (ts != null) { File screenshot = ts.getScreenshotAs(OutputType.FILE); try { BufferedImage fullWindow = ImageIO.read(screenshot); Point location = element.getLocation(); int w = element.getSize().getWidth(); int h = element.getSize().getHeight(); BufferedImage elementScreenshot = fullWindow.getSubimage(location.getX(), location.getY(), w, h); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ImageIO.write(elementScreenshot, "png", baos); result = writeScreenshot(baseName, baos.toByteArray()); } catch (IOException e) { throw new SlimFixtureException(true, "Unable to create element screenshot"); } } return result; }
Source:
<code>public List<VmNumaNode> getVmNumaNodes(VM vm) { int onlineCpus = vm.getNumOfCpus(); int vcpus = FeatureSupported.supportedInConfig(ConfigValues.HotPlugCpuSupported, vm.getCompatibilityVersion(), vm.getClusterArch()) ? VmCpuCountHelper.calcMaxVCpu(vm, vm.getClusterCompatibilityVersion()) : onlineCpus; int offlineCpus = vcpus - onlineCpus; List<VmNumaNode> vmNumaNodes = vmNumaNodeDao.getAllVmNumaNodeByVmId(vm.getId()); if (!vmNumaNodes.isEmpty()) { int <START> totalCpusPerNode = <END> 0; for (VmNumaNode vmNode : vmNumaNodes) { totalCpusPerNode += vmNode.getCpuIds().size(); } if (onlineCpus != totalCpusPerNode) { offlineCpus = vcpus - totalCpusPerNode; } if (offlineCpus > 0) { Comparator<VmNumaNode> compareBySize = Comparator.comparingInt(o -> o.getCpuIds().size()); Collections.sort(vmNumaNodes, compareBySize); int numaCount = vmNumaNodes.size(); int start = totalCpusPerNode-1; for (VmNumaNode vmNode : vmNumaNodes) { int index = start = start+1; if (numaCount <= 0) { break; } while (index < vcpus) { vmNode.getCpuIds().add(index); index += numaCount; } } } return vmNumaNodes; } if (offlineCpus > 0) { VmNumaNode vmNode = new VmNumaNode(); vmNode.setIndex(0); vmNode.setMemTotal(vm.getMemSizeMb()); for (int i = 0; i < vcpus; i++) { vmNode.getCpuIds().add(i); } return Collections.singletonList(vmNode); } return Collections.emptyList(); }</code><technical_language>This is 'per node' is count of CPUs defined in NUMA nodes</technical_language>

Target:
public List<VmNumaNode> getVmNumaNodes(VM vm) { int onlineCpus = vm.getNumOfCpus(); int vcpus = FeatureSupported.supportedInConfig(ConfigValues.HotPlugCpuSupported, vm.getCompatibilityVersion(), vm.getClusterArch()) ? VmCpuCountHelper.calcMaxVCpu(vm, vm.getClusterCompatibilityVersion()) : onlineCpus; int offlineCpus = vcpus - onlineCpus; List<VmNumaNode> vmNumaNodes = vmNumaNodeDao.getAllVmNumaNodeByVmId(vm.getId()); if (!vmNumaNodes.isEmpty()) { int totalCpusInNodes = 0; for (VmNumaNode vmNode : vmNumaNodes) { totalCpusInNodes += vmNode.getCpuIds().size(); } if (onlineCpus != totalCpusInNodes) { offlineCpus = vcpus - totalCpusInNodes; } if (offlineCpus > 0) { Comparator<VmNumaNode> compareBySize = Comparator.comparingInt(o -> o.getCpuIds().size()); Collections.sort(vmNumaNodes, compareBySize); int numaCount = vmNumaNodes.size(); int start = totalCpusInNodes-1; for (VmNumaNode vmNode : vmNumaNodes) { int index = start = start+1; while (index < vcpus) { vmNode.getCpuIds().add(index); index += numaCount; } } } return vmNumaNodes; } if (offlineCpus > 0) { VmNumaNode vmNode = new VmNumaNode(); vmNode.setIndex(0); vmNode.setMemTotal(vm.getMemSizeMb()); for (int i = 0; i < vcpus; i++) { vmNode.getCpuIds().add(i); } return Collections.singletonList(vmNode); } return Collections.emptyList(); }
Source:
<code>public void addRule(Rule rule) { if (rule.containsAttribute(Attribute.FUNCTION_KEY)) { functionRules.put(rule.functionKLabel(), rule); if (rule.isSortPredicate()) { sortPredicateRules.put((KLabelConstant) rule.sortPredicateArgument().kLabel(), rule); } } else if (rule.containsAttribute(Attribute.MACRO_KEY)) { macros.add(rule); } else if (rule.containsAttribute(Attribute.ANYWHERE_KEY)) { if (!(rule.leftHandSide() instanceof KItem)) { <START> GlobalSettings.kem.registerCriticalWarning( <END> "The Java backend only supports [anywhere] rule that rewrites KItem; but found:\n\t" + rule, null, rule); return; } anywhereRules.put(rule.anywhereKLabel(), rule); } else { rules.add(rule); } }</code><technical_language>overload of registerCriticalWarning method takes non-null arguments here</technical_language>

Target:
public void addRule(Rule rule) { if (rule.containsAttribute(Attribute.FUNCTION_KEY)) { functionRules.put(rule.definedKLabel(), rule); if (rule.isSortPredicate()) { sortPredicateRules.put((KLabelConstant) rule.sortPredicateArgument().kLabel(), rule); } } else if (rule.containsAttribute(Attribute.PATTERN_KEY)) { patternRules.put(rule.definedKLabel(), rule); } else if (rule.containsAttribute(Attribute.MACRO_KEY)) { macros.add(rule); } else if (rule.containsAttribute(Attribute.ANYWHERE_KEY)) { if (!(rule.leftHandSide() instanceof KItem)) { GlobalSettings.kem.registerCriticalWarning( "The Java backend only supports [anywhere] rule that rewrites KItem; but found:\n\t" + rule, rule); return; } anywhereRules.put(rule.anywhereKLabel(), rule); } else { rules.add(rule); } }
Source:
<code>public IndexDiffCacheEntry(Repository repository) { this.repository = repository; repository.getListenerList().addIndexChangedListener( new IndexChangedListener() { public void onIndexChanged(IndexChangedEvent event) { refreshIndexDelta(); } }); repository.getListenerList().addRefsChangedListener( new RefsChangedListener() { public void onRefsChanged(RefsChangedEvent event) { scheduleReloadJob("RefsChanged"); } }); scheduleReloadJob("IndexDiffCacheEntry construction"); createResourceChangeListener(); if (!repository.isBare()) { try { lastIndex = repository.readDirCache(); <START> } catch(IOException ex) { <END> Activator.error(String.format(CoreText.IndexDiffCacheEntry_errorCalculatingIndexDelta, repository), ex); } } }</code><technical_language>Add space catch</technical_language>

Target:
public IndexDiffCacheEntry(Repository repository) { this.repository = repository; repository.getListenerList().addIndexChangedListener( new IndexChangedListener() { public void onIndexChanged(IndexChangedEvent event) { refreshIndexDelta(); } }); repository.getListenerList().addRefsChangedListener( new RefsChangedListener() { public void onRefsChanged(RefsChangedEvent event) { scheduleReloadJob("RefsChanged"); } }); scheduleReloadJob("IndexDiffCacheEntry construction"); createResourceChangeListener(); if (!repository.isBare()) { try { lastIndex = repository.readDirCache(); } catch (IOException ex) { Activator.error(MessageFormat.format(CoreText.IndexDiffCacheEntry_errorCalculatingIndexDelta, repository), ex); } } }
Source:
<code>public void verifyTrackingForSingletonLatencyRecords() throws Exception { final int numTasks = 100; AbfsPerfTracker abfsPerfTracker = new AbfsPerfTracker(accountName, filesystemName, true); String latencyDetails = abfsPerfTracker.getClientLatency(); assertThat(latencyDetails).describedAs("AbfsPerfTracker should be empty").isNull(); List<Callable<Integer>> tasks = new ArrayList<>(); AbfsHttpOperation httpOperation = new AbfsHttpOperation(url, "GET", new ArrayList<>()); for (int i=0; i < numTasks; i++) { tasks.add(() -> { try (AbfsPerfInfo tracker = new AbfsPerfInfo(abfsPerfTracker, "oneOperationCaller", "oneOperationCallee")) { tracker.registerResult(httpOperation).registerSuccess(true); return 0; } }); } for (Future<Integer> fr: executorService.invokeAll(tasks)) { fr.get(); } for (int i=0; i < numTasks; i++) { latencyDetails = abfsPerfTracker.getClientLatency(); assertThat(latencyDetails).describedAs("AbfsPerfTracker should return non-null record").isNotNull(); assertThat(Pattern.matches( <START> "h=[^ ]* t=[^ ]* a=bogusFilesystemName c=bogusAccountName cr=oneOperationCaller ce=oneOperationCallee r=Succeeded l=[0-9]+" <END> + " s=0 e= ci=[^ ]* ri=[^ ]* ct=[0-9]+ st=[0-9]+ rt=[0-9]+ bs=0 br=0 m=GET u=http%3A%2F%2Fwww.microsoft.com%2FbogusFile", latencyDetails)) .describedAs("Latency record should be in the correct format").isTrue(); } latencyDetails = abfsPerfTracker.getClientLatency(); assertThat(latencyDetails).describedAs("AbfsPerfTracker should return no record").isNull(); }</code><technical_language>long. this benefit some message</technical_language>

Target:
public void verifyTrackingForSingletonLatencyRecords() throws Exception { final int numTasks = 100; AbfsPerfTracker abfsPerfTracker = new AbfsPerfTracker(accountName, filesystemName, true); String latencyDetails = abfsPerfTracker.getClientLatency(); assertThat(latencyDetails).describedAs("AbfsPerfTracker should be empty").isNull(); List<Callable<Integer>> tasks = new ArrayList<>(); AbfsHttpOperation httpOperation = new AbfsHttpOperation(url, "GET", new ArrayList<>()); for (int i = 0; i < numTasks; i++) { tasks.add(() -> { try (AbfsPerfInfo tracker = new AbfsPerfInfo(abfsPerfTracker, "oneOperationCaller", "oneOperationCallee")) { tracker.registerResult(httpOperation).registerSuccess(true); return 0; } }); } for (Future<Integer> fr: executorService.invokeAll(tasks)) { fr.get(); } for (int i = 0; i < numTasks; i++) { latencyDetails = abfsPerfTracker.getClientLatency(); assertThat(latencyDetails).describedAs("AbfsPerfTracker should return non-null record").isNotNull(); assertThat(latencyDetails).describedAs("Latency record should be in the correct format") .containsPattern("h=[^ ]* t=[^ ]* a=bogusFilesystemName c=bogusAccountName cr=oneOperationCaller" + " ce=oneOperationCallee r=Succeeded l=[0-9]+ s=0 e= ci=[^ ]* ri=[^ ]* bs=0 br=0 m=GET" + " u=http%3A%2F%2Fwww.microsoft.com%2FbogusFile"); } latencyDetails = abfsPerfTracker.getClientLatency(); assertThat(latencyDetails).describedAs("AbfsPerfTracker should return no record").isNull(); }
Source:
<code>public void sourcePrepare(FlowProcess<JobConf> flowProcess, SourceCall<Object[], RecordReader> sourceCall) throws IOException { super.sourcePrepare(flowProcess, sourceCall); Object[] context = new Object[4]; context[0] = sourceCall.getInput().createKey(); context[1] = sourceCall.getInput().createValue(); Settings settings = loadSettings(flowProcess.getConfigCopy(), true); context[2] = CascadingUtils.alias(settings); <START> context[3] = settings.getOutputAsJson(); <END> sourceCall.setContext(context); }</code><technical_language>sense a constant for index in context array, context[OUTPUT_AS_JSON] = settings.getOutputAsJson(); read context array quickly identify is read & set</technical_language>

Target:
public void sourcePrepare(FlowProcess<JobConf> flowProcess, SourceCall<Object[], RecordReader> sourceCall) throws IOException { super.sourcePrepare(flowProcess, sourceCall); Object[] context = new Object[SRC_CTX_SIZE]; context[SRC_CTX_KEY] = sourceCall.getInput().createKey(); context[SRC_CTX_VALUE] = sourceCall.getInput().createValue(); Settings settings = loadSettings(flowProcess.getConfigCopy(), true); context[SRC_CTX_ALIASES] = CascadingUtils.alias(settings); context[SRC_CTX_OUTPUT_JSON] = settings.getOutputAsJson(); sourceCall.setContext(context); }
Source:
<code><START> public List<ITmfCallsite> getCallsites(String traceId, String device, long time) { ITmfStateSystem ss = getStateSystem(); if (ss == null) { return Collections.emptyList(); } int quark = ss.optQuarkAbsolute(CallsiteStateProvider.DEVICES, traceId, device); int invalidAttribute = ITmfStateSystem.INVALID_ATTRIBUTE; if (quark == invalidAttribute) { return Collections.emptyList(); } int stringPool = ss.optQuarkAbsolute(CallsiteStateProvider.STRING_POOL); int fileQuark = ss.optQuarkRelative(quark, CallsiteStateProvider.FILES); int lineQuark = ss.optQuarkRelative(quark, CallsiteStateProvider.LINES); if (fileQuark == ITmfStateSystem.INVALID_ATTRIBUTE || lineQuark == ITmfStateSystem.INVALID_ATTRIBUTE || stringPool == ITmfStateSystem.INVALID_ATTRIBUTE) { return Collections.emptyList(); } List<Integer> files = ss.getSubAttributes(fileQuark, false); List<Integer> lines = ss.getSubAttributes(lineQuark, false); int size = files.size(); if (size != lines.size()) { return Collections.emptyList(); } List<ITmfCallsite> retVal = new ArrayList<>(); try { List<ITmfStateInterval> values = ss.queryFullState(time); Object stringIntern = values.get(fileQuark).getValue(); int lineNo = values.get(lineQuark).getValueInt(); if (lineNo != CallsiteStateProvider.UNKNOWN_LINE_NO && stringIntern instanceof Integer) { String fileName = fSSInterner.resolve(ss, (Integer) stringIntern + ss.getStartTime(), stringPool); if (fileName != null) { retVal.add(new TmfCallsite(fileName, (long) lineNo)); } } } catch (StateSystemDisposedException e) { } return retVal; } <END></code><technical_language>if decide it, iterator instead of manually querying state system</technical_language>

Target:
public List<ITmfCallsite> getCallsites(String traceId, String device, long time) { ITmfCallsiteIterator iterator = iterator(traceId, device, time); if (iterator.hasNext()) { return Collections.singletonList(iterator.next().getCallsite()); } return Collections.emptyList(); }
Source:
<code>public void setMBeanAttribute(ObjectName objectName, String type, String name, String value) throws InstanceNotFoundException, IntrospectionException, ReflectionException, IOException, MBeanException, InvalidAttributeValueException, AttributeNotFoundException { Object attributeValue; switch (type.toLowerCase()) { case "int": attributeValue = Integer.valueOf(value); break; case "string": attributeValue = value; break; default: return; } <START> this.jmxClient.getConnector().getMBeanServerConnection().setAttribute(objectName, <END> new Attribute(name, attributeValue)); }</code><technical_language>potentials AttributeNotFoundException translated 404 status code REST interface</technical_language>

Target:
public void setMBeanAttribute(ObjectName objectName, String type, String name, String value) throws InstanceNotFoundException, IntrospectionException, ReflectionException, IOException, MBeanException, InvalidAttributeValueException, AttributeNotFoundException, IllegalArgumentException { Object attributeValue = MBeanAttributeType.valueOf(type.toUpperCase()).convert(value); this.jmxClient.getConnector().getMBeanServerConnection().setAttribute(objectName, new Attribute(name, attributeValue)); }
Source:
<code>public void onMessage(ClientMessage message) { String body = ""; try { message.acknowledge(); body = message.getBodyBuffer().readString(); log.debug("Got event: {}", body); JobMessage jobMessage = mapper.readValue(body, JobMessage.class); log.debug("ActiveMQ message received for async job: {}.", message.getMessageID(), jobMessage); AsyncJobStatus jobStatus = manager.executeJob(jobMessage); } catch (JobException e) { } catch (Exception e) { String messageId = (message == null) ? "" : Long.toString(message.getMessageID()); String reason = (e.getCause() == null) ? e.getMessage() : e.getCause().getMessage(); log.warn("Job message processing failed! {}: {}", messageId, reason); log.debug("Unable to process message. Rolling back client session.\n{}", body, e); try { <START> session.rollback(); <END> } catch (ActiveMQException amqe) { log.error("Unable to roll back client session.", amqe); } } finally { try { session.commit(); } catch (ActiveMQException amqe) { log.error("Unable to commit client session", amqe); } } }</code><technical_language>consequence is of rolling session attempting commit in finally block below. want verify this is OK, move commit 'success' case</technical_language>

Target:
public void onMessage(ClientMessage message) { String body = ""; try { message.acknowledge(); body = message.getBodyBuffer().readString(); log.debug("Got event: {}", body); JobMessage jobMessage = mapper.readValue(body, JobMessage.class); log.debug("ActiveMQ message received for async job: {}.", message.getMessageID(), jobMessage); AsyncJobStatus jobStatus = manager.executeJob(jobMessage); this.commitSession(); } catch (JobExecutionException e) { this.commitSession(); } catch (JobStateManagementException e) { JobState intendedState = e.getIntendedState(); if (intendedState != null && !intendedState.isTerminal()) { log.error("Job processing failed; rolling back job message to retry later: {}", body); this.rollbackSession(); } else { log.error("Job processing failed terminally; committing job message as acknowledged: {}", body); this.commitSession(); } } catch (JobMessageDispatchException e) { log.error("Failed to dispatch job message during job execution; rolling back job message " + "to retry later: {}", body); this.rollbackSession(); } catch (JobException e) { if (e.isTerminal()) { log.error("Job processing failed terminally; committing job message as acknowledged: {}", body); this.commitSession(); } else { log.error("Job processing failed; rolling back job message to retry later: {}", body); this.rollbackSession(); } } catch (Exception e) { String messageId = (message == null) ? "" : Long.toString(message.getMessageID()); String reason = (e.getCause() == null) ? e.getMessage() : e.getCause().getMessage(); log.warn("Job message processing failed! {}: {}", messageId, reason); log.debug("Unable to process message. Rolling back client session.\n{}", body, e); this.rollbackSession(); } }
Source:
<code>private org.openmrs.module.emrapi.conditionslist.contract.Concept convertCoreConceptToEmrapiConcept(Concept coreConcept) { <START> if (coreConcept != null) { <END> ConceptName fullySpecifiedName = coreConcept.getFullySpecifiedName(Context.getLocale()); if (fullySpecifiedName == null) { fullySpecifiedName = coreConcept.getFullySpecifiedName(getDefaultLocale()); } org.openmrs.module.emrapi.conditionslist.contract.Concept concept = new org.openmrs.module.emrapi.conditionslist.contract.Concept(coreConcept.getUuid(), fullySpecifiedName.getName()); ConceptName shortName = coreConcept.getShortNameInLocale(Context.getLocale()); if (shortName != null) { concept.setShortName(shortName.getName()); } return concept; } return null; }</code><technical_language>I do need check for coreConcept null. call this method if is null</technical_language>

Target:
private org.openmrs.module.emrapi.conditionslist.contract.Concept convertCoreConceptToEmrapiConcept(Concept coreConcept) { ConceptName fullySpecifiedName = coreConcept.getFullySpecifiedName(Context.getLocale()); if (fullySpecifiedName == null) { fullySpecifiedName = coreConcept.getFullySpecifiedName(getDefaultLocale()); } org.openmrs.module.emrapi.conditionslist.contract.Concept concept = new org.openmrs.module.emrapi.conditionslist.contract.Concept(coreConcept.getUuid(), fullySpecifiedName.getName()); ConceptName shortName = coreConcept.getShortNameInLocale(Context.getLocale()); if (shortName != null) { concept.setShortName(shortName.getName()); } return concept; }