auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public int hashCode() { final int prime = 31; int result = 1; result = prime * result + fChildren.hashCode(); result = prime * result + fDepth; result = prime * result + (int) (fEnd ^ (fEnd >>> 32)); ICalledFunction parent = fParent; <START> result = prime * result + ((parent == null) ? 0 : parent.hashCode()); <END> result = prime * result + (int) (fSelfTime ^ (fSelfTime >>> 32)); result = prime * result + (int) (fStart ^ (fStart >>> 32)); result = prime * result + getSymbol().hashCode(); return result; }</code><technical_language>parent.hashCode() call hashcode() of this -> java.lang.StackOverflowError</technical_language>

Target:
public int hashCode() { final int prime = 31; int result = 1; result = prime * result + fDepth; result = prime * result + (int) (fEnd ^ (fEnd >>> 32)); ICalledFunction parent = fParent; result = prime * result + ((parent == null) ? 0 : parent.hashCode()); result = prime * result + (int) (fSelfTime ^ (fSelfTime >>> 32)); result = prime * result + (int) (fStart ^ (fStart >>> 32)); result = prime * result + getSymbol().hashCode(); return result; }
Source:
<code>private boolean checkEvaluation(ICPPASTExpression expr) { ICPPEvaluation eval = expr.getEvaluation(); if (eval instanceof EvalTypeId) { ICPPFunction evalFunc = ((EvalTypeId) eval).getConstructor(); if (evalFunc != null && evalFunc.isNoDiscard()) { return true; } } else if (eval instanceof EvalFunctionCall) { ICPPFunction evalFunc = ((EvalFunctionCall) eval).resolveFunctionBinding(); if (evalFunc == null) return false; if (evalFunc.isNoDiscard()) { return true; } else { ICPPFunctionType fType = evalFunc.getType(); IType retType = SemanticUtil.getNestedType(fType.getReturnType(), SemanticUtil.TDEF); if (CPPTemplates.isDependentType(retType)) { return false; } if (retType instanceof ICPPReferenceType || retType instanceof IPointerType) return false; retType = SemanticUtil.getUltimateType(retType, true); if (retType instanceof ICPPClassType) { return ((ICPPClassType) retType).isNoDiscard(); } else if (retType instanceof ICPPEnumeration) { return ((ICPPEnumeration) retType).isNoDiscard(); <START> } else if (retType instanceof ICPPEnumerationSpecialization) { <END> return ((ICPPEnumerationSpecialization) retType).isNoDiscard(); } } } return false; }</code><technical_language>ICPPEnumerationSpecialization extends ICPPEnumeration, is need for this additional branch</technical_language>

Target:
private boolean checkEvaluation(ICPPASTExpression expr) { ICPPEvaluation eval = expr.getEvaluation(); if (eval instanceof EvalTypeId) { ICPPFunction evalFunc = ((EvalTypeId) eval).getConstructor(); if (evalFunc != null && evalFunc.isNoDiscard()) { return true; } } else if (eval instanceof EvalFunctionCall) { ICPPFunction evalFunc = ((EvalFunctionCall) eval).resolveFunctionBinding(); if (evalFunc == null) return false; if (evalFunc.isNoDiscard()) { return true; } else { ICPPFunctionType fType = evalFunc.getType(); IType retType = SemanticUtil.getNestedType(fType.getReturnType(), SemanticUtil.TDEF); if (CPPTemplates.isDependentType(retType)) { return false; } if (retType instanceof ICPPReferenceType || retType instanceof IPointerType) return false; retType = SemanticUtil.getUltimateType(retType, true); if (retType instanceof ICPPClassType) { return ((ICPPClassType) retType).isNoDiscard(); } else if (retType instanceof ICPPEnumeration) { return ((ICPPEnumeration) retType).isNoDiscard(); } } } return false; }
Source:
<code>private void handleUnknownFeatures(final EObject owner, final FeatureMap featureMap) { <START> final Iterator<FeatureMap.Entry> iter = featureMap.iterator(); List<FeatureMap.Entry> entryList = Lists.newArrayList(); while (iter.hasNext()) { entryList.add(iter.next()); } <END> for (FeatureMap.Entry currentEntry : entryList) { handleFeature(owner, currentEntry.getEStructuralFeature(), currentEntry.getValue()); } }</code><technical_language>replaced List<FeatureMap.Entry> entryList = Lists.newArrayList(featureMap.iterator());</technical_language>

Target:
private void handleUnknownFeatures(final EObject owner, final FeatureMap featureMap) { List<FeatureMap.Entry> entryList = Lists.newArrayList(featureMap.iterator()); for (FeatureMap.Entry currentEntry : entryList) { handleFeature(owner, currentEntry.getEStructuralFeature(), currentEntry.getValue()); } }
Source:
<code>public void seekToSegment(long entryId, SeekErrorRule errorRule) throws NoSuchOffsetException, IOException { assert(m_isTransient); assert(entryId >= 0); synchronized(PersistentBinaryDeque.this) { PBDSegment<M> seekSegment = findSegmentWithEntry(entryId, errorRule); <START> moveToValidSegment(); <END> if (m_segment == null) { return; } if (m_segment.segmentIndex() == seekSegment.segmentIndex()) { if (m_segment.getReader(m_cursorId) != null) { m_numRead -= m_segment.getReader(m_cursorId).readIndex(); m_segment.getReader(m_cursorId).close(); m_segment.openForRead(m_cursorId); } } else { if (m_segment.segmentIndex() > seekSegment.segmentIndex()) { for (PBDSegment<M> curr : m_segments.tailMap(seekSegment.segmentIndex(), true).values()) { if (curr.segmentIndex() > m_segment.segmentIndex()) { break; } PBDSegmentReader<M> currReader = curr.getReader(m_cursorId); if (curr.segmentIndex() == m_segment.segmentIndex()) { if (currReader != null) { m_numRead -= currReader.readIndex(); } } else { m_numRead -= curr.getNumEntries(); } if (currReader != null) { currReader.close(); } } } else { PBDSegmentReader<M> segmentReader = m_segment.getReader(m_cursorId); m_numRead += m_segment.getNumEntries(); if (segmentReader != null) { m_numRead -= segmentReader.readIndex(); segmentReader.close(); } for (PBDSegment<M> curr : m_segments.tailMap(m_segment.segmentIndex(), false).values()) { if (curr.segmentIndex() == seekSegment.segmentIndex()) { break; } m_numRead += curr.getNumEntries(); } } m_segment = seekSegment; } } }</code><technical_language>more readable moveToValidSegment() return a tested statement</technical_language>

