auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public void addRequestable( IAEFluidStack option ) { if( this.isStackNull( option ) ) { return; } final IAEFluidStack st = this.getFluidRecord( option ); if( st != null ) { st.setCountRequestable( st.getCountRequestable() + option.getCountRequestable() ); return; } final IAEFluidStack opt = option.copy(); opt.setStackSize( 0 ); opt.setCraftable( false ); <START> opt.setCountRequestable( opt.getCountRequestable() ); <END> this.putFluidRecord( opt ); }</code><technical_language>opt.getCountRequestable() option.getCountRequestable() same? if yes, outsource variable if</technical_language>

Target:
public void addRequestable( IAEFluidStack option ) { if( option == null ) { return; } final IAEFluidStack st = this.getFluidRecord( option ); if( st != null ) { st.setCountRequestable( st.getCountRequestable() + option.getCountRequestable() ); return; } final IAEFluidStack opt = option.copy(); opt.setStackSize( 0 ); opt.setCraftable( false ); opt.setCountRequestable( option.getCountRequestable() ); this.putFluidRecord( opt ); }
Source:
<code>public static void addProfileDataToNic(Map<String, Object> struct, VM vm, VmDevice vmDevice, VmNic nic) { VnicProfile vnicProfile = null; Network network = null; String networkName = ""; List<VNIC_PROFILE_PROPERTIES> unsupportedFeatures = new ArrayList<>(); if (nic.getVnicProfileId() != null) { vnicProfile = DbFacade.getInstance().getVnicProfileDao().get(nic.getVnicProfileId()); if (vnicProfile != null) { network = DbFacade.getInstance().getNetworkDao().get(vnicProfile.getNetworkId()); networkName = network.getName(); log.debugFormat("VNIC {0} is using profile {1} on network {2}", nic.getName(), vnicProfile, networkName); if (!addQosForDevice(struct, vnicProfile, vm.getVdsGroupCompatibilityVersion())) { unsupportedFeatures.add(VNIC_PROFILE_PROPERTIES.NETWORK_QOS); } } } struct.put(VdsProperties.NETWORK, networkName); if (!addPortMirroringToVmInterface(struct, vnicProfile, vm.getVdsGroupCompatibilityVersion(), <START> network == null ? Collections.<String> emptyList() : Collections.singletonList(networkName))) { <END> unsupportedFeatures.add(VNIC_PROFILE_PROPERTIES.PORT_MIRRORING); } if (!addCustomPropertiesForDevice(struct, vm, vmDevice, vm.getVdsGroupCompatibilityVersion(), getVnicCustomProperties(vnicProfile))) { unsupportedFeatures.add(VNIC_PROFILE_PROPERTIES.CUSTOM_PROPERTIES); } if (!unsupportedFeatures.isEmpty()) { reportUnsupportedVnicProfileFeatures(vm, nic, vnicProfile, unsupportedFeatures); } }</code><technical_language>This logic addPortMirroringToVmInterface</technical_language>

Target:
public static void addProfileDataToNic(Map<String, Object> struct, VM vm, VmDevice vmDevice, VmNic nic) { VnicProfile vnicProfile = null; Network network = null; String networkName = ""; List<VNIC_PROFILE_PROPERTIES> unsupportedFeatures = new ArrayList<>(); if (nic.getVnicProfileId() != null) { vnicProfile = DbFacade.getInstance().getVnicProfileDao().get(nic.getVnicProfileId()); if (vnicProfile != null) { network = DbFacade.getInstance().getNetworkDao().get(vnicProfile.getNetworkId()); networkName = network.getName(); log.debugFormat("VNIC {0} is using profile {1} on network {2}", nic.getName(), vnicProfile, networkName); if (!addQosForDevice(struct, vnicProfile, vm.getVdsGroupCompatibilityVersion())) { unsupportedFeatures.add(VNIC_PROFILE_PROPERTIES.NETWORK_QOS); } } } struct.put(VdsProperties.NETWORK, networkName); if (!addPortMirroringToVmInterface(struct, vnicProfile, vm.getVdsGroupCompatibilityVersion(), network)) { unsupportedFeatures.add(VNIC_PROFILE_PROPERTIES.PORT_MIRRORING); } if (!addCustomPropertiesForDevice(struct, vm, vmDevice, vm.getVdsGroupCompatibilityVersion(), getVnicCustomProperties(vnicProfile))) { unsupportedFeatures.add(VNIC_PROFILE_PROPERTIES.CUSTOM_PROPERTIES); } if (!unsupportedFeatures.isEmpty()) { reportUnsupportedVnicProfileFeatures(vm, nic, vnicProfile, unsupportedFeatures); } }
Source:
<code>private void handleWifiP2pAction(Intent intent) { if (mConfig.isWifiP2pLegacyTetheringMode()) return; final WifiP2pInfo p2pInfo = (WifiP2pInfo) intent.getParcelableExtra(WifiP2pManager.EXTRA_WIFI_P2P_INFO); final WifiP2pGroup group = (WifiP2pGroup) intent.getParcelableExtra(WifiP2pManager.EXTRA_WIFI_P2P_GROUP); if (VDBG) { Log.d(TAG, "WifiP2pAction: P2pInfo: " + p2pInfo + " Group: " + group); } synchronized (Tethering.this.mPublicSync) { if (p2pInfo != null && group != null && group.isGroupOwner() && !TextUtils.isEmpty(group.getInterface())) { if (!TextUtils.isEmpty(mWifiP2pTetherInterface)) { if (mWifiP2pTetherInterface.equals(group.getInterface())) { return; } else { <START> Log.w(TAG, <END> "P2P tethered interface " + mWifiP2pTetherInterface + "is different from current interface " + group.getInterface() + ", re-tether it"); disableWifiP2pIpServingLocked(mWifiP2pTetherInterface); } } mWifiP2pTetherInterface = group.getInterface(); enableWifiIpServingLocked(mWifiP2pTetherInterface, IFACE_IP_MODE_LOCAL_ONLY); } else if (group == null && !TextUtils.isEmpty(mWifiP2pTetherInterface)) { disableWifiP2pIpServingLocked(mWifiP2pTetherInterface); mWifiP2pTetherInterface = null; } } }</code><technical_language>change mLog.w(both log in dumpsys system log) mLog.log(only dumpsys) ?</technical_language>