Target:
public void seekToSegment(long entryId, SeekErrorRule errorRule) throws NoSuchOffsetException, IOException { assert(m_isTransient); assert(entryId >= 0); synchronized(PersistentBinaryDeque.this) { PBDSegment<M> seekSegment = findSegmentWithEntry(entryId, errorRule); if (moveToValidSegment() == null) { return; } if (m_segment.segmentIndex() == seekSegment.segmentIndex()) { if (m_segment.getReader(m_cursorId) != null) { m_numRead -= m_segment.getReader(m_cursorId).readIndex(); m_segment.getReader(m_cursorId).close(); m_segment.openForRead(m_cursorId); } } else { if (m_segment.segmentIndex() > seekSegment.segmentIndex()) { for (PBDSegment<M> curr : m_segments.tailMap(seekSegment.segmentIndex(), true).values()) { if (curr.segmentIndex() > m_segment.segmentIndex()) { break; } PBDSegmentReader<M> currReader = curr.getReader(m_cursorId); if (curr.segmentIndex() == m_segment.segmentIndex()) { if (currReader != null) { m_numRead -= currReader.readIndex(); } } else { m_numRead -= curr.getNumEntries(); } if (currReader != null) { currReader.close(); } } } else { PBDSegmentReader<M> segmentReader = m_segment.getReader(m_cursorId); m_numRead += m_segment.getNumEntries(); if (segmentReader != null) { m_numRead -= segmentReader.readIndex(); segmentReader.close(); } for (PBDSegment<M> curr : m_segments.tailMap(m_segment.segmentIndex(), false).values()) { if (curr.segmentIndex() == seekSegment.segmentIndex()) { break; } m_numRead += curr.getNumEntries(); } } m_segment = seekSegment; } } }
Source:
<code>protected ITmfStateProvider createStateProvider() { <START> if (!(getTrace() instanceof LttngKernelTrace)) { <END> throw new IllegalStateException("LttngKernelStateSystemModule: trace should be of type LttngKernelTrace"); } return new LttngKernelStateProvider((LttngKernelTrace) getTrace()); }</code><technical_language>super.fTrace is final a setter, extra-safe extracted in a local variable (which instanceof cast right type). a Sonar warning too</technical_language>

Target:
protected @NonNull ITmfStateProvider createStateProvider() { ITmfTrace trace = getTrace(); if (!(trace instanceof LttngKernelTrace)) { throw new IllegalStateException("LttngKernelStateSystemModule: trace should be of type LttngKernelTrace"); } return new LttngKernelStateProvider((LttngKernelTrace) trace); }
Source:
<code>public List<NMFData> parse() { <START> final List<NMFData> result = new ArrayList<>(); <END> for (final Pair<LongWritable, Text> ketValue : dataSet) { final String line = ketValue.getSecond().toString().trim(); if (line.startsWith("#") || line.length() == 0) { continue; } final String[] split = line.split("\\s+"); if (split.length != 3) { throw new RuntimeException("Failed to parse: the number of elements in each line should be 3"); } final int rowIndex; final int colIndex; final double value; try { rowIndex = Integer.valueOf(split[0]); colIndex = Integer.valueOf(split[1]); } catch (final NumberFormatException e) { throw new RuntimeException("Failed to parse: numbers for indices should be integer."); } if (rowIndex >= rows) { throw new RuntimeException( String.format("Invalid row index %d. It should be less than # of input rows %d", rowIndex, rows)); } if (colIndex >= cols) { throw new RuntimeException( String.format("Invalid column index %d. It should be less than # of input columns %d", colIndex, cols)); } try { value = Double.valueOf(split[2]); } catch (final NumberFormatException e) { throw new RuntimeException("Failed to parse: numbers for values should be double."); } if (value < 0) { throw new RuntimeException("Failed to parse: numbers should be greater than or equal to zero."); } result.add(new NMFData(rowIndex, colIndex, value)); } return result; }</code><technical_language>Lots of array reallocation happened size of data grows. LinkedList result read sequentially</technical_language>

Target:
public List<NMFData> parse() { final List<NMFData> result = new LinkedList<>(); for (final Pair<LongWritable, Text> keyValue : dataSet) { final String line = keyValue.getSecond().toString().trim(); if (line.startsWith("#") || line.length() == 0) { continue; } final String[] split = line.split("\\s+"); if (split.length != 3) { throw new RuntimeException("Failed to parse: the number of elements in each line should be 3"); } final int rowIndex; final int colIndex; final double value; try { rowIndex = Integer.valueOf(split[0]); colIndex = Integer.valueOf(split[1]); } catch (final NumberFormatException e) { throw new RuntimeException("Failed to parse: numbers for indices should be integer.", e); } if (rowIndex > numRows) { throw new RuntimeException( String.format("Invalid row index %d. It should be less than # of input rows %d", rowIndex, numRows)); } if (colIndex > numCols) { throw new RuntimeException( String.format("Invalid column index %d. It should be less than # of input columns %d", colIndex, numCols)); } if (rowIndex <= 0 || colIndex <= 0) { throw new RuntimeException("Invalid indices. It should be greater than zero"); } try { value = Double.valueOf(split[2]); } catch (final NumberFormatException e) { throw new RuntimeException("Failed to parse: numbers for values should be double.", e); } if (value < 0) { throw new RuntimeException("Failed to parse: numbers should be greater than or equal to zero."); } result.add(new NMFData(rowIndex, colIndex, value)); } return result; }
Source:
<code>public void FileOpenEmptyTest() throws IOException, BadPcapFileException { PcapTestTrace trace = PcapTestTrace.EMPTY_PCAP; assumeTrue(trace.exists()); <START> PcapFile file = trace.getTrace(); <END> assertEquals(PcapTestTrace.EMPTY_PCAP.getPath(), file.getPath()); assertEquals(2, file.getMajorVersion()); assertEquals(4, file.getMinorVersion()); assertEquals(1, file.getDataLinkType()); assertEquals(65535, file.getSnapLength()); assertEquals(0, file.getTimeAccuracy()); assertEquals(0, file.getTimeZoneCorrection()); assertEquals(ByteOrder.LITTLE_ENDIAN, file.getByteOrder()); assertEquals(0, file.getTotalNbPackets()); }</code><technical_language>I try</technical_language>