Target:
private void handleWifiP2pAction(Intent intent) { if (mConfig.isWifiP2pLegacyTetheringMode()) return; final WifiP2pInfo p2pInfo = (WifiP2pInfo) intent.getParcelableExtra(WifiP2pManager.EXTRA_WIFI_P2P_INFO); final WifiP2pGroup group = (WifiP2pGroup) intent.getParcelableExtra(WifiP2pManager.EXTRA_WIFI_P2P_GROUP); if (VDBG) { Log.d(TAG, "WifiP2pAction: P2pInfo: " + p2pInfo + " Group: " + group); } synchronized (Tethering.this.mPublicSync) { if (p2pInfo != null && group != null && group.isGroupOwner() && !TextUtils.isEmpty(group.getInterface())) { if (!TextUtils.isEmpty(mWifiP2pTetherInterface)) { if (mWifiP2pTetherInterface.equals(group.getInterface())) { return; } else { mLog.w("P2P tethered interface " + mWifiP2pTetherInterface + "is different from current interface " + group.getInterface() + ", re-tether it"); disableWifiP2pIpServingLocked(mWifiP2pTetherInterface); } } mWifiP2pTetherInterface = group.getInterface(); enableWifiIpServingLocked(mWifiP2pTetherInterface, IFACE_IP_MODE_LOCAL_ONLY); } else if (group == null && !TextUtils.isEmpty(mWifiP2pTetherInterface)) { disableWifiP2pIpServingLocked(mWifiP2pTetherInterface); mWifiP2pTetherInterface = null; } } }
Source:
<code>private void handleCreateAccountResult(CompatCreateAccountResult result) { boolean authManagerEnabled = result.isAuthManagerResult(); if (result.getAuthManagerCreateAccountResult() instanceof AMCreateAccountSuccessResult || result.getLegacyCreateAccountResult() instanceof CreateAccountSuccessResult) { return; } assertThat(result, authManagerEnabled ? instanceOf(AMCreateAccountCaptchaResult.class) : instanceOf(CreateAccountCaptchaResult.class)); CaptchaResult captchaResult = authManagerEnabled <START> ? ((AMCreateAccountCaptchaResult) result.getAuthManagerCreateAccountResult()).getCaptchaResult() <END> : ((CreateAccountCaptchaResult) result.getLegacyCreateAccountResult()).getCaptchaResult(); assertThat(captchaResult, notNullValue()); assertThat(captchaResult.getCaptchaId(), not(isEmptyOrNullString())); String expectedCaptchaUrlPrefix = WikipediaApp.getInstance().getSite().scheme() + "://test.wikipedia.org/w/index.php?title=Special:Captcha/image"; assertThat(captchaResult.getCaptchaUrl(TEST_WIKI), startsWith(expectedCaptchaUrlPrefix)); }</code><technical_language>This failing compilation</technical_language>

Target:
private void handleCreateAccountResult(CompatCreateAccountResult result) { if (result instanceof AMCreateAccountSuccessResult || result instanceof CreateAccountSuccessResult) { return; } assertThat(result, instanceOf(CreateAccountCaptchaResult.class)); CaptchaResult captchaResult = ((CreateAccountCaptchaResult) result).getCaptchaResult(); assertThat(captchaResult, notNullValue()); assertThat(captchaResult.getCaptchaId(), not(isEmptyOrNullString())); String expectedCaptchaUrlPrefix = WikipediaApp.getInstance().getSite().scheme() + "://test.wikipedia.org/w/index.php?title=Special:Captcha/image"; assertThat(captchaResult.getCaptchaUrl(TEST_WIKI), startsWith(expectedCaptchaUrlPrefix)); }
Source:
<code>void receiveHeader(PacketLineIn pckIn, boolean stateless) throws IOException { try { version = parseHeader(pckIn, VERSION); if (!version.equals(VERSION_0_1)) { throw new IOException(MessageFormat.format( JGitText.get().pushCertificateInvalidFieldValue, <START> VERSION, version)); <END> } String pusherStr = parseHeader(pckIn, PUSHER); pusher = RawParseUtils.parsePersonIdent(pusherStr); if (pusher == null) { throw new IOException(MessageFormat.format( JGitText.get().pushCertificateInvalidFieldValue, PUSHER, pusherStr)); } pushee = parseHeader(pckIn, PUSHEE); receivedNonce = parseHeader(pckIn, NONCE); if (!pckIn.readString().isEmpty()) { throw new IOException( JGitText.get().pushCertificateInvalidHeader); } } catch (EOFException eof) { throw new IOException( JGitText.get().pushCertificateInvalidHeader, eof); } nonceStatus = nonceGenerator.verify(receivedNonce, sentNonce(), db, stateless, nonceSlopLimit); }</code><technical_language>line length</technical_language>

Target:
public void receiveHeader(PacketLineIn pckIn, boolean stateless) throws IOException { try { version = parseHeader(pckIn, VERSION); if (!version.equals(VERSION_0_1)) { throw new IOException(MessageFormat.format( JGitText.get().pushCertificateInvalidFieldValue, VERSION, version)); } String pusherStr = parseHeader(pckIn, PUSHER); pusher = RawParseUtils.parsePersonIdent(pusherStr); if (pusher == null) { throw new IOException(MessageFormat.format( JGitText.get().pushCertificateInvalidFieldValue, PUSHER, pusherStr)); } pushee = parseHeader(pckIn, PUSHEE); receivedNonce = parseHeader(pckIn, NONCE); if (!pckIn.readString().isEmpty()) { throw new IOException( JGitText.get().pushCertificateInvalidHeader); } } catch (EOFException eof) { throw new IOException( JGitText.get().pushCertificateInvalidHeader, eof); } nonceStatus = nonceGenerator != null ? nonceGenerator.verify( receivedNonce, sentNonce(), db, stateless, nonceSlopLimit) : NonceStatus.UNSOLICITED; }
Source:
<code>public void start() { if (!lifecycleLock.canStart()) { throw new ISE("can't start."); } try { notifierThread = Execs.makeThread( "CoordinatorBasicAuthenticatorCacheNotifier-notifierThread", () -> { while (!Thread.interrupted()) { try { LOG.debug("Waiting for cache update notification"); Set<String> authenticatorsToUpdateSnapshot; HashMap<String, byte[]> serializedUserMapsSnapshot; synchronized (authenticatorsToUpdate) { if (authenticatorsToUpdate.isEmpty()) { authenticatorsToUpdate.wait(); } authenticatorsToUpdateSnapshot = new HashSet<>(authenticatorsToUpdate); serializedUserMapsSnapshot = new HashMap<String, byte[]>(serializedMaps); authenticatorsToUpdate.clear(); serializedMaps.clear(); } LOG.debug("Sending cache update notifications"); for (String authenticator : authenticatorsToUpdateSnapshot) { BasicAuthDBConfig authenticatorConfig = authenticatorConfigMap.get(authenticator); if (!authenticatorConfig.isEnableCacheNotifications()) { continue; } List<ListenableFuture<StatusResponseHolder>> futures = sendUpdate( authenticator, serializedUserMapsSnapshot.get(authenticator) ); for (ListenableFuture<StatusResponseHolder> future : futures) { try { StatusResponseHolder srh = future.get( authenticatorConfig.getCacheNotificationTimeout(), TimeUnit.MILLISECONDS ); LOG.debug("Got status: " + srh.getStatus()); } catch (Exception e) { <START> LOG.makeAlert("Failed to get response for cache notification.").emit(); <END> } } } LOG.debug("Received responses for cache update notifications."); } catch (Throwable t) { LOG.makeAlert(t, "Error occured while handling updates for cachedUserMaps.").emit(); } } }, true ); notifierThread.start(); lifecycleLock.started(); } finally { lifecycleLock.exitStart(); } }</code><technical_language>e included in alert</technical_language>