Target:
public void FileOpenEmptyTest() throws IOException, BadPcapFileException { PcapTestTrace trace = PcapTestTrace.EMPTY_PCAP; assumeTrue(trace.exists()); try (PcapFile file = trace.getTrace();) { assertEquals(PcapTestTrace.EMPTY_PCAP.getPath(), file.getPath()); assertEquals(2, file.getMajorVersion()); assertEquals(4, file.getMinorVersion()); assertEquals(1, file.getDataLinkType()); assertEquals(65535, file.getSnapLength()); assertEquals(0, file.getTimeAccuracy()); assertEquals(0, file.getTimeZoneCorrection()); assertEquals(ByteOrder.LITTLE_ENDIAN, file.getByteOrder()); assertEquals(0, file.getTotalNbPackets()); } }
Source:
<code>public void copyObject(String bucketName, String objectName, ServerSideEncryption sseSource, String destBucketName, String destObjectName, CopyConditions copyConditions, ServerSideEncryption sseTarget) throws InvalidKeyException, InvalidBucketNameException, NoSuchAlgorithmException, InsufficientDataException, NoResponseException, ErrorResponseException, InternalException, IOException, XmlPullParserException, InvalidArgumentException { if ((sseTarget.getType() == ServerSideEncryption.Type.SSE_C) && (!this.baseUrl.isHttps())) { <START> throw new InvalidArgumentException("SSE_C provided keys must be made over a secure connection."); <END> } else { Map<String, String> headerTarget = new HashMap<>(); Map<String, String> headers = new HashMap<>(); sseTarget.marshal(headerTarget); if (sseTarget.getType() == ServerSideEncryption.Type.SSE_C) { Map<String, String> headerSource = new HashMap<>(); sseSource.marshal(headerSource); headers.putAll(headerSource); headers.putAll(headerTarget); } else { headers.putAll(headerTarget); } copyObject(bucketName, objectName, destBucketName, destObjectName, copyConditions, headers); } }</code><technical_language>SSE_C operations performed a secure connection</technical_language>

Target:
public void copyObject(String bucketName, String objectName, ServerSideEncryption sseSource, String destBucketName, String destObjectName, CopyConditions copyConditions, ServerSideEncryption sseTarget) throws InvalidKeyException, InvalidBucketNameException, NoSuchAlgorithmException, InsufficientDataException, NoResponseException, ErrorResponseException, InternalException, IOException, XmlPullParserException, InvalidArgumentException { if ((sseTarget.getType() == ServerSideEncryption.Type.SSE_C) && (!this.baseUrl.isHttps())) { throw new InvalidArgumentException("SSE_C operations must be performed over a secure connection."); } else if ((sseTarget.getType() == (ServerSideEncryption.Type.SSE_KMS)) && (!this.baseUrl.isHttps())) { throw new InvalidArgumentException("SSE_KMS operations must be performed over a secure connection."); } Map<String, String> headerTarget = new HashMap<>(); Map<String, String> headers = new HashMap<>(); sseTarget.marshal(headerTarget); if (sseTarget.getType() == ServerSideEncryption.Type.SSE_C) { Map<String, String> headerSource = new HashMap<>(); sseSource.marshal(headerSource); headers.putAll(headerSource); headers.putAll(headerTarget); } else { headers.putAll(headerTarget); } copyObject(bucketName, objectName, destBucketName, destObjectName, copyConditions, headers); }
Source:
<code>private PollingResult pollCommandWithTimeListener(Stack stack, ApiClient apiClient, BigDecimal commandId, long maximumWaitTimeInSeconds, AbstractClouderaManagerCommandCheckerTask<ClouderaManagerPollerObject> listenerTask) { ClouderaManagerPollerObject clouderaManagerPollerObject = new ClouderaManagerPollerObject(stack, apiClient, commandId); return clouderaManagerCommandPollerObjectPollingService.pollWithAbsoluteTimeout( listenerTask, clouderaManagerPollerObject, POLL_INTERVAL, maximumWaitTimeInSeconds, <START> TOLERATE_FIVE_CONSECUTIVE_ERRORS).getLeft(); <END> }</code><technical_language>this is in place, consider passing parameter</technical_language>

Target:
private PollingResult pollCommandWithTimeListener(Stack stack, ApiClient apiClient, BigDecimal commandId, long maximumWaitTimeInSeconds, AbstractClouderaManagerCommandCheckerTask<ClouderaManagerPollerObject> listenerTask) { ClouderaManagerPollerObject clouderaManagerPollerObject = new ClouderaManagerPollerObject(stack, apiClient, commandId); return clouderaManagerCommandPollerObjectPollingService.pollWithAbsoluteTimeoutSingleFailure( listenerTask, clouderaManagerPollerObject, POLL_INTERVAL, maximumWaitTimeInSeconds); }
Source:
<code>public void testIndexSeekAndScan() throws Exception { updateAndCommit( asList( IndexEntryUpdate.add( 1L, index, "a" ), IndexEntryUpdate.add( 2L, index, "a" ), IndexEntryUpdate.add( 3L, index, "b" ) ) ); assertThat( query( exact( 1, "a" ) ), equalTo( asList( 1L, 2L ) ) ); <START> assertThat( query( IndexQuery.exists( 1 ) ), equalTo( asList( 1L, 2L, 3L ) ) ); <END> }</code><technical_language>exists is statically imported</technical_language>

Target:
public void testIndexSeekAndScan() throws Exception { updateAndCommit( asList( IndexEntryUpdate.add( 1L, index, "a" ), IndexEntryUpdate.add( 2L, index, "a" ), IndexEntryUpdate.add( 3L, index, "b" ) ) ); assertThat( query( exact( 1, "a" ) ), equalTo( asList( 1L, 2L ) ) ); assertThat( query( exists( 1 ) ), equalTo( asList( 1L, 2L, 3L ) ) ); }
Source:
<code>void store(String tenantId, Property<?> property) throws CacheException; void remove(String tenantId, String id); void addObserver(String tenantId, String id, Observer observer); void removeObserver(String tenantId, String id, Observer observer); interface Observer<Type> { void created(Property<Type> value); void updated(Property<Type> newValue); <START> void removed(); <END> }</code><technical_language>need provide 'id' of property removed - - atleast id</technical_language>

Target:
void store(String tenantId, Property<?> property) throws CacheException; void remove(String tenantId, String id); void addObserver(String tenantId, String id, Observer observer); void removeObserver(String tenantId, String id, Observer observer); interface Observer<Type> { void created(Property<Type> property); void updated(Property<Type> property); void removed(Property<Type> property); }
Source:
<code>private boolean isCompressedRequestForPathAccepted(String path) { if (cachedCompressedRequestForPathAccepted != null) return cachedCompressedRequestForPathAccepted; try { String gzipCompressedRequestForPathAccepted = Context.getAdministrationService().getGlobalProperty( OpenmrsConstants.GLOBAL_PROPERTY_GZIP_ACCEPT_COMPRESSED_REQUESTS_FOR_PATHS, ""); cachedCompressedRequestForPathAccepted = false; for (String acceptPath : gzipCompressedRequestForPathAccepted.split(",")) { if (path.matches(acceptPath)) { <START> cachedCompressedRequestForPathAccepted = true; <END> } } return cachedCompressedRequestForPathAccepted; } catch (Throwable t) { log.warn("Unable to get the global property: " + OpenmrsConstants.GLOBAL_PROPERTY_GZIP_ACCEPT_COMPRESSED_REQUESTS_FOR_PATHS, t); return false; } }</code><technical_language>break loop match</technical_language>

Target:
private boolean isCompressedRequestForPathAccepted(String path) { try { cachedGZipCompressedRequestForPathAccepted = Context.getAdministrationService().getGlobalProperty( OpenmrsConstants.GLOBAL_PROPERTY_GZIP_ACCEPT_COMPRESSED_REQUESTS_FOR_PATHS, ""); for (String acceptPath : cachedGZipCompressedRequestForPathAccepted.split(",")) { if (path.matches(acceptPath)) { return true; } } return false; } catch (Throwable t) { log.warn("Unable to get the global property: " + OpenmrsConstants.GLOBAL_PROPERTY_GZIP_ACCEPT_COMPRESSED_REQUESTS_FOR_PATHS, t); return false; } }
Source:
<code>private StatisticsFile getStatisticFile() { MinecraftServer server = MinecraftServer.getServer(); File statsDir = new File(server.worldServerForDimension(0).getSaveHandler().getWorldDirectory(), "stats"); <START> File statsFile = new File(statsDir, getUniqueId().toString() + ".json"); <END> if (!statsFile.exists()) { File legacyFile = new File(statsDir, getName() + ".json"); if (legacyFile.exists() && legacyFile.isFile()) { legacyFile.renameTo(statsFile); } } return new StatisticsFile(server, statsFile); }</code><technical_language>Pretty Users a valid GameProfile existed server a statistics file</technical_language>

Target:
private StatisticsManagerServer getStatisticFile() { MinecraftServer server = SpongeImpl.getServer(); File statsDir = new File(server.worldServerForDimension(0).getSaveHandler().getWorldDirectory(), "stats"); File statsFile = new File(statsDir, getUniqueId().toString() + ".json"); if (!statsFile.exists()) { File legacyFile = new File(statsDir, getName() + ".json"); if (legacyFile.exists() && legacyFile.isFile()) { legacyFile.renameTo(statsFile); } } return new StatisticsManagerServer(server, statsFile); }
Source:
<code>private void scheduleWithFixedDelay() { executor.scheduleWithFixedDelay( () -> { CorruptionHealthReport paxosRoundCorruptionReport = analyzeHistoryAndBuildCorruptionHealthReport(); CorruptionHealthReport timestampInvariantsReport = timestampInvariantsVerifier.timestampInvariantsHealthReport(); localCorruptionReport = ImmutableCorruptionHealthReport.builder() <START> .putAllViolatingStatusesToNamespaceAndUseCase( paxosRoundCorruptionReport.violatingStatusesToNamespaceAndUseCase()) <END> .putAllViolatingStatusesToNamespaceAndUseCase( timestampInvariantsReport.violatingStatusesToNamespaceAndUseCase()) .build(); processLocalHealthReport(); }, TIMELOCK_CORRUPTION_ANALYSIS_INTERVAL.getSeconds(), TIMELOCK_CORRUPTION_ANALYSIS_INTERVAL.getSeconds(), TimeUnit.SECONDS); }</code><technical_language>suggestion .from(paxosRoundCorruptionReport)</technical_language>

Target:
private void scheduleWithFixedDelay() { executor.scheduleWithFixedDelay( () -> { CorruptionHealthReport paxosRoundCorruptionReport = analyzeHistoryAndBuildCorruptionHealthReport(); CorruptionHealthReport timestampInvariantsReport = timestampInvariantsVerifier.timestampInvariantsHealthReport(); localCorruptionReport = ImmutableCorruptionHealthReport.builder() .from(paxosRoundCorruptionReport) .putAllViolatingStatusesToNamespaceAndUseCase( timestampInvariantsReport.violatingStatusesToNamespaceAndUseCase()) .build(); processLocalHealthReport(); }, TIMELOCK_CORRUPTION_ANALYSIS_INTERVAL.getSeconds(), TIMELOCK_CORRUPTION_ANALYSIS_INTERVAL.getSeconds(), TimeUnit.SECONDS); }
Source:
<code>public void testSetTexture() throws NoSuchFieldException, IllegalAccessException { CustomTextureService service = new CustomTextureService(plugin); SlimefunItem item = SlimefunMocks.mockSlimefunItem(plugin, "TEXTURE_TEST", new ItemStack(Material.LANTERN)); String version = "Unit Test v1.0"; <START> Config config = (Config) ReflectionUtils.getFieldValue(service, "config"); <END> config.setValue(item.getID(), 300); config.setValue("version", version); service.register(Arrays.asList(item), false); Assertions.assertTrue(service.isActive()); Assertions.assertEquals(version, service.getVersion()); Assertions.assertEquals(300, service.getModelData(item.getID())); ItemStack stack = new ItemStack(Material.DIAMOND); service.setTexture(stack, item.getID()); Assertions.assertTrue(stack.getItemMeta().hasCustomModelData()); Assertions.assertEquals(300, stack.getItemMeta().getCustomModelData()); }</code><technical_language>biggest fan of reflection in unit tests. able access making test</technical_language>