Target:
public void start() { if (!lifecycleLock.canStart()) { throw new ISE("can't start."); } try { cacheNotifier.start(); lifecycleLock.started(); } finally { lifecycleLock.exitStart(); } }
Source:
<code>public void close() { final FSDataInputStream inLocal = in; if (inLocal != null) { synchronized (inLocal) { <START> in = null; <END> } } }</code><technical_language>code sets in null close called. This code sync in a rigmarole. I simplify code if a boolean tracks closed state introduced in set null. code safely sync in check closed boolean syncing</technical_language>

Target:
public void close() { if (!closed) { synchronized (in) { closed = true; } } }
Source:
<code>public static List<JiraSite> getSitesFromFolders(ItemGroup itemGroup) { List<JiraSite> result = new ArrayList<>(); while (itemGroup != null) { if (itemGroup instanceof AbstractFolder<?>) { AbstractFolder<?> folder = (AbstractFolder<?>) itemGroup; JiraFolderProperty jiraFolderProperty = folder.getProperties() .get(JiraFolderProperty.class); if (jiraFolderProperty != null && jiraFolderProperty.getSites().length != 0) { result.addAll(Arrays.asList(jiraFolderProperty.getSites())); } itemGroup = folder.getParent(); } <START> if (!(itemGroup instanceof AbstractFolder<?>)) { <END> itemGroup = null; } } return result; }</code><technical_language>while instead of null checking</technical_language>

Target:
public static List<JiraSite> getSitesFromFolders(ItemGroup itemGroup) { List<JiraSite> result = new ArrayList<>(); while (itemGroup instanceof AbstractFolder<?>) { AbstractFolder<?> folder = (AbstractFolder<?>) itemGroup; JiraFolderProperty jiraFolderProperty = folder.getProperties() .get(JiraFolderProperty.class); if (jiraFolderProperty != null && jiraFolderProperty.getSites().length != 0) { result.addAll(Arrays.asList(jiraFolderProperty.getSites())); } itemGroup = folder.getParent(); } return result; }
Source:
<code>INode toFile(UGIResolver ugi, BlockResolver blk, BlockAliasMap.Writer<FileRegion> out) throws IOException { final FileStatus s = getFileStatus(); final AclStatus aclStatus = getAclStatus(); long permissions = ugi.getPermissionsProto(s, aclStatus); INodeFile.Builder b = INodeFile.newBuilder() .setReplication(blk.getReplication(s)) .setModificationTime(s.getModificationTime()) .setAccessTime(s.getAccessTime()) .setPreferredBlockSize(blk.preferredBlockSize(s)) .setPermission(permissions) .setStoragePolicyID(HdfsConstants.PROVIDED_STORAGE_POLICY_ID); PathHandle pathHandle = null; if (fs != null) { try { pathHandle = fs.getPathHandle(s, Options.HandleOpt.exact()); } catch (UnsupportedOperationException e) { LOG.warn( "Exact path handle not supported by filesystem " + fs.toString()); } } if (aclStatus != null) { <START> throw new UnsupportedOperationException( <END> "Acls not supported by ImageWriter"); } long off = 0L; for (BlockProto block : blk.resolve(s)) { b.addBlocks(block); writeBlock(block.getBlockId(), off, block.getNumBytes(), block.getGenStamp(), pathHandle, out); off += block.getNumBytes(); } INode.Builder ib = INode.newBuilder() .setType(INode.Type.FILE) .setId(id) .setName(ByteString.copyFrom(string2Bytes(s.getPath().getName()))) .setFile(b); return ib.build(); }</code><technical_language>line</technical_language>

Target:
INode toFile(UGIResolver ugi, BlockResolver blk, BlockAliasMap.Writer<FileRegion> out) throws IOException { final FileStatus s = getFileStatus(); final AclStatus aclStatus = getAclStatus(); long permissions = ugi.getPermissionsProto(s, aclStatus); INodeFile.Builder b = INodeFile.newBuilder() .setReplication(blk.getReplication(s)) .setModificationTime(s.getModificationTime()) .setAccessTime(s.getAccessTime()) .setPreferredBlockSize(blk.preferredBlockSize(s)) .setPermission(permissions) .setStoragePolicyID(HdfsConstants.PROVIDED_STORAGE_POLICY_ID); PathHandle pathHandle = null; if (fs != null) { try { pathHandle = fs.getPathHandle(s, Options.HandleOpt.exact()); } catch (UnsupportedOperationException e) { LOG.warn( "Exact path handle not supported by filesystem " + fs.toString()); } } if (aclStatus != null) { throw new UnsupportedOperationException( "ACLs not supported by ImageWriter"); } long off = 0L; for (BlockProto block : blk.resolve(s)) { b.addBlocks(block); writeBlock(block.getBlockId(), off, block.getNumBytes(), block.getGenStamp(), pathHandle, out); off += block.getNumBytes(); } INode.Builder ib = INode.newBuilder() .setType(INode.Type.FILE) .setId(id) .setName(ByteString.copyFrom(string2Bytes(s.getPath().getName()))) .setFile(b); return ib.build(); }
Source:
<code>private String normalize(String input) { <START> return pattern.matcher(input).replaceAll("-"); <END> }</code><technical_language>I this logic is that: - hyphen char - hyphen char cases forbidden in hostnames</technical_language>