Target:
public void testSetTexture() { Config config = new Config("plugins/temporary"); CustomTextureService service = new CustomTextureService(config); SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "TEXTURE_TEST", new ItemStack(Material.LANTERN)); String version = "Unit Test v1.0"; config.setValue(item.getID(), 300); config.setValue("version", version); service.register(Arrays.asList(item), false); Assertions.assertTrue(service.isActive()); Assertions.assertEquals(version, service.getVersion()); Assertions.assertEquals(300, service.getModelData(item.getID())); ItemStack stack = new ItemStack(Material.DIAMOND); service.setTexture(stack, item.getID()); Assertions.assertTrue(stack.getItemMeta().hasCustomModelData()); Assertions.assertEquals(300, stack.getItemMeta().getCustomModelData()); }
Source:
<code>public void linkResultFieldToSubTrans( IMetaverseNode streamFieldNode, TransMeta subTransMeta, IMetaverseNode subTransNode, IComponentDescriptor descriptor ) { List<StepMeta> steps = subTransMeta.getSteps(); if ( !CollectionUtils.isEmpty( steps ) ) { for ( StepMeta step : steps ) { if ( step.getStepMetaInterface() instanceof RowsToResultMeta ) { RowsToResultMeta rtrm = (RowsToResultMeta) step.getStepMetaInterface(); IComponentDescriptor stepDescriptor = new MetaverseComponentDescriptor( step.getName(), DictionaryConst.NODE_TYPE_TRANS_STEP, subTransNode, descriptor.getContext() ); IMetaverseNode subTransStepNode = stepAnalyzer.createNodeFromDescriptor( stepDescriptor ); try { RowMetaInterface rowMetaInterface = rtrm.getParentStepMeta().getParentTransMeta().getStepFields( step ); for ( int i = 0; i < rowMetaInterface.getFieldNames().length; i++ ) { String field = rowMetaInterface.getFieldNames()[ i ]; if ( streamFieldNode.getName().equals( field ) ) { IComponentDescriptor stepFieldDescriptor = new MetaverseComponentDescriptor( field, DictionaryConst.NODE_TYPE_TRANS_FIELD, subTransStepNode, descriptor.getContext() ); IMetaverseNode subTransField = stepAnalyzer.createFieldNode( stepFieldDescriptor, rowMetaInterface.getValueMeta( i ), StepAnalyzer.NONE, false ); stepAnalyzer.getMetaverseBuilder().addLink( subTransField, DictionaryConst.LINK_DERIVES, streamFieldNode ); } } } catch ( KettleStepException e ) { <START> log.warn( "Could not get step fields of RowsToResult step in sub transformation - " <END> + subTransMeta.getName(), e ); } } } } }</code><technical_language>message localized</technical_language>

Target:
public void linkResultFieldToSubTrans( IMetaverseNode streamFieldNode, TransMeta subTransMeta, IMetaverseNode subTransNode, IComponentDescriptor descriptor ) { List<StepMeta> steps = subTransMeta.getSteps(); if ( !CollectionUtils.isEmpty( steps ) ) { for ( StepMeta step : steps ) { if ( step.getStepMetaInterface() instanceof RowsToResultMeta ) { RowsToResultMeta rtrm = (RowsToResultMeta) step.getStepMetaInterface(); IComponentDescriptor stepDescriptor = new MetaverseComponentDescriptor( step.getName(), DictionaryConst.NODE_TYPE_TRANS_STEP, subTransNode, descriptor.getContext() ); IMetaverseNode subTransStepNode = stepAnalyzer.createNodeFromDescriptor( stepDescriptor ); try { RowMetaInterface rowMetaInterface = rtrm.getParentStepMeta().getParentTransMeta().getStepFields( step ); for ( int i = 0; i < rowMetaInterface.getFieldNames().length; i++ ) { String field = rowMetaInterface.getFieldNames()[ i ]; if ( streamFieldNode.getName().equals( field ) ) { IComponentDescriptor stepFieldDescriptor = new MetaverseComponentDescriptor( field, DictionaryConst.NODE_TYPE_TRANS_FIELD, subTransStepNode, descriptor.getContext() ); IMetaverseNode subTransField = stepAnalyzer.createFieldNode( stepFieldDescriptor, rowMetaInterface.getValueMeta( i ), StepAnalyzer.NONE, false ); stepAnalyzer.getMetaverseBuilder().addLink( subTransField, DictionaryConst.LINK_DERIVES, streamFieldNode ); } } } catch ( KettleStepException e ) { log.warn( Messages.getString( "WARN.SubtransAnalyzer.RowsToResultNotFound", subTransMeta.getName() ), e ); } } } } }
Source:
<code>public List<String> render() { final List<String> violationMessages = new ArrayList<>(); violationMessages.add(violationName); violationMessages.add(MessageFormat.format(VIOLATING_ENTITIES_LIST_FORMAT, violationName, <START> StringUtils.join(violatingEntities, ", "))); <END> return violationMessages; }</code><technical_language>reuse COMMA_SEPARATOR</technical_language>

Target:
public List<String> render() { final List<String> violationMessages = new ArrayList<>(); violationMessages.add(violationName); violationMessages.add(MessageFormat.format(VIOLATING_ENTITIES_LIST_FORMAT, violationName, StringUtils.join(violatingEntities, COMMA_SEPARATOR))); return violationMessages; }
Source:
<code>public void render(Context context, GlusterVolumeEntity volume, SafeHtmlBuilder sb) { if (volume == null) { return; } GlusterStatus status = volume.getStatus(); ImageResource statusImage = null; String tooltip; Boolean isBrickDown = false; for(GlusterBrickEntity brick : volume.getBricks()) { if(brick.getStatus() == GlusterStatus.DOWN) { isBrickDown = true; break; } } if (!isBrickDown) { switch (status) { case DOWN: statusImage = resources.downImage(); tooltip = constants.down(); break; case UP: statusImage = resources.upImage(); tooltip = constants.up(); break; default: statusImage = resources.downImage(); tooltip = constants.down(); } } else { statusImage = resources.volumeUpWarning(); tooltip = constants.volumeBricksDown(); <START> } <END> SafeHtml statusImageHtml = SafeHtmlUtils.fromTrustedString(AbstractImagePrototype.create(statusImage).getHTML()); sb.append(applicationTemplates.statusTemplate(statusImageHtml, tooltip)); }</code><technical_language>In case volume is down, status shown a red-down icon. here, warning icon shown if volume is</technical_language>