Target:
private String normalize(String input) { String normalized = pattern.matcher(input).replaceAll("-"); while (normalized.startsWith("-")) { normalized = normalized.substring(1); } while (normalized.endsWith("-")) { normalized = normalized.substring(0, normalized.length() - 1); } return normalized; }
Source:
<code>public byte[] getCacheKey() { byte[] dimensionBytes = StringUtils.toUtf8(dimension); final byte[][] intervalsBytes = new byte[intervals.size()][]; int intervalsBytesSize = 0; int index = 0; <START> for (Interval interval : intervals) { <END> intervalsBytes[index] = StringUtils.toUtf8(interval.toString()); intervalsBytesSize += intervalsBytes[index].length + 1; ++index; } byte[] extractionFnBytes = extractionFn == null ? new byte[0] : extractionFn.getCacheKey(); ByteBuffer filterCacheKey = ByteBuffer.allocate(3 + dimensionBytes.length + intervalsBytesSize + extractionFnBytes.length) .put(DimFilterUtils.INTERVAL_CACHE_ID) .put(dimensionBytes) .put(DimFilterUtils.STRING_SEPARATOR) .put(extractionFnBytes) .put(DimFilterUtils.STRING_SEPARATOR); for (byte[] bytes : intervalsBytes) { filterCacheKey.put(bytes) .put((byte) 0xFF); } return filterCacheKey.array(); }</code><technical_language>intervals stored start/end millis pairs, simplify cache key generation</technical_language>

Target:
public byte[] getCacheKey() { byte[] dimensionBytes = StringUtils.toUtf8(dimension); byte[] extractionFnBytes = extractionFn == null ? new byte[0] : extractionFn.getCacheKey(); int intervalsBytesSize = intervalLongs.size() * Longs.BYTES * 2 + intervalLongs.size(); ByteBuffer filterCacheKey = ByteBuffer.allocate(3 + dimensionBytes.length + intervalsBytesSize + extractionFnBytes.length) .put(DimFilterUtils.INTERVAL_CACHE_ID) .put(dimensionBytes) .put(DimFilterUtils.STRING_SEPARATOR) .put(extractionFnBytes) .put(DimFilterUtils.STRING_SEPARATOR); for (Pair<Long, Long> interval : intervalLongs) { filterCacheKey.put(Longs.toByteArray(interval.lhs)) .put(Longs.toByteArray(interval.rhs)) .put((byte) 0xFF); } return filterCacheKey.array(); }
Source:
<code>public String getShortName() { <START> return "projectactivity"; <END> }</code><technical_language>"activity" enough</technical_language>

Target:
public String getShortName() { return "activity"; }
Source:
<code>public ConcurrentDocumentClient(ISarosSession sarosSession) { this.sarosSession = sarosSession; this.jupiterClient = new JupiterClient(sarosSession); <START> this.deletedResources = new CopyOnWriteArraySet<>(); <END> }</code><technical_language>This is single threaded, Client Server accessed a dedicated thread (yes I reset stuff correctly)</technical_language>

Target:
public ConcurrentDocumentClient(ISarosSession sarosSession) { this.sarosSession = sarosSession; this.jupiterClient = new JupiterClient(sarosSession); this.resourceActivityFilter = new ResourceActivityFilter(sarosSession, this::reset); }
Source:
<code>public void emit(T tuple) { if (operatorThread != null && Thread.currentThread() != operatorThread) { <START> throw new IllegalStateException("emit() not called from operator thread!, currentThread=" + <END> Thread.currentThread() + ", operatorThread=" + operatorThread); } sink.put(tuple); }</code><technical_language>throw new IllegalStateException("Current thread " + Thread.currentThread().getName() + " is operator thread " + operatorThread.getName());</technical_language>

Target:
public void emit(T tuple) { if (operatorThread != null && Thread.currentThread() != operatorThread) { throw new IllegalStateException("Current thread " + Thread.currentThread().getName() + " is different from the operator thread " + operatorThread.getName()); } sink.put(tuple); }
Source:
<code>public Object compute(Map<String, Object> values) { Iterator<PostAggregator> fieldsIter = fields.iterator(); <START> Double retVal = NullHandling.useDefaultValuesForNull() ? DimensionHandlerUtils.ZERO_DOUBLE : null; <END> if (fieldsIter.hasNext()) { Number nextVal = (Number) fieldsIter.next().compute(values); if (nextVal == null) { return null; } retVal = nextVal.doubleValue(); while (fieldsIter.hasNext()) { nextVal = (Number) fieldsIter.next().compute(values); if (nextVal == null) { return null; } retVal = op.compute(retVal, (nextVal).doubleValue()); } } return retVal; }</code><technical_language>NullHandling.defaultDoubleValue()</technical_language>

Target:
public Object compute(Map<String, Object> values) { Iterator<PostAggregator> fieldsIter = fields.iterator(); Double retVal = NullHandling.defaultDoubleValue(); if (fieldsIter.hasNext()) { Number nextVal = (Number) fieldsIter.next().compute(values); if (nextVal == null) { return null; } retVal = nextVal.doubleValue(); while (fieldsIter.hasNext()) { nextVal = (Number) fieldsIter.next().compute(values); if (nextVal == null) { return null; } retVal = op.compute(retVal, (nextVal).doubleValue()); } } return retVal; }
Source:
<code>public ParametersList(MethodTree methodTree) { parameterNames = new ArrayList<>(); parameterTypes = new ArrayList<>(); List<Symbol> symbolListOfParameters = methodTree.parameters().stream().map(VariableTree::symbol).collect(Collectors.toList()); <START> parameterNames.addAll(symbolListOfParameters.stream().map(parameter -> parameter.name().toLowerCase(Locale.ENGLISH)).collect(Collectors.toList())); <END> parameterTypes.addAll(symbolListOfParameters.stream().map(Symbol::type).collect(Collectors.toList())); }</code><technical_language>iterate lit of symbols collect everything: java methodTree.parameters().stream().map(VariableTree::symbol).forEach(symbol -> { parameterNames.add(symbol.name().toLowerCase(Locale.ENGLISH)); parameterTypes.add(symbol.type()) });</technical_language>