Target:
public void render(Context context, GlusterVolumeEntity volume, SafeHtmlBuilder sb) { if (volume == null) { return; } GlusterStatus status = volume.getStatus(); ImageResource statusImage = null; String tooltip; switch (status) { case DOWN: statusImage = resources.downImage(); tooltip = constants.down(); break; case UP: if(isBrickDown(volume)) { statusImage = resources.volumeUpWarning(); tooltip = constants.volumeBricksDown(); } else { statusImage = resources.upImage(); tooltip = constants.up(); } break; default: statusImage = resources.downImage(); tooltip = constants.down(); } SafeHtml statusImageHtml = SafeHtmlUtils.fromTrustedString(AbstractImagePrototype.create(statusImage).getHTML()); sb.append(applicationTemplates.statusTemplate(statusImageHtml, tooltip)); }
Source:
<code>public ParcelFileDescriptor openFile(@NonNull Uri uri, @NonNull String mode) throws FileNotFoundException { if (!TimeZoneRulesDataContract.DATA_URI.equals(uri)) { throw new FileNotFoundException("Unknown <START> URI"); <END> } if (!"r".equals(mode)) { throw new FileNotFoundException("Only read-only access supported."); } File distroFile = null; try { distroFile = File.createTempFile("distro", null, getContext().getFilesDir()); AssetManager assets = getContext().getAssets(); try (InputStream is = assets.open(TimeZoneDistro.FILE_NAME, ACCESS_STREAMING); FileOutputStream fos = new FileOutputStream(distroFile, false )) { copy(is, fos); } return ParcelFileDescriptor.open(distroFile, ParcelFileDescriptor.MODE_READ_ONLY); } catch (IOException e) { throw new RuntimeException("Unable to copy distro asset file", e); } finally { if (distroFile != null) { distroFile.delete(); } } }</code><technical_language>consider quoting offending uri in exception message? is PII</technical_language>

Target:
public ParcelFileDescriptor openFile(@NonNull Uri uri, @NonNull String mode) throws FileNotFoundException { if (!TimeZoneRulesDataContract.DATA_URI.equals(uri)) { throw new FileNotFoundException("Unknown URI: " + uri); } if (!"r".equals(mode)) { throw new FileNotFoundException("Only read-only access supported."); } File distroFile = null; try { distroFile = File.createTempFile("distro", null, getContext().getFilesDir()); AssetManager assets = getContext().getAssets(); try (InputStream is = assets.open(TimeZoneDistro.FILE_NAME, ACCESS_STREAMING); FileOutputStream fos = new FileOutputStream(distroFile, false )) { copy(is, fos); } return ParcelFileDescriptor.open(distroFile, ParcelFileDescriptor.MODE_READ_ONLY); } catch (IOException e) { throw new RuntimeException("Unable to copy distro asset file", e); } finally { if (distroFile != null) { distroFile.delete(); } } }
Source:
<code>public OffsetFetchRequest build(short version) { if (isAllTopicPartitions() && version < 2) { throw new UnsupportedVersionException("The broker only supports OffsetFetchRequest " + "v" + version + ", but we need v2 or newer to request all topic partitions."); } if (data.requireStable() && version < 7) { if (throwOnStableFlagNotSupported) { throw new UnsupportedVersionException("Broker unexpectedly doesn't support requireStable flag " + "on version " + version); <START> } <END> log.trace("Fallback the requireStable flag to false as broker " + "only supports OffsetFetchRequest version {}. Need " + "v7 or newer to enable this feature", version); return new OffsetFetchRequest(data.setRequireStable(false), version); } return new OffsetFetchRequest(data, version); }</code><technical_language>nit: if else {log.trace()}</technical_language>

Target:
public OffsetFetchRequest build(short version) { if (isAllTopicPartitions() && version < 2) { throw new UnsupportedVersionException("The broker only supports OffsetFetchRequest " + "v" + version + ", but we need v2 or newer to request all topic partitions."); } if (data.requireStable() && version < 7) { if (throwOnFetchStableOffsetsUnsupported) { throw new UnsupportedVersionException("Broker unexpectedly " + "doesn't support requireStable flag on version " + version); } else { log.trace("Fallback the requireStable flag to false as broker " + "only supports OffsetFetchRequest version {}. Need " + "v7 or newer to enable this feature", version); return new OffsetFetchRequest(data.setRequireStable(false), version); } } return new OffsetFetchRequest(data, version); }
Source:
<code><START> private PropertySet getRef() { <END> return getCheckedRef(PropertySet.class); }</code><technical_language>this is compatible</technical_language>

Target:
protected PropertySet getRef() { return getCheckedRef(PropertySet.class); }
Source:
<code>public <TElement extends Element> void updateElement( Graph graph, ExistingElementMutation<TElement> elementMutation, Authorizations authorizations ) { TElement element = elementMutation.getElement(); if (MUTATION_LOGGER.isTraceEnabled()) { MUTATION_LOGGER.trace("updateElement: %s", elementMutation.getId()); } if (!getConfig().isIndexEdges() && elementMutation.getElementType() == ElementType.EDGE) { return; } <START> bulkUpdateService.flushUntilElementIdIsComplete(elementMutation.getId()); <END> addMutationPropertiesToIndex(graph, elementMutation); addUpdateForMutationToBulk(graph, elementMutation); if (elementMutation.getNewElementVisibility() != null && element.getFetchHints().isIncludeExtendedDataTableNames()) { ImmutableSet<String> extendedDataTableNames = element.getExtendedDataTableNames(); if (extendedDataTableNames != null && !extendedDataTableNames.isEmpty()) { extendedDataTableNames.forEach(tableName -> alterExtendedDataElementTypeVisibility( graph, elementMutation, element.getExtendedData(tableName), elementMutation.getOldElementVisibility(), elementMutation.getNewElementVisibility() )); } } if (getConfig().isAutoFlush()) { flush(graph); } }</code><technical_language>wait in BulkUpdateService batch is converted a request</technical_language>