Target:
public ParametersList(MethodTree methodTree) { parameterNames = new ArrayList<>(); parameterTypes = new ArrayList<>(); methodTree.parameters().stream().map(VariableTree::symbol).forEach(symbol -> { parameterNames.add(symbol.name().toLowerCase(Locale.ENGLISH)); parameterTypes.add(symbol.type()); }); }
Source:
<code>public SubTabDiskGeneralView(DetailModelProvider<DiskListModel, DiskGeneralModel> modelProvider) { super(modelProvider); formPanel = new GeneralFormPanel(); initWidget(ViewUiBinder.uiBinder.createAndBindUi(this)); Driver.driver.initialize(this); formBuilder = new FormBuilder(formPanel, 1, 6); formBuilder.setColumnsWidth("300px"); formBuilder.addFormItem(new FormItem(constants.aliasDisk(), alias, 0, 0)); formBuilder.addFormItem(new FormItem(constants.descriptionDisk(), description, 1, 0)); formBuilder.addFormItem(new FormItem(constants.idDisk(), diskId, 2, 0)); formBuilder.addFormItem(new FormItem(constants.lunIdSanStorage(), lunId, 3, 0) { @Override public boolean isVisible() { return getDetailModel().isLun(); } }); <START> formBuilder.addFormItem(new FormItem(constants.diskAlignment(), alignment, 2, 0)); <END> formBuilder.addFormItem(new FormItem(constants.quota(), quotaName, 4, 0) { @Override public boolean isVisible() { return getDetailModel().isQuotaAvailable(); } }); }</code><technical_language>* this line 'lunIdSanStorage' item * 2 -> 3 (and 'lunIdSanStorage'/'quota' items modified accordingly...)</technical_language>

Target:
public SubTabDiskGeneralView(DetailModelProvider<DiskListModel, DiskGeneralModel> modelProvider) { super(modelProvider); formPanel = new GeneralFormPanel(); initWidget(ViewUiBinder.uiBinder.createAndBindUi(this)); driver.initialize(this); formBuilder = new FormBuilder(formPanel, 1, 6); formBuilder.addFormItem(new FormItem(constants.aliasDisk(), alias, 0, 0)); formBuilder.addFormItem(new FormItem(constants.descriptionDisk(), description, 1, 0)); formBuilder.addFormItem(new FormItem(constants.idDisk(), diskId, 2, 0)); formBuilder.addFormItem(new FormItem(constants.diskAlignment(), alignment, 3, 0)); formBuilder.addFormItem(new FormItem(constants.lunIdSanStorage(), lunId, 4, 0) { @Override public boolean getIsAvailable() { return getDetailModel().isLun(); } }); formBuilder.addFormItem(new FormItem(constants.quota(), quotaName, 5, 0) { @Override public boolean getIsAvailable() { return getDetailModel().isQuotaAvailable(); } }); }
Source:
<code>public static List<Point> getPointsFromTarget(ConnectionEditPart edgeEditPart) throws IllegalArgumentException { if (edgeEditPart.getModel() instanceof Edge && edgeEditPart.getFigure() instanceof Connection) { List<Point> result = Lists.newArrayList(); Edge gmfEdge = (Edge) edgeEditPart.getModel(); Connection connectionFigure = (Connection) edgeEditPart.getFigure(); Point tgtAnchorLoc = connectionFigure.getTargetAnchor().getReferencePoint(); connectionFigure.translateToRelative(tgtAnchorLoc); RelativeBendpoints bp = (RelativeBendpoints) gmfEdge.getBendpoints(); for (int i = 0; i < bp.getPoints().size(); i++) { RelativeBendpoint rbp = (RelativeBendpoint) bp.getPoints().get(i); <START> Point fromSrc = tgtAnchorLoc.getTranslated(rbp.getTargetX(), rbp.getTargetY()); <END> result.add(fromSrc); } return result; } throw new IllegalArgumentException( "The model of the edgeEditPart should be a org.eclipse.gmf.runtime.notation.Edge and the figure of this edgeEditPart should be a org.eclipse.draw2d.Connection."); }</code><technical_language>fromSrc => fromTgt</technical_language>

Target:
public static List<Point> getPointsFromTarget(ConnectionEditPart edgeEditPart) throws IllegalArgumentException { if (edgeEditPart.getModel() instanceof Edge && edgeEditPart.getFigure() instanceof Connection) { List<Point> result = Lists.newArrayList(); Edge gmfEdge = (Edge) edgeEditPart.getModel(); Connection connectionFigure = (Connection) edgeEditPart.getFigure(); Point tgtAnchorLoc = connectionFigure.getTargetAnchor().getReferencePoint(); connectionFigure.translateToRelative(tgtAnchorLoc); RelativeBendpoints bp = (RelativeBendpoints) gmfEdge.getBendpoints(); for (int i = 0; i < bp.getPoints().size(); i++) { RelativeBendpoint rbp = (RelativeBendpoint) bp.getPoints().get(i); Point fromTgt = tgtAnchorLoc.getTranslated(rbp.getTargetX(), rbp.getTargetY()); result.add(fromTgt); } return result; } throw new IllegalArgumentException( "The model of the edgeEditPart should be a org.eclipse.gmf.runtime.notation.Edge and the figure of this edgeEditPart should be a org.eclipse.draw2d.Connection."); }
Source:
<code>public MailMessage setTo(String to) { <START> this.to = Arrays.asList(to); <END> return this; }</code><technical_language>Arrays.asList create a fixed sized list, getTo().add(something) throw exception</technical_language>

Target:
public MailMessage setTo(String to) { this.to = asList(to); return this; }
Source:
<code>private Schema getSchema() { try { return Schema.parseJson(schema); } catch (IOException e) { throw new IllegalArgumentException( <START> String.format("Unable to parse schema '%s'. Reason: %s", schema, e.getMessage())); <END> } }</code><technical_language>instead of putting e.getMessage() part of new exception message, I pass entire e parameter constructor of IllegalArgumentException</technical_language>

Target:
private Schema getSchema() { try { return Schema.parseJson(schema); } catch (IOException e) { throw new IllegalArgumentException(String.format("Unable to parse schema '%s'. Reason: %s", schema, e.getMessage()), e); } }
Source:
<code>public void fetchEapAuthentications() throws Exception { <START> final List<AuthEntry> encodings = Lists.newArrayList(new AuthEntry(CREDENTIAL_TYPE, Type.EAP_SIM)); <END> final List<AuthenticationEntryDTO> list = Lists.newArrayList(new AuthenticationEntryDTO("CREDENTIAL_TYPE", Lists.newArrayList("EAP_SIM"))); context.checking(new Expectations() {{ oneOf(authenticationCatalog).findAll(); will(returnValue(encodings)); }}); Reply<?> reply = endpoint.fetchEapAuthentications(); assertThat(reply, contains(list)); assertThat(reply, isOk()); }</code><technical_language>encodings</technical_language>

Target:
public void fetchEapAuthentications() throws Exception { final List<AuthEntry> auths = Lists.newArrayList(new AuthEntry(CREDENTIAL_TYPE, Type.EAP_SIM)); final List<AuthEntryDTO> list = Lists.newArrayList(new AuthEntryDTO("CREDENTIAL_TYPE", Lists.newArrayList("EAP_SIM"))); context.checking(new Expectations() {{ oneOf(authenticationCatalog).findAll(); will(returnValue(auths)); }}); Reply<?> reply = endpoint.fetchEapAuthentications(); assertThat(reply, contains(list)); assertThat(reply, isOk()); }
Source:
<code>public void sendMessage(OutboundHandler.SendContext sendContext) { try { <START> channel.eventLoop().execute(() -> { <END> final BytesReference bytesReference; try { bytesReference = sendContext.get(); } catch (IOException e) { sendContext.onFailure(e); return; } channel.writeAndFlush(Netty4Utils.toByteBuf(bytesReference), addPromise(sendContext, channel)); }); } catch (RejectedExecutionException e) { sendContext.onFailure(new TransportException("Cannot send message, event loop is shutting down.")); } }</code><technical_language>do this in Netty4MessageChannelHandler#write? uncaught exceptions normal channel exception handling</technical_language>

Target:
public void sendMessage(OutboundHandler.SendContext sendContext) { channel.writeAndFlush(sendContext, addPromise(sendContext, channel)); if (channel.eventLoop().isShutdown()) { sendContext.onFailure(new TransportException("Cannot send message, event loop is shutting down.")); } }
Source:
<code>public <Q, I, U> SubscriptionQueryResult<QueryResponseMessage<I>, SubscriptionQueryUpdateMessage<U>> subscriptionQuery( SubscriptionQueryMessage<Q, I, U> query, int updateBufferSize) { if (queryUpdateEmitter.queryUpdateHandlerRegistered(query)) { throw new IllegalArgumentException("There is already a subscription with the given message identifier"); } MonoWrapper<QueryResponseMessage<I>> initialResult = MonoWrapper.create(monoSink -> query(query) .thenAccept(monoSink::success) .exceptionally(t -> { logger.error(format("An error happened while trying to report an initial result. Query: %s", query), <START> t); <END> monoSink.error(t.getCause()); return null; })); UpdateHandlerRegistration<U> updateHandlerRegistration = queryUpdateEmitter .registerUpdateHandler(query, updateBufferSize); return new DefaultSubscriptionQueryResult<>(initialResult.getMono(), updateHandlerRegistration.getUpdates(), updateHandlerRegistration.getRegistration()); }</code><technical_language>changes, I guessing set style guide present in this project. mind axon_code_style.xml file set style for this project</technical_language>

Target:
public <Q, I, U> SubscriptionQueryResult<QueryResponseMessage<I>, SubscriptionQueryUpdateMessage<U>> subscriptionQuery( SubscriptionQueryMessage<Q, I, U> query, int updateBufferSize) { if (queryUpdateEmitter.queryUpdateHandlerRegistered(query)) { throw new IllegalArgumentException("There is already a subscription with the given message identifier"); } MonoWrapper<QueryResponseMessage<I>> initialResult = getInitialResultMono(query); UpdateHandlerRegistration<U> updateHandlerRegistration = queryUpdateEmitter .registerUpdateHandler(query, updateBufferSize); return getSubscriptionQueryResult(initialResult, updateHandlerRegistration); }
Source:
<code>protected void run() throws Exception { try (Git git = new Git(db)) { if (command == null) { RemoteListCommand cmd = git.remoteList(); List<RemoteConfig> remotes = cmd.call(); print(remotes); } else if ("add".equals(command)) { RemoteAddCommand cmd = git.remoteAdd(); cmd.setName(name); cmd.setUri(new URIish(uri)); cmd.call(); } else if ("remove".equals(command) || "rm".equals(command)) { RemoteRemoveCommand cmd = git.remoteRemove(); cmd.setName(name); cmd.call(); } else if ("set-url".equals(command)) { RemoteSetUrlCommand cmd = git.remoteSetUrl(); cmd.setName(name); cmd.setUri(new URIish(uri)); cmd.setPush(push); cmd.call(); } else if ("update".equals(command)) { Fetch fetch = new Fetch(); fetch.init(db, gitdir); StringWriter osw = new StringWriter(); fetch.outw = new ThrowingPrintWriter(osw); StringWriter esw = new StringWriter(); fetch.errw = new ThrowingPrintWriter(esw); List<String> fetchArgs = new ArrayList<>(); <START> if (verbose) <END> fetchArgs.add("--verbose"); if (prune) fetchArgs.add("--prune"); if (name != null) fetchArgs.add(name); fetch.execute(fetchArgs.toArray(new String[fetchArgs.size()])); fetch.outw.flush(); fetch.errw.flush(); outw.println(osw.toString()); errw.println(esw.toString()); } else { throw new JGitInternalException(MessageFormat .format(CLIText.get().unknownSubcommand, command)); } } }</code><technical_language>style nit: missing braces (we changed style guide [1] braces for single line blocks in new changed code) [1] <LINK_0></technical_language>

Target:
protected void run() throws Exception { try (Git git = new Git(db)) { if (command == null) { RemoteListCommand cmd = git.remoteList(); List<RemoteConfig> remotes = cmd.call(); print(remotes); } else if ("add".equals(command)) { RemoteAddCommand cmd = git.remoteAdd(); cmd.setName(name); cmd.setUri(new URIish(uri)); cmd.call(); } else if ("remove".equals(command) || "rm".equals(command)) { RemoteRemoveCommand cmd = git.remoteRemove(); cmd.setName(name); cmd.call(); } else if ("set-url".equals(command)) { RemoteSetUrlCommand cmd = git.remoteSetUrl(); cmd.setName(name); cmd.setUri(new URIish(uri)); cmd.setPush(push); cmd.call(); } else if ("update".equals(command)) { Fetch fetch = new Fetch(); fetch.init(db, gitdir); StringWriter osw = new StringWriter(); fetch.outw = new ThrowingPrintWriter(osw); StringWriter esw = new StringWriter(); fetch.errw = new ThrowingPrintWriter(esw); List<String> fetchArgs = new ArrayList<>(); if (verbose) { fetchArgs.add("--verbose"); } if (prune) { fetchArgs.add("--prune"); } if (name != null) { fetchArgs.add(name); } fetch.execute(fetchArgs.toArray(new String[fetchArgs.size()])); fetch.outw.flush(); fetch.errw.flush(); outw.println(osw.toString()); errw.println(esw.toString()); } else { throw new JGitInternalException(MessageFormat .format(CLIText.get().unknownSubcommand, command)); } } }
Source:
<code>public void installEdition(Set<String> pluginKeys) { Optional<UpdateCenter> updateCenter = updateCenterMatrixFactory.getUpdateCenter(true); <START> Set<Release> pluginsToInstall = new HashSet<>(); <END> if (updateCenter.isPresent()) { for (String pluginKey : pluginKeys) { pluginsToInstall.addAll(updateCenter.get().findInstallablePlugins(pluginKey, Version.create(""))); } } pluginsToInstall.forEach(super::download); }</code><technical_language>need create this Set updateCenter is present</technical_language>