Target:
public <TElement extends Element> void updateElement( Graph graph, ExistingElementMutation<TElement> elementMutation, Authorizations authorizations ) { TElement element = elementMutation.getElement(); if (MUTATION_LOGGER.isTraceEnabled()) { MUTATION_LOGGER.trace("updateElement: %s", elementMutation.getId()); } if (!getConfig().isIndexEdges() && elementMutation.getElementType() == ElementType.EDGE) { return; } addMutationPropertiesToIndex(graph, elementMutation); addUpdateForMutationToBulk(graph, elementMutation); if (elementMutation.getNewElementVisibility() != null && element.getFetchHints().isIncludeExtendedDataTableNames()) { ImmutableSet<String> extendedDataTableNames = element.getExtendedDataTableNames(); if (extendedDataTableNames != null && !extendedDataTableNames.isEmpty()) { extendedDataTableNames.forEach(tableName -> alterExtendedDataElementTypeVisibility( graph, elementMutation, element.getExtendedData(tableName), elementMutation.getOldElementVisibility(), elementMutation.getNewElementVisibility() )); } } if (getConfig().isAutoFlush()) { flush(graph); } }
Source:
<code>void removeServerSegment(final DruidServerMetadata server, final DataSegment segment) { synchronized (lock) { log.debug("Segment[%s] is gone from server[%s]", segment.getId(), server.getName()); final Map<SegmentId, AvailableSegmentMetadata> knownSegments = segmentMetadataInfo.get(segment.getDataSource()); final AvailableSegmentMetadata segmentMetadata = knownSegments.get(segment.getId()); final Set<DruidServerMetadata> segmentServers = segmentMetadata.getReplicas(); final ImmutableSet<DruidServerMetadata> servers = FluentIterable.from(segmentServers) .filter(Predicates.not(Predicates.equalTo(server))) .toSet(); final DruidServerMetadata realtimeServer = servers.stream() .filter(metadata -> metadata.getType().equals(ServerType.REALTIME)) .findAny() <START> .orElse(null); <END> long isRealtime = realtimeServer == null ? 0 : 1; final AvailableSegmentMetadata metadataWithNumReplicas = AvailableSegmentMetadata .from(segmentMetadata) .withReplicas(servers) .withRealtime(isRealtime) .build(); knownSegments.put(segment.getId(), metadataWithNumReplicas); lock.notifyAll(); } }</code><technical_language>findAny() returns Optional, Optional.isPresent() instead of orElse() convert null. Another option is anyMatch() instead of findAny()</technical_language>

Target:
void removeServerSegment(final DruidServerMetadata server, final DataSegment segment) { synchronized (lock) { log.debug("Segment[%s] is gone from server[%s]", segment.getId(), server.getName()); final Map<SegmentId, AvailableSegmentMetadata> knownSegments = segmentMetadataInfo.get(segment.getDataSource()); final AvailableSegmentMetadata segmentMetadata = knownSegments.get(segment.getId()); final Set<DruidServerMetadata> segmentServers = segmentMetadata.getReplicas(); final ImmutableSet<DruidServerMetadata> servers = FluentIterable .from(segmentServers) .filter(Predicates.not(Predicates.equalTo(server))) .toSet(); final AvailableSegmentMetadata metadataWithNumReplicas = AvailableSegmentMetadata .from(segmentMetadata) .withReplicas(servers) .withRealtime(recomputeIsRealtime(servers)) .build(); knownSegments.put(segment.getId(), metadataWithNumReplicas); lock.notifyAll(); } }
Source:
<code>public PlanNodeStatsEstimate( @JsonProperty("outputRowCount") double outputRowCount, @JsonProperty("symbolStatistics") Map<Symbol, SymbolStatsEstimate> symbolStatistics) { checkArgument(isNaN(outputRowCount) || outputRowCount >= 0, "outputRowCount cannot be negative"); this.outputRowCount = outputRowCount; <START> this.symbolStatistics = HashTreePMap.from(symbolStatistics); <END> }</code><technical_language>this.symbolStatistics = HashTreePMap.from(requireNonNull(symbolStatistics, "symbolStatistics is null"));</technical_language>

Target:
public PlanNodeStatsEstimate( @JsonProperty("outputRowCount") double outputRowCount, @JsonProperty("symbolStatistics") Map<Symbol, SymbolStatsEstimate> symbolStatistics) { this(outputRowCount, HashTreePMap.from(requireNonNull(symbolStatistics, "symbolStatistics is null"))); }
Source:
<code>private ServiceInfo getACS(Predicate<ServiceInfo> predicate) { return assertionConsumerServices .values() .stream() .filter(predicate) .filter(serviceInfo -> supportedBindings.contains(serviceInfo.getBinding())) .filter( serviceInfo -> <START> CollectionUtils.intersection(IDP_SUPPORTED_BINDINGS, SSO_RESPONSE_BINDINGS) <END> .contains(serviceInfo.getBinding())) .findFirst() .orElse(null); }</code><technical_language>changed mind. This is efficient - create a new collection for one-time - calling subsequent filters</technical_language>

Target:
private ServiceInfo getACS(Predicate<ServiceInfo> predicate) { return assertionConsumerServices .values() .stream() .filter(predicate) .filter(serviceInfo -> supportedBindings.contains(serviceInfo.getBinding())) .filter(serviceInfo -> IDP_SUPPORTED_BINDINGS.contains(serviceInfo.getBinding())) .filter(serviceInfo -> SSO_RESPONSE_BINDINGS.contains(serviceInfo.getBinding())) .findFirst() .orElse(null); }
Source:
<code>public Object doWork() { final AllelicCountCollection counts = new AllelicCountCollection(snpCountsFile); final List<ACNVModeledSegment> segments = SegmentUtils.readACNVModeledSegmentFile(segmentsFile); final AlleleFractionState state = reconstructState(segments, parametersFile); <START> final AllelicPanelOfNormals allelicPON = <END> allelicPONFile != null ? AllelicPanelOfNormals.read(allelicPONFile) : AllelicPanelOfNormals.EMPTY_PON; final List<SimpleInterval> unmodeledSegments = segments.stream().map(ACNVModeledSegment::getInterval).collect(Collectors.toList()); final AllelicCountWithPhasePosteriorsCollection countsWithPhasePosteriors = calculatePhasePosteriors(counts, unmodeledSegments, state, allelicPON); countsWithPhasePosteriors.write(outputFile, counts.getVerbosity()); return "SUCCESS"; }</code><technical_language>allelicPON -> allelicPoN</technical_language>

Target:
public Object doWork() { if (!new HDF5Library().load(null)) { throw new UserException.HardwareFeatureException("Cannot load the required HDF5 library. " + "HDF5 is currently supported on x86-64 architecture and Linux or OSX systems."); } final AllelicCountCollection counts = new AllelicCountCollection(snpCountsFile); final List<ACNVModeledSegment> segments = SegmentUtils.readACNVModeledSegmentFile(segmentsFile); final AlleleFractionState state = reconstructState(segments, parametersFile); final AllelicPanelOfNormals allelicPoN = allelicPoNFile != null ? AllelicPanelOfNormals.read(allelicPoNFile) : AllelicPanelOfNormals.EMPTY_PON; final List<SimpleInterval> unmodeledSegments = segments.stream().map(ACNVModeledSegment::getInterval).collect(Collectors.toList()); final AllelicCountWithPhasePosteriorsCollection countsWithPhasePosteriors = calculatePhasePosteriors(counts, unmodeledSegments, state, allelicPoN); countsWithPhasePosteriors.write(outputFile, counts.getVerbosity()); return "SUCCESS"; }
Source:
<code>public void close() throws IOException { <START> this.closed = true; <END> for (final EJBClientContextListener listener : this.ejbClientContextListeners) { try { listener.contextClosed(this); } catch (Throwable t) { logger.debug("Ignoring the exception thrown by an EJB client context listener while closing the context " + this, t); } } this.reconnectionExecutorService.shutdownNow(); }</code><technical_language>I if this atomic operation</technical_language>