Target:
public void installEdition(Set<String> pluginKeys) { Optional<UpdateCenter> updateCenter = updateCenterMatrixFactory.getUpdateCenter(true); if (updateCenter.isPresent()) { Set<Release> pluginsToInstall = new HashSet<>(); for (String pluginKey : pluginKeys) { pluginsToInstall.addAll(updateCenter.get().findInstallablePlugins(pluginKey, Version.create(""))); } for (Release r : pluginsToInstall) { super.download(r); } } }
Source:
<code>public List<VmTemplate> getVmTemplatesByIds(List<Guid> templatesIds) { return getCallsHandler().executeReadList("GetVmTemplatesByIds", VMTemplateRowMapper.instance, <START> getCustomMapSqlParameterSource().addValue("vms_tremplates_ids", StringUtils.join(templatesIds,','))); <END> }</code><technical_language>Please change vms_tremplates_ids vms_templates_ids</technical_language>

Target:
public List<VmTemplate> getVmTemplatesByIds(List<Guid> templatesIds) { return getCallsHandler().executeReadList("GetVmTemplatesByIds", VMTemplateRowMapper.instance, getCustomMapSqlParameterSource().addValue("vm_templates_ids", StringUtils.join(templatesIds,','))); }
Source:
<code>protected void executeCommand() { setStoragePoolId(getNetwork().getDataCenterId()); TransactionSupport.executeInNewTransaction(new TransactionMethod<Void> () { @Override public Void runInTransaction() { removeVnicProfiles(); getCompensationContext().snapshotEntity(getNetwork()); getNetworkDAO().remove(getNetwork().getId()); getCompensationContext().stateChanged(); return null; } }); if (getNetwork().isExternal()) { if (getParameters().isRemoveFromNetworkProvider()) { removeExternalNetwork(); } } else { <START> if (NetworkUtils.isLabeled(getNetwork()) <END> && NetworkHelper.setupNetworkSupported(getStoragePool().getcompatibility_version())) { removeNetworkFromHosts(); } } setSucceeded(true); }</code><technical_language>code duplicates code- DetachNetworkToVdsGroupCommand.executeCommand(..)- if (!getPersistedNetwork().isExternal() && NetworkUtils.isLabeled(getPersistedNetwork()) && NetworkHelper.setupNetworkSupported(getVdsGroup().getcompatibility_version())) { removeNetworkFromHosts(); } Please consider adding method NetworkHelper- private boolean shouldNetworkBeRemovedFromHosts(Network network, Guid idForCompatibility) {...} call from- 'NetworkHelper.removeNetworkFromHosts(..)'</technical_language>

Target:
protected void executeCommand() { setStoragePoolId(getNetwork().getDataCenterId()); TransactionSupport.executeInNewTransaction(new TransactionMethod<Void> () { @Override public Void runInTransaction() { removeVnicProfiles(); getCompensationContext().snapshotEntity(getNetwork()); getNetworkDAO().remove(getNetwork().getId()); getCompensationContext().stateChanged(); return null; } }); if (getNetwork().isExternal()) { if (getParameters().isRemoveFromNetworkProvider()) { removeExternalNetwork(); } } if (NetworkHelper.shouldNetworkBeRemovedFromHosts(getNetwork(), getStoragePool().getcompatibility_version())) { removeNetworkFromHosts(); } setSucceeded(true); }
Source:
<code>public Collection<IRemoteTest> split(int shardCountHint) { if (shardCountHint <= 1 || mIsSharded) { <START> return null; <END> } Collection<IRemoteTest> tests = new ArrayList<>(); for (int i = 0; i < shardCountHint; i++) { tests.add(getTestShard(shardCountHint, i)); } return tests; }</code><technical_language>Add a log message here</technical_language>

Target:
public Collection<IRemoteTest> split(int shardCountHint) { if (shardCountHint <= 1 || mIsSharded) { return null; } Collection<IRemoteTest> tests = new ArrayList<>(); for (int i = 0; i < shardCountHint; i++) { tests.add(getTestShard(shardCountHint, i)); } mIsSharded = true; return tests; }
Source:
<code>private NetworkSend write(SelectionKey key, Transmission transmission) { long startTimeToWriteInMs = time.milliseconds(); try { boolean sendComplete = transmission.write(); NetworkSend networkSend = transmission.getNetworkSend(); if (sendComplete) { logger.trace("Finished writing, registering for read on connection {}", transmission.getRemoteSocketAddress()); transmission.onSendComplete(); metrics.sendInFlight.dec(); transmission.clearSend(); key.interestOps(key.interestOps() & ~SelectionKey.OP_WRITE | SelectionKey.OP_READ); } return networkSend; } catch (IOException e) { handleReadWriteIOException(e, key); <START> transmission.networkSend.getPayload().release(); <END> return null; } finally { long writeTime = time.milliseconds() - startTimeToWriteInMs; logger.trace("SocketServer time spent on write per key = {}", transmission.getConnectionId(), writeTime); } }</code><technical_language>closing send buffer in close(SelectionKey key) method better, calls Transmission.close() unify cleanup paths. valid release send buffer Transmission.clearSend() is called</technical_language>

Target:
private NetworkSend write(SelectionKey key, Transmission transmission) { long startTimeToWriteInMs = time.milliseconds(); try { boolean sendComplete = transmission.write(); NetworkSend networkSend = transmission.getNetworkSend(); if (sendComplete) { logger.trace("Finished writing, registering for read on connection {}", transmission.getRemoteSocketAddress()); transmission.onSendComplete(); metrics.sendInFlight.dec(); transmission.clearSend(); key.interestOps(key.interestOps() & ~SelectionKey.OP_WRITE | SelectionKey.OP_READ); } return networkSend; } catch (IOException e) { handleReadWriteIOException(e, key); return null; } finally { long writeTime = time.milliseconds() - startTimeToWriteInMs; logger.trace("SocketServer time spent on write per key = {}", transmission.getConnectionId(), writeTime); } }
Source:
<code>public String generateCPF(boolean valid) { String partial = ""; String cpf = ""; Integer number; for (int i = 0; i < 9; i++) { number = new Integer((int) (Math.random() * 10)); partial += number.toString(); } if(valid) { cpf = partial + CPFUtils.calculateVerificationDigit(partial); } else { <START> String twoFakeDigits = String.valueOf(new Random().nextInt(9 + 1)) + String.valueOf(new Random().nextInt(9 + 1)); <END> cpf = partial + twoFakeDigits; } return formatCPF(cpf); }</code><technical_language>a chance this return a valid checkSum? 1 in 100 chance possibly</technical_language>

Target:
public String generateCPF(boolean valid) { String partial = ""; String cpf = ""; Integer number; for (int i = 0; i < 9; i++) { number = new Integer((int) (Math.random() * 10)); partial += number.toString(); } if(valid) { cpf = partial + CPFUtils.calculateVerificationDigit(partial); } else { Random random = new Random(); long elevenDigits = (random.nextInt(1000000000) + (random.nextInt(90) + 10) * 1000000000L); cpf = String.valueOf(elevenDigits); } return formatCPF(cpf); }
Source:
<code>public FilePath getWorkspace(Job job) { <START> if(job != null) { <END> LOGGER.info("Nodes went offline. Hence fetching it through master"); if (job instanceof AbstractProject) { String assignedLabel = ((AbstractProject) job).getAssignedLabelString(); KubernetesCloud kubernetesCloud = Hudson.getInstance().clouds.get(KubernetesCloud.class); if (kubernetesCloud != null) { List<PodTemplate> podTemplates = kubernetesCloud.getTemplates(); for (PodTemplate podTemplate : podTemplates) { if (ObjectUtils.equals(podTemplate.getLabel(), assignedLabel)) { FilePath filePath = Jenkins.getInstance().getWorkspaceFor((TopLevelItem) job); if(filePath != null) { String workspacePath = filePath.toString(); LOGGER.info("Workspace Path: " + workspacePath); File workspace = new File(workspacePath); LOGGER.info("Workspace exists ? " + workspace.exists()); if (workspace.exists()) { return new FilePath(workspace); } } } } } } } return null; }</code><technical_language>is need add a null check instanceof. <LINK_0></technical_language>

Target:
public FilePath getWorkspace(Job job) { LOGGER.info("Nodes went offline. Hence fetching it through master"); if (job instanceof AbstractProject) { String assignedLabel = ((AbstractProject) job).getAssignedLabelString(); Jenkins jenkinsInstance = Hudson.getInstanceOrNull(); if(jenkinsInstance != null) { List<KubernetesCloud> kubernetesClouds = jenkinsInstance.clouds.getAll(KubernetesCloud.class); for (KubernetesCloud kubernetesCloud : kubernetesClouds) { if (kubernetesCloud != null) { List<PodTemplate> podTemplates = kubernetesCloud.getTemplates(); for (PodTemplate podTemplate : podTemplates) { if (ObjectUtils.equals(podTemplate.getLabel(), assignedLabel)) { FilePath filePath = Jenkins.getInstance().getWorkspaceFor((TopLevelItem) job); if (filePath != null) { String workspacePath = filePath.toString(); LOGGER.fine("Workspace Path: " + workspacePath); File workspace = new File(workspacePath); LOGGER.fine("Workspace exists ? " + workspace.exists()); if (workspace.exists()) { return new FilePath(workspace); } } } } } } } } return null; }
Source:
<code>public UpdateMetadataRequest build(short version) { if (version < 3) { for (UpdateMetadataBroker broker : liveBrokers) { if (version == 0) { if (broker.endpoints().size() != 1 || broker.endpoints().get(0).securityProtocol() != SecurityProtocol.PLAINTEXT.id) { throw new UnsupportedVersionException("UpdateMetadataRequest v0 only handles PLAINTEXT endpoints"); } <START> UpdateMetadataEndpoint endpoint = broker.endpoints().get(0); <END> broker.setV0Host(endpoint.host()); broker.setV0Port(endpoint.port()); } else { if (broker.endpoints().stream().anyMatch(endpoint -> !endpoint.listener().isEmpty() && !endpoint.listener().equals(listenerNameFromSecurityProtocol(endpoint)))) { throw new UnsupportedVersionException("UpdateMetadataRequest v0-v3 does not support custom " + "listeners, request version: " + version + ", endpoints: " + broker.endpoints()); } } } } UpdateMetadataRequestData data = new UpdateMetadataRequestData() .setControllerId(controllerId) .setControllerEpoch(controllerEpoch) .setBrokerEpoch(brokerEpoch) .setLiveBrokers(liveBrokers); if (version >= 5) { Map<String, UpdateMetadataTopicState> topicStatesMap = groupByTopic(partitionStates); data.setTopicStates(new ArrayList<>(topicStatesMap.values())); } else { data.setUngroupedPartitionStates(partitionStates); } return new UpdateMetadataRequest(data, version); }</code><technical_language>a separate UnsupportedVersionException for multiple endpoints? For example, multiple plaintext endpoints</technical_language>

Target:
public UpdateMetadataRequest build(short version) { if (version < 3) { for (UpdateMetadataBroker broker : liveBrokers) { if (version == 0) { if (broker.endpoints().size() != 1) throw new UnsupportedVersionException("UpdateMetadataRequest v0 requires a single endpoint"); if (broker.endpoints().get(0).securityProtocol() != SecurityProtocol.PLAINTEXT.id) throw new UnsupportedVersionException("UpdateMetadataRequest v0 only handles PLAINTEXT endpoints"); UpdateMetadataEndpoint endpoint = broker.endpoints().get(0); broker.setV0Host(endpoint.host()); broker.setV0Port(endpoint.port()); } else { if (broker.endpoints().stream().anyMatch(endpoint -> !endpoint.listener().isEmpty() && !endpoint.listener().equals(listenerNameFromSecurityProtocol(endpoint)))) { throw new UnsupportedVersionException("UpdateMetadataRequest v0-v3 does not support custom " + "listeners, request version: " + version + ", endpoints: " + broker.endpoints()); } } } } UpdateMetadataRequestData data = new UpdateMetadataRequestData() .setControllerId(controllerId) .setControllerEpoch(controllerEpoch) .setBrokerEpoch(brokerEpoch) .setLiveBrokers(liveBrokers); if (version >= 5) { Map<String, UpdateMetadataTopicState> topicStatesMap = groupByTopic(partitionStates); data.setTopicStates(new ArrayList<>(topicStatesMap.values())); } else { data.setUngroupedPartitionStates(partitionStates); } return new UpdateMetadataRequest(data, version); }