Target:
public synchronized void close() throws IOException { if (closed) { return; } this.closed = true; for (final EJBClientContextListener listener : this.ejbClientContextListeners) { try { listener.contextClosed(this); } catch (Throwable t) { logger.debug("Ignoring the exception thrown by an EJB client context listener while closing the context " + this, t); } } this.reconnectionExecutorService.shutdownNow(); }
Source:
<code><START> public void updateProviderDatasetRepresentation(String globalId, String schema, String version, Revision revision) <END> throws RepresentationNotExistsException { if(!revision.isPublished()){ return; } Representation rep = recordDAO.getRepresentation(globalId, schema, version); if (rep == null) { throw new RepresentationNotExistsException(schema); } Collection<CompoundDataSetId> dataSets = dataSetDAO.getDataSetAssignments(globalId, schema, version); for (CompoundDataSetId dsID : dataSets) { dataSetDAO.insertProviderDatasetRepresentationInfo(dsID.getDataSetId(), dsID.getDataSetProviderId(), globalId, version, schema, RevisionUtils.getRevisionKey(revision), revision.getCreationTimeStamp(), revision.isAcceptance(), revision.isPublished(), revision.isDeleted()); } }</code><technical_language>inserting provider_dataset_representation. This insertion allowed if revision is published .Right</technical_language>

Target:
public void updateProviderDatasetRepresentation(String globalId, String schema, String version, Revision revision) throws RepresentationNotExistsException { Representation rep = recordDAO.getRepresentation(globalId, schema, version); if (rep == null) { throw new RepresentationNotExistsException(schema); } Collection<CompoundDataSetId> dataSets = dataSetDAO.getDataSetAssignments(globalId, schema, version); for (CompoundDataSetId dsID : dataSets) { dataSetDAO.insertProviderDatasetRepresentationInfo(dsID.getDataSetId(), dsID.getDataSetProviderId(), globalId, version, schema, RevisionUtils.getRevisionKey(revision), revision.getCreationTimeStamp(), revision.isAcceptance(), revision.isPublished(), revision.isDeleted()); } }
Source:
<code>private Message createManagementMessage(String operation, String associatedLinkName) { final Duration serverTimeout = MessageUtils.adjustServerTimeout(operationTimeout); final Map<String, Object> applicationProperties = new HashMap<>(); applicationProperties.put(ManagementConstants.MANAGEMENT_OPERATION_KEY, operation); applicationProperties.put(ManagementConstants.SERVER_TIMEOUT, serverTimeout.toMillis()); <START> if (associatedLinkName != null && !associatedLinkName.isEmpty()) { <END> applicationProperties.put(ManagementConstants.ASSOCIATED_LINK_NAME_KEY, associatedLinkName); } final Message message = Proton.message(); message.setApplicationProperties(new ApplicationProperties(applicationProperties)); return message; }</code><technical_language>CoreUtils.isNullOrEmpty(associatedLinkName)</technical_language>

Target:
private Message createManagementMessage(String operation, String associatedLinkName) { final Duration serverTimeout = MessageUtils.adjustServerTimeout(operationTimeout); final Map<String, Object> applicationProperties = new HashMap<>(); applicationProperties.put(ManagementConstants.MANAGEMENT_OPERATION_KEY, operation); applicationProperties.put(ManagementConstants.SERVER_TIMEOUT, serverTimeout.toMillis()); if (!CoreUtils.isNullOrEmpty(associatedLinkName)) { applicationProperties.put(ManagementConstants.ASSOCIATED_LINK_NAME_KEY, associatedLinkName); } final Message message = Proton.message(); message.setApplicationProperties(new ApplicationProperties(applicationProperties)); return message; }
Source:
<code>protected void postInitTemplate(List<VmTemplate> templates) { boolean isSelectedTemplateBase = selectedTemplate.isBaseTemplate(); VmTemplate baseTemplate = null; List<VmTemplate> relatedTemplates = new ArrayList<>(); for (VmTemplate template : templates) { <START> if (template.getName().equals(selectedTemplate.getName())) { <END> relatedTemplates.add(template); if (!isSelectedTemplateBase) { if (selectedTemplate.getBaseTemplateId().equals(template.getId())) { baseTemplate = template; } } } } initTemplateWithVersion(relatedTemplates); TemplateWithVersion templateCouple; if (selectedTemplate.isBaseTemplate()) { templateCouple = new TemplateWithVersion(selectedTemplate, selectedTemplate); } else { templateCouple = new TemplateWithVersion(baseTemplate, selectedTemplate); } getModel().getTemplateWithVersion().setSelectedItem(templateCouple); updateIsDisksAvailable(); }</code><technical_language>this a bit dangerous... please try rewrite check IDs</technical_language>

Target:
protected void postInitTemplate(List<VmTemplate> templates) { DataCenterWithCluster selectedDCWithCluster = getModel().getDataCenterWithClustersList().getSelectedItem(); Guid clusterId = selectedDCWithCluster != null ? selectedDCWithCluster.getCluster().getId() : selectedTemplate.getVdsGroupId(); VmTemplate baseTemplate = null; if (selectedTemplate.isBaseTemplate()) { baseTemplate = selectedTemplate; } Guid baseTemplateId = selectedTemplate.getBaseTemplateId(); List<VmTemplate> relatedTemplates = new ArrayList<>(); for (VmTemplate template : templates) { if (template.getBaseTemplateId().equals(baseTemplateId)) { if (template.getVdsGroupId().equals(clusterId)) { relatedTemplates.add(template); } if (baseTemplate == null) { if (template.getId().equals(baseTemplateId)) { baseTemplate = template; } } } } if(!relatedTemplates.contains(baseTemplate)) { relatedTemplates.add(baseTemplate); } initTemplateWithVersion(relatedTemplates); if(selectedTemplate.getVdsGroupId().equals(selectedDCWithCluster.getCluster().getId())) { TemplateWithVersion templateCouple = new TemplateWithVersion(baseTemplate, selectedTemplate); getModel().getTemplateWithVersion().setSelectedItem(templateCouple); } updateIsDisksAvailable(); }