auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public QualityGateDto selectBuiltIn(DbSession dbSession) { QualityGateDto qualityGateDto = mapper(dbSession).selectBuiltIn(); <START> checkState(qualityGateDto != null, "Builtin quality gate is missing."); <END> return qualityGateDto; }</code><technical_language>AFAIK, check in DAO (it in QualityGateFinder)</technical_language>

Target:
public QualityGateDto selectBuiltIn(DbSession dbSession) { return mapper(dbSession).selectBuiltIn(); }
Source:
<code><START> private boolean imageValidation() { <END> if (disk.getDiskStorageType() != DiskStorageType.IMAGE) { return true; } StorageDomain storageDomain = getStorageDomainDAO().getForStoragePool( ((DiskImage) disk).getStorageIds().get(0), ((DiskImage) disk).getStoragePoolId()); StorageDomainValidator storageDomainValidator = new StorageDomainValidator(storageDomain); return validate(storageDomainValidator.isDomainExistAndActive()); }</code><technical_language>this method checks other checks if domain is active, is image validation. Please consider renaming method</technical_language>

Target:
private boolean imageValidation() { if (disk.getDiskStorageType() != DiskStorageType.IMAGE || (getVm().getStatus() != VMStatus.Up && getVm().getStatus() != VMStatus.Paused)) { return true; } StorageDomain storageDomain = getStorageDomainDAO().getForStoragePool( ((DiskImage) disk).getStorageIds().get(0), ((DiskImage) disk).getStoragePoolId()); StorageDomainValidator storageDomainValidator = new StorageDomainValidator(storageDomain); return validate(storageDomainValidator.isDomainExistAndActive()); }
Source:
<code>final void assertionError(String message) { <START> StringBuilder b = new StringBuilder(); <END> if (onCompletedEvents.isEmpty()) { b.append("(active) "); } b.append(message); if (!onErrorEvents.isEmpty()) { b.append(" (+ ") .append(onErrorEvents.size()) .append(" errors)"); } AssertionError ae = new AssertionError(b.toString()); if (!onErrorEvents.isEmpty()) { if (onErrorEvents.size() == 1) { ae.initCause(onErrorEvents.get(0)); } else { ae.initCause(new CompositeException(onErrorEvents)); } } throw ae; }</code><technical_language>nit: set some initial capacity save allocations</technical_language>

Target:
final void assertionError(String message) { StringBuilder b = new StringBuilder(message.length() + 32); b.append(message); b.append(" ("); int c = onCompletedEvents.size(); b.append(c); b.append(" completion"); if (c != 1) { b.append("s"); } b.append(")"); if (!onErrorEvents.isEmpty()) { int size = onErrorEvents.size(); b.append(" (+") .append(size) .append(" error"); if (size != 1) { b.append("s"); } b.append(")"); } AssertionError ae = new AssertionError(b.toString()); if (!onErrorEvents.isEmpty()) { if (onErrorEvents.size() == 1) { ae.initCause(onErrorEvents.get(0)); } else { ae.initCause(new CompositeException(onErrorEvents)); } } throw ae; }
Source:
<code><START> public void setUp() throws Exception { <END> receiver = new Receiver(reporter) { @Override public Object fromJSON(final String json) { return returnObject; } }; receiver.setUp(worker); verify(worker).setOnMessage(messageHandlerArgumentCaptor.capture()); }</code><technical_language>@Rikkola is this "throws' Exception necessary</technical_language>

Target:
public void setUp() { receiver = new Receiver(reporter) { @Override public Object fromJSON(final String json) { return returnObject; } }; receiver.setUp(worker); verify(worker).setOnMessage(messageHandlerArgumentCaptor.capture()); }
Source:
<code>public static ResAllocs addAll(List<ResAllocs> resToAdd) { if (resToAdd.isEmpty()) { <START> throw new IllegalArgumentException("Empty list provided"); <END> } if (resToAdd.size() == 1) { return resToAdd.get(0); } double cores = 0; double memory = 0; double network = 0; double disk = 0; for (ResAllocs r : resToAdd) { cores += r.getCores(); memory += r.getMemory(); network += r.getNetworkMbps(); disk += r.getDisk(); } return new ResAllocsBuilder(resToAdd.get(0).getTaskGroupName()) .withCores(cores) .withMemory(memory) .withNetworkMbps(network) .withDisk(disk) .build(); }</code><technical_language>a silent return treating a no-op OK</technical_language>

Target:
public static Optional<ResAllocs> addAll(List<ResAllocs> resToAdd) { if (resToAdd.isEmpty()) { return Optional.empty(); } if (resToAdd.size() == 1) { return Optional.of(resToAdd.get(0)); } double cores = 0; double memory = 0; double network = 0; double disk = 0; for (ResAllocs r : resToAdd) { cores += r.getCores(); memory += r.getMemory(); network += r.getNetworkMbps(); disk += r.getDisk(); } ResAllocs total = new ResAllocsBuilder(resToAdd.get(0).getTaskGroupName()) .withCores(cores) .withMemory(memory) .withNetworkMbps(network) .withDisk(disk) .build(); return Optional.of(total); }
Source:
<code>private Void monitorAndGetSplits() throws Exception { stateLock.writeLock().lock(); try { List<Tuple2<Partition, T>> partitions = fetcher.fetchPartitions(fetcherContext, currentReadOffset); if (partitions.isEmpty()) { return null; } partitions.sort(Comparator.comparing(o -> o.f1)); List<HiveSourceSplit> newSplits = new ArrayList<>(); T maxOffset = currentReadOffset; Set<List<String>> nextSeen = new HashSet<>(); for (Tuple2<Partition, T> tuple2 : partitions) { Partition partition = tuple2.f0; List<String> partSpec = partition.getValues(); if (seenPartitions.add(partSpec)) { T offset = tuple2.f1; if (offset.compareTo(currentReadOffset) > 0) { nextSeen.add(partSpec); } if (offset.compareTo(maxOffset) > 0) { maxOffset = offset; } LOG.info("Found new partition of table {}, generating splits for it", partSpec, tablePath.getFullName()); newSplits.addAll(HiveSourceFileEnumerator.createInputSplits( 0, Collections.singletonList(fetcherContext.toHiveTablePartition(partition)), jobConf)); } } currentReadOffset = maxOffset; <START> splitAssigner.addSplits(new ArrayList<>(newSplits)); <END> if (!nextSeen.isEmpty()) { seenPartitions.clear(); seenPartitions.addAll(nextSeen); } return null; } finally { stateLock.writeLock().unlock(); } }</code><technical_language>return newSplits pass handleNewSplits call assignSplits</technical_language>

Target:
private Void monitorAndGetSplits() throws Exception { stateLock.writeLock().lock(); try { List<Tuple2<Partition, T>> partitions = fetcher.fetchPartitions(fetcherContext, currentReadOffset); if (partitions.isEmpty()) { return null; } partitions.sort(Comparator.comparing(o -> o.f1)); List<HiveSourceSplit> newSplits = new ArrayList<>(); T maxOffset = currentReadOffset; Set<List<String>> nextSeen = new HashSet<>(); for (Tuple2<Partition, T> tuple2 : partitions) { Partition partition = tuple2.f0; List<String> partSpec = partition.getValues(); if (seenPartitionsSinceOffset.add(partSpec)) { T offset = tuple2.f1; if (offset.compareTo(currentReadOffset) > 0) { nextSeen.add(partSpec); } if (offset.compareTo(maxOffset) > 0) { maxOffset = offset; } LOG.info("Found new partition of table {}, generating splits for it", partSpec, tablePath.getFullName()); newSplits.addAll(HiveSourceFileEnumerator.createInputSplits( 0, Collections.singletonList(fetcherContext.toHiveTablePartition(partition)), jobConf)); } } currentReadOffset = maxOffset; splitAssigner.addSplits(new ArrayList<>(newSplits)); if (!nextSeen.isEmpty()) { seenPartitionsSinceOffset.clear(); seenPartitionsSinceOffset.addAll(nextSeen); } return null; } finally { stateLock.writeLock().unlock(); } }
Source:
<code>private void rename() throws IOException { if(mFile != null && Files.exists(mFile)) { String renamed = mFile.getFileName().toString(); renamed = renamed.replace(".tmp", ".wav"); Path renamedPath = mFile.resolveSibling(renamed); int suffix = 1; while(Files.exists(renamedPath) && suffix < 4) { String renamedWithSuffix = mFile.getFileName().toString(); renamedWithSuffix = renamedWithSuffix.replace(".tmp", "_" + suffix + ".wav"); <START> String cleaned = StringUtils.replaceIllegalCharacters(renamedWithSuffix); <END> Path renamedWithSuffixPath = mFile.resolveSibling(cleaned); renamedPath = mFile.resolveSibling(renamedWithSuffixPath); suffix++; } Files.move(mFile, renamedPath); } }</code><technical_language>This change removed. original filename valid characters if this point, updated suffix version valid filename charactes. Otherwise, this corrupt linux filepaths</technical_language>

Target:
private void rename() throws IOException { if(mFile != null && Files.exists(mFile)) { String renamed = mFile.getFileName().toString(); renamed = renamed.replace(".tmp", ".wav"); Path renamedPath = mFile.resolveSibling(renamed); int suffix = 1; while(Files.exists(renamedPath) && suffix < 4) { String renamedWithSuffix = mFile.getFileName().toString(); renamedWithSuffix = renamedWithSuffix.replace(".tmp", "_" + suffix + ".wav"); Path renamedWithSuffixPath = mFile.resolveSibling(renamedWithSuffix); renamedPath = mFile.resolveSibling(renamedWithSuffixPath); suffix++; } Files.move(mFile, renamedPath); } }
Source:
<code>protected ConnectorFactory instantiateConnectorFactory(final String connectorFactoryClassName) { ConnectorFactory cachedFactory = connectorFactory; if (cachedFactory != null && cachedFactory.getClass().getName().equals(connectorFactoryClassName)) { return cachedFactory; } return AccessController.doPrivileged(new PrivilegedAction<ConnectorFactory>() { @Override public ConnectorFactory run() { <START> ClassLoader cl = Thread.currentThread().getContextClassLoader(); <END> try { Thread.currentThread().setContextClassLoader(ClientSessionFactoryImpl.class.getClassLoader()); return (ConnectorFactory) ClassloadingUtil.newInstanceFromClassLoader(connectorFactoryClassName); } finally { Thread.currentThread().setContextClassLoader(cl); } } }); }</code><technical_language>change ClassLoadingUtil java public static Object newInstanceFromClassLoader(final String className) { return newInstanceFromClassLoader(ClassloadingUtil.class, className); } public static Object newInstanceFromClassLoader(Class classOwner, final String className) { ClassLoader loader = classOwner.getClassLoader(); try { Class<?> clazz = loader.loadClass(className); return clazz.newInstance(); } catch (Throwable t) { if (t instanceof InstantiationException) { System.out.println(INSTANTIATION_EXCEPTION_MESSAGE); } loader = Thread.currentThread().getContextClassLoader(); if (loader == null) throw new RuntimeException("No local context classloader", t); try { return loader.loadClass(className).newInstance(); } catch (InstantiationException e) { throw new RuntimeException(INSTANTIATION_EXCEPTION_MESSAGE + " " + className, e); } catch (ClassNotFoundException e) { throw new IllegalStateException(e); } catch (IllegalAccessException e) { throw new RuntimeException(e); } } } pass in class parameter cases? this issues Security JDK? If issues I prefer parameter added</technical_language>

Target:
protected ConnectorFactory instantiateConnectorFactory(final String connectorFactoryClassName) { ConnectorFactory cachedFactory = connectorFactory; if (cachedFactory != null && cachedFactory.getClass().getName().equals(connectorFactoryClassName)) { return cachedFactory; } return AccessController.doPrivileged(new PrivilegedAction<ConnectorFactory>() { @Override public ConnectorFactory run() { return (ConnectorFactory) ClassloadingUtil.newInstanceFromClassLoader(ClientSessionFactoryImpl.class, connectorFactoryClassName); } }); }
Source:
<code>public void init(GraphHopperConfig ghConfig) { if (ghConfig.has("prepare.lm.weightings")) { <START> throw new IllegalStateException("Use profiles_lm instead of prepare.lm.weightings"); <END> } setPreparationThreads(ghConfig.getInt(Parameters.Landmark.PREPARE + "threads", getPreparationThreads())); setDisablingAllowed(ghConfig.getBool(Landmark.INIT_DISABLING_ALLOWED, isDisablingAllowed())); setLMProfileConfigs(ghConfig.getLMProfiles()); landmarkCount = ghConfig.getInt(Parameters.Landmark.COUNT, landmarkCount); activeLandmarkCount = ghConfig.getInt(Landmark.ACTIVE_COUNT_DEFAULT, Math.min(8, landmarkCount)); logDetails = ghConfig.getBool(Landmark.PREPARE + "log_details", false); minNodes = ghConfig.getInt(Landmark.PREPARE + "min_network_size", -1); for (String loc : ghConfig.get(Landmark.PREPARE + "suggestions_location", "").split(",")) { if (!loc.trim().isEmpty()) lmSuggestionsLocations.add(loc.trim()); } }</code><technical_language>(I put a link this issue in error message)</technical_language>

Target:
public void init(GraphHopperConfig ghConfig) { if (ghConfig.has("prepare.lm.weightings")) { throw new IllegalStateException("Use profiles_lm instead of prepare.lm.weightings, see #1922"); } setPreparationThreads(ghConfig.getInt(Parameters.Landmark.PREPARE + "threads", getPreparationThreads())); setDisablingAllowed(ghConfig.getBool(Landmark.INIT_DISABLING_ALLOWED, isDisablingAllowed())); setLMProfileConfigs(ghConfig.getLMProfiles()); landmarkCount = ghConfig.getInt(Parameters.Landmark.COUNT, landmarkCount); activeLandmarkCount = ghConfig.getInt(Landmark.ACTIVE_COUNT_DEFAULT, Math.min(8, landmarkCount)); if (activeLandmarkCount > landmarkCount) throw new IllegalArgumentException("Default value for active landmarks " + activeLandmarkCount + " should be less or equal to landmark count of " + landmarkCount); logDetails = ghConfig.getBool(Landmark.PREPARE + "log_details", false); minNodes = ghConfig.getInt(Landmark.PREPARE + "min_network_size", -1); for (String loc : ghConfig.get(Landmark.PREPARE + "suggestions_location", "").split(",")) { if (!loc.trim().isEmpty()) lmSuggestionsLocations.add(loc.trim()); } }
Source:
<code>LRESULT WM_CHAR (long wParam, long lParam) { if (ignoreCharacter) return null; LRESULT result = super.WM_CHAR (wParam, lParam); if (result != null) return result; switch ((int) wParam) { case SWT.DEL: if (OS.GetKeyState (OS.VK_CONTROL) < 0) { if ((style & SWT.READ_ONLY) != 0) return LRESULT.ZERO; Point selection = getSelection(); String text = getText(); int x = selection.x; int y = selection.y; if (x == y) { <START> String actText = text.substring (0, getCaretPosition()); <END> java.util.regex.Matcher m = CTRL_BS_PATTERN.matcher (actText); if (m.find ()) { x = m.start (); y = m.end (); OS.SendMessage (handle, OS.EM_SETSEL, x, y); } } if (x < y) { OS.SendMessage (handle, OS.EM_REPLACESEL, 1, 0); } return LRESULT.ZERO; } } if ((style & SWT.SINGLE) != 0) { switch ((int) wParam) { case SWT.CR: sendSelectionEvent (SWT.DefaultSelection); case SWT.TAB: case SWT.ESC: return LRESULT.ZERO; } } return result; }</code><technical_language>getText (0, getCaretPosition()) method call</technical_language>

Target:
LRESULT WM_CHAR (long wParam, long lParam) { if (ignoreCharacter) return null; LRESULT result = super.WM_CHAR (wParam, lParam); if (result != null) return result; switch ((int) wParam) { case SWT.DEL: if (OS.GetKeyState (OS.VK_CONTROL) < 0) { if ((style & SWT.READ_ONLY) != 0) return LRESULT.ZERO; Point selection = getSelection (); int x = selection.x; int y = selection.y; if (x == y) { String actText = getText ().substring (0, getCaretPosition()); java.util.regex.Matcher m = CTRL_BS_PATTERN.matcher (actText); if (m.find ()) { x = m.start (); y = m.end (); OS.SendMessage (handle, OS.EM_SETSEL, x, y); } } if (x < y) { OS.SendMessage (handle, OS.EM_REPLACESEL, 1, 0); } return LRESULT.ZERO; } } if ((style & SWT.SINGLE) != 0) { switch ((int) wParam) { case SWT.CR: sendSelectionEvent (SWT.DefaultSelection); case SWT.TAB: case SWT.ESC: return LRESULT.ZERO; } } return result; }
Source:
<code>private String buildTailApiUrl(String tailApiUrl) { if (!isMethodWithBody() && !args.isEmpty()) { try { boolean questionMarkFound = tailApiUrl.indexOf('?') != -1; StringBuilder argString = new StringBuilder(); argString.append(questionMarkFound ? '&' : '?'); for (Iterator<Entry> it = args.listIterator(); it.hasNext();) { Entry arg = it.next(); <START> argString.append(URLEncoder.encode(arg.key, "UTF-8")); <END> argString.append('='); argString.append(URLEncoder.encode(arg.value.toString(), "UTF-8")); if (it.hasNext()) { argString.append('&'); } } tailApiUrl += argString; } catch (UnsupportedEncodingException e) { throw new AssertionError(e); } } return tailApiUrl; }</code><technical_language>this <LINK_0> instead of hardcoded value? (no biggie tbh)</technical_language>

Target:
private String buildTailApiUrl(String tailApiUrl) { if (!isMethodWithBody() && !args.isEmpty()) { try { boolean questionMarkFound = tailApiUrl.indexOf('?') != -1; StringBuilder argString = new StringBuilder(); argString.append(questionMarkFound ? '&' : '?'); for (Iterator<Entry> it = args.listIterator(); it.hasNext();) { Entry arg = it.next(); argString.append(URLEncoder.encode(arg.key, StandardCharsets.UTF_8.name())); argString.append('='); argString.append(URLEncoder.encode(arg.value.toString(), StandardCharsets.UTF_8.name())); if (it.hasNext()) { argString.append('&'); } } tailApiUrl += argString; } catch (UnsupportedEncodingException e) { throw new AssertionError(e); } } return tailApiUrl; }
Source:
<code>public static NotificationCompat.Builder setSecretVisibility(NotificationCompat.Builder builder) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { <START> return builder.setVisibility(Notification.VISIBILITY_SECRET).setPriority(Notification.PRIORITY_MIN); <END> } return builder; }</code><technical_language>Extract Priority a constant change in 2 places</technical_language>

Target:
public static NotificationCompat.Builder setSecretVisibility(NotificationCompat.Builder builder) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { return builder.setVisibility(Notification.VISIBILITY_SECRET); } return builder; }
Source:
<code>protected void readInternal() throws IOException, CorruptObjectException { if (liveFile == null) throw new IOException(JGitText.get().dirCacheDoesNotHaveABackingFile); if (!liveFile.exists()) clearInternal(); else if (liveFile.lastModified() != lastModified) { try { <START> System.out.println("Reading DirCache"); <END> final FileInputStream inStream = new FileInputStream(liveFile); try { clearInternal(); readFrom(inStream); } finally { try { inStream.close(); } catch (IOException err2) { } } } catch (FileNotFoundException fnfe) { clearInternal(); } } }</code><technical_language>I this println removed</technical_language>

Target:
protected void readInternal() throws IOException, CorruptObjectException { if (liveFile == null) throw new IOException(JGitText.get().dirCacheDoesNotHaveABackingFile); if (!liveFile.exists()) clearInternal(); else if (liveFile.lastModified() != lastModified) { try { final FileInputStream inStream = new FileInputStream(liveFile); try { clearInternal(); readFrom(inStream); } finally { try { inStream.close(); } catch (IOException err2) { } } } catch (FileNotFoundException fnfe) { clearInternal(); } } }
Source:
<code>private void verifyLoginFailed(String username, String password) { events.clear(); loginPage.open(); loginPage.login(username, password); Assert.assertEquals("Invalid username or password.", loginPage.getError()); if (username.equals(DEFAULT_TEST_USERS.get("INVALID_USER_EMAIL")) || username.equals(DEFAULT_TEST_USERS.get("INVALID_USER_NAME"))) { <START> events.expect(EventType.LOGIN_ERROR).user((String) null).error("user_not_found").assertEvent(); <END> } else if (username.equals(DEFAULT_TEST_USERS.get("VALID_USER_EMAIL")) || username.equals(DEFAULT_TEST_USERS.get("VALID_USER_NAME"))) { List<UserRepresentation> knownUsers = getAdminClient().realm(TEST_REALM_NAME).users().search(DEFAULT_TEST_USERS.get("VALID_USER_NAME")); Assert.assertTrue(!knownUsers.isEmpty()); final String userId = knownUsers.get(0).getId(); events.expect(EventType.LOGIN_ERROR).user(userId).error("invalid_user_credentials").assertEvent(); } }</code><technical_language>nitpick: slightly constant Errors.USER_NOT_FOUND</technical_language>

Target:
private void verifyLoginFailed(String username, String password) { events.clear(); loginPage.open(); loginPage.login(username, password); Assert.assertEquals("Invalid username or password.", loginPage.getError()); if (username.equals(DEFAULT_TEST_USERS.get("INVALID_USER_EMAIL")) || username.equals(DEFAULT_TEST_USERS.get("INVALID_USER_NAME"))) { events.expect(EventType.LOGIN_ERROR).user((String) null).error(Errors.USER_NOT_FOUND).assertEvent(); } else if (username.equals(DEFAULT_TEST_USERS.get("VALID_USER_EMAIL")) || username.equals(DEFAULT_TEST_USERS.get("VALID_USER_NAME"))) { List<UserRepresentation> knownUsers = getAdminClient().realm(TEST_REALM_NAME).users().search(DEFAULT_TEST_USERS.get("VALID_USER_NAME")); Assert.assertTrue(!knownUsers.isEmpty()); final String userId = knownUsers.get(0).getId(); events.expect(EventType.LOGIN_ERROR).user(userId).error(Errors.INVALID_USER_CREDENTIALS).assertEvent(); } }
Source:
<code>public final String consoleClientResourcesUrl() { String url = getString(DynamicMessageKey.CONSOLE_CLIENT_RESOURCES_URL); boolean isAbsolute = url.contains("://"); return isAbsolute ? url : Window.Location.getProtocol() + " <START> "/" + BaseContextPathData.getInstance().getRelativePath() + url; END> }</code><technical_language>no... this relative well... see: frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/ReportInit.java</technical_language>

Target:
public final String consoleClientResourcesUrl() { String url = getString(DynamicMessageKey.CONSOLE_CLIENT_RESOURCES_URL); boolean isAbsolute = url.contains("://"); return isAbsolute ? url : "/" + BaseContextPathData.getInstance().getRelativePath() + url; }
Source:
<code>protected void showCreateContactDialog(final String prefilledJid, final Invite invite) { EnterJidDialog dialog = new EnterJidDialog( this, mKnownHosts, mActivatedAccounts, getString(R.string.dialog_title_create_contact), getString(R.string.create), prefilledJid, null, invite == null || !invite.hasFingerprints() ); dialog.setOnEnterJidDialogPositiveListener((accountJid, contactJid) -> { if (!xmppConnectionServiceBound) { return false; } final Account account = xmppConnectionService.findAccountByJid(accountJid); if (account == null) { return true; } final Contact contact = account.getRoster().getContact(contactJid); <START> if (invite.getName() != null) <END> contact.setServerName(invite.getName()); if (contact.isSelf()) { switchToConversation(contact,null); return true; } else if (contact.showInRoster()) { throw new EnterJidDialog.JidError(getString(R.string.contact_already_exists)); } else { xmppConnectionService.createContact(contact); if (invite != null && invite.hasFingerprints()) { xmppConnectionService.verifyFingerprints(contact,invite.getFingerprints()); } switchToConversation(contact, invite == null ? null : invite.getBody()); return true; } }); mCurrentDialog = dialog.show(); }</code><technical_language>Please wrap block in { }</technical_language>

Target:
protected void showCreateContactDialog(final String prefilledJid, final Invite invite) { EnterJidDialog dialog = new EnterJidDialog( this, mKnownHosts, mActivatedAccounts, getString(R.string.dialog_title_create_contact), getString(R.string.create), prefilledJid, null, invite == null || !invite.hasFingerprints() ); dialog.setOnEnterJidDialogPositiveListener((accountJid, contactJid) -> { if (!xmppConnectionServiceBound) { return false; } final Account account = xmppConnectionService.findAccountByJid(accountJid); if (account == null) { return true; } final Contact contact = account.getRoster().getContact(contactJid); if (contact.isSelf()) { switchToConversation(contact,null); return true; } else if (contact.showInRoster()) { throw new EnterJidDialog.JidError(getString(R.string.contact_already_exists)); } else { xmppConnectionService.createContact(contact); if (invite != null && invite.hasFingerprints()) { xmppConnectionService.verifyFingerprints(contact,invite.getFingerprints()); } switchToConversation(contact, invite == null ? null : invite.getBody()); return true; } }); mCurrentDialog = dialog.show(); }
Source:
<code>private void logStatesAndWeights() { final StringBuilder message = new StringBuilder("Joint segmenter has following (copy-ratio, allele-fraction): weight pairs: "); for (int n = 0; n < weights.length; n++) { final AFCRHiddenState state = hiddenStateValues.get(n); final double cr = state.getLog2CopyRatio(); final double af = state.getMinorAlleleFraction(); final double weight = weights[n]; <START> message.append(String.format("(%f, %f): %f", cr, af, weight) + ((n < weights.length - 1) ? ";" : ".")); <END> } logger.info(message); }</code><technical_language>Missing white space semicolon</technical_language>

Target:
private void logStatesAndWeights() { final StringBuilder message = new StringBuilder("Joint segmenter has following (copy-ratio, allele-fraction): weight pairs: "); for (int n = 0; n < numStates(); n++) { final AFCRHiddenState state = getState(n); final double cr = state.getLog2CopyRatio(); final double af = state.getMinorAlleleFraction(); final double weight = getWeight(n); message.append(String.format("(%f, %f): %f", cr, af, weight) + ((n < numStates() - 1) ? "; " : ".")); } logger.info(message); }
Source:
<code>public boolean isCredentialValid() throws IOException { try { retrieve().to("/user", GHUser.class); return true; } catch (IOException e) { <START> logger.log(Level.FINEST, "Exception validating credentials on {0} with login {1}: {2}", new Object[]{this.apiUrl, this.login, e, e}); <END> return false; } }</code><technical_language>FINE appropriate</technical_language>

Target:
public boolean isCredentialValid() throws IOException { try { retrieve().to("/user", GHUser.class); return true; } catch (IOException e) { if (logger.isLoggable(Level.FINE)) logger.log(Level.FINE, "Exception validating credentials on " + this.apiUrl + " with login '" + this.login + "' " + e, e); return false; } }
Source:
<code>public void senml_json_encode_device_object_instance() { LwM2mObjectInstance oInstance = new LwM2mObjectInstance(0, getDeviceResources()); byte[] encoded = LwM2mNodeSenMLJsonEncoder.encode(oInstance, new LwM2mPath("/3/0"), model, new DefaultLwM2mValueConverter()); StringBuilder b = new StringBuilder(); <START> b.append("[{\"bn\":\"/3/0\",\"n\":\"0\",\"vs\":\"Open Mobile Alliance\"},"); <END> b.append("{\"n\":\"1\",\"vs\":\"Lightweight M2M Client\"},"); b.append("{\"n\":\"2\",\"vs\":\"345000123\"},"); b.append("{\"n\":\"3\",\"vs\":\"1.0\"},"); b.append("{\"n\":\"6/0\",\"v\":1},"); b.append("{\"n\":\"6/1\",\"v\":5},"); b.append("{\"n\":\"7/0\",\"v\":3800},"); b.append("{\"n\":\"7/1\",\"v\":5000},"); b.append("{\"n\":\"8/0\",\"v\":125},"); b.append("{\"n\":\"8/1\",\"v\":900},"); b.append("{\"n\":\"9\",\"v\":100},"); b.append("{\"n\":\"10\",\"v\":15},"); b.append("{\"n\":\"11/0\",\"v\":0},"); b.append("{\"n\":\"13\",\"v\":1.3674912E9},"); b.append("{\"n\":\"14\",\"vs\":\"+02:00\"},"); b.append("{\"n\":\"16\",\"vs\":\"U\"}]"); String expected = b.toString(); Assert.assertEquals(expected, new String(encoded)); }</code><technical_language>[7.4.4.-2 sample](<LINK_0>, bn /3/0/ instead of /3/0. kind of issue current JSON implementation. (more relative #651)</technical_language>

Target:
public void senml_json_encode_device_object_instance() { LwM2mObjectInstance oInstance = new LwM2mObjectInstance(0, getDeviceResources()); byte[] encoded = LwM2mNodeSenMLJsonEncoder.encode(oInstance, new LwM2mPath("/3/0"), model, new DefaultLwM2mValueConverter()); StringBuilder b = new StringBuilder(); b.append("[{\"bn\":\"/3/0/\",\"n\":\"0\",\"vs\":\"Open Mobile Alliance\"},"); b.append("{\"n\":\"1\",\"vs\":\"Lightweight M2M Client\"},"); b.append("{\"n\":\"2\",\"vs\":\"345000123\"},"); b.append("{\"n\":\"3\",\"vs\":\"1.0\"},"); b.append("{\"n\":\"6/0\",\"v\":1},"); b.append("{\"n\":\"6/1\",\"v\":5},"); b.append("{\"n\":\"7/0\",\"v\":3800},"); b.append("{\"n\":\"7/1\",\"v\":5000},"); b.append("{\"n\":\"8/0\",\"v\":125},"); b.append("{\"n\":\"8/1\",\"v\":900},"); b.append("{\"n\":\"9\",\"v\":100},"); b.append("{\"n\":\"10\",\"v\":15},"); b.append("{\"n\":\"11/0\",\"v\":0},"); b.append("{\"n\":\"13\",\"v\":1.3674912E9},"); b.append("{\"n\":\"14\",\"vs\":\"+02:00\"},"); b.append("{\"n\":\"16\",\"vs\":\"U\"}]"); String expected = b.toString(); Assert.assertEquals(expected, new String(encoded)); }
Source:
<code>public void setup() throws Exception { initMocks(this); depositUUID = UUID.randomUUID().toString(); pid = new PID(depositUUID); eventType = Premis.VirusCheck; premisFile = File.createTempFile(depositUUID, ".ttl"); premisFile.deleteOnExit(); premis = new FilePremisLogger(pid, premisFile, repository); date = new Date(); <START> SoftwareAgentConstants.setCdrVersion("4.0-SNAPSHOT"); <END> when(repository.mintPremisEventUrl(any(PID.class))).thenAnswer(new Answer<String>() { @Override public String answer(InvocationOnMock invocation) throws Throwable { return "<LINK_0>" + UUID.randomUUID().toString(); } }); }</code><technical_language>is SNAPSHOT version hardcoded here? is this assumption this test make</technical_language>

Target:
public void setup() throws Exception { initMocks(this); depositUUID = UUID.randomUUID().toString(); pid = new PID(depositUUID); eventType = Premis.VirusCheck; premisFile = File.createTempFile(depositUUID, ".ttl"); premisFile.deleteOnExit(); premis = new FilePremisLogger(pid, premisFile, repository); date = new Date(); when(repository.mintPremisEventUrl(any(PID.class))).thenAnswer(new Answer<String>() { @Override public String answer(InvocationOnMock invocation) throws Throwable { return "<LINK_0>" + UUID.randomUUID().toString(); } }); }
Source:
<code>public Secret getPassword() { String appInstallationToken; synchronized (this) { try { if (cachedToken == null || cachedToken.isStale()) { LOGGER.log(Level.FINE, "Generating App Installation Token for app ID {0}", appID); cachedToken = generateAppInstallationToken(appID, privateKey.getPlainText(), actualApiUri(), owner); LOGGER.log(Level.FINER, "Retrieved GitHub App Installation Token for app ID {0}", appID); } } catch (Exception e) { if (cachedToken != null && !cachedToken.isExpired()) { LOGGER.log(Level.WARNING, <START> "Keeping cached GitHub App Installation Token for app ID {0}: token is stale but has not expired", appID); <END> } else { throw e; } } appInstallationToken = cachedToken.getToken(); } LOGGER.log(Level.FINEST, "Returned GitHub App Installation Token for app ID {0}", appID); return Secret.fromString(appInstallationToken); }</code><technical_language>nit: If log this a warning, I include exception diagnose problem: suggestion "Keeping cached GitHub App Installation Token for app ID " + appID + ": token is stale expired", e);</technical_language>

Target:
public Secret getPassword() { String appInstallationToken; synchronized (this) { try { if (cachedToken == null || cachedToken.isStale()) { LOGGER.log(Level.FINE, "Generating App Installation Token for app ID {0}", appID); cachedToken = generateAppInstallationToken(appID, privateKey.getPlainText(), actualApiUri(), owner); LOGGER.log(Level.FINER, "Retrieved GitHub App Installation Token for app ID {0}", appID); } } catch (Exception e) { if (cachedToken != null && !cachedToken.isExpired()) { LOGGER.log(Level.WARNING, "Failed to generate new GitHub App Installation Token for app ID " + appID + ": cached token is stale but has not expired", e); } else { throw e; } } appInstallationToken = cachedToken.getToken(); } LOGGER.log(Level.FINEST, "Returned GitHub App Installation Token for app ID {0}", appID); return Secret.fromString(appInstallationToken); }
Source:
<code>Map<SystemStreamPartition, String> getOldestOffsets() { Map<SystemStreamPartition, String> oldestOffsets = new HashMap<>(); Map<SystemStream, List<SystemStreamPartition>> systemStreamToSsp = sspsToStores.keySet().stream() .collect(Collectors.groupingBy(SystemStreamPartition::getSystemStream)); Map<SystemStream, SystemStreamMetadata> metadata = JavaConverters.mapAsJavaMapConverter( streamMetadataCache.getStreamMetadata( JavaConverters.asScalaSetConverter(systemStreamToSsp.keySet()).asScala().toSet(), false)).asJava(); metadata.forEach((systemStream, systemStreamMetadata) -> { Map<Partition, SystemStreamMetadata.SystemStreamPartitionMetadata> partitionMetadata = systemStreamMetadata.getSystemStreamPartitionMetadata(); <START> Map<SystemStreamPartition, String> offsets = new HashMap<>(); for (SystemStreamPartition ssp : systemStreamToSsp.get(systemStream)) { if (partitionMetadata == null || partitionMetadata.get(ssp.getPartition()) == null) { offsets.put(ssp, null); } else { offsets.put(ssp, partitionMetadata.get(ssp.getPartition()).getOldestOffset()); <END> } } oldestOffsets.putAll(offsets); }); return oldestOffsets; }</code><technical_language>This map redundant. put oldestOffsets</technical_language>

Target:
Map<SystemStreamPartition, String> getOldestOffsets() { Map<SystemStreamPartition, String> oldestOffsets = new HashMap<>(); Map<SystemStream, List<SystemStreamPartition>> systemStreamToSsp = sspsToStores.keySet().stream() .collect(Collectors.groupingBy(SystemStreamPartition::getSystemStream)); Map<SystemStream, SystemStreamMetadata> metadata = JavaConverters.mapAsJavaMapConverter( streamMetadataCache.getStreamMetadata( JavaConverters.asScalaSetConverter(systemStreamToSsp.keySet()).asScala().toSet(), false)).asJava(); metadata.forEach((systemStream, systemStreamMetadata) -> { Map<Partition, SystemStreamMetadata.SystemStreamPartitionMetadata> partitionMetadata = systemStreamMetadata.getSystemStreamPartitionMetadata(); for (SystemStreamPartition ssp : systemStreamToSsp.get(systemStream)) { oldestOffsets.put(ssp, partitionMetadata.get(ssp.getPartition()).getOldestOffset()); } }); return oldestOffsets; }
Source:
<code>public ImageInfo inspectImage(InspectImageParams params) throws IOException { String image = params.getImage(); <START> if (image.contains(":")) { END> image = image.replaceAll(":.*", ""); } String imageStreamTagName = KubernetesStringUtils.getTagNameFromRepoString(image); ImageStreamTag imageStreamTag = getImageStreamTagFromRepo(imageStreamTagName); return getImageInfoFromTag(imageStreamTag); }</code><technical_language>This code is duplicated in removeImage too. want extract a new method</technical_language>

Target:
public ImageInfo inspectImage(InspectImageParams params) throws IOException { String image = KubernetesStringUtils.getImageStreamNameFromPullSpec(params.getImage()); String imageStreamTagName = KubernetesStringUtils.convertPullSpecToTagName(image); ImageStreamTag imageStreamTag = getImageStreamTagFromRepo(imageStreamTagName); return getImageInfoFromTag(imageStreamTag); }
Source:
<code><START> public HostNetworkQos <END> getHostNetworkQosFromNetwork(Network network) { return network != null ? hostNetworkQosDao.get(network.getQosId()) : null; }</code><technical_language>public required</technical_language>

Target:
HostNetworkQos getHostNetworkQosFromNetwork(Network network) { return network != null ? hostNetworkQosDao.get(network.getQosId()) : null; }
Source:
<code>private <T> List<T> retrieveListOrSingleItem(List<T> list, T item) { if (list != null && list.size() > 0) { return list; } else if (item == null) { return new ArrayList<>(); } else { return Arrays.asList(item); <START> } <END> }</code><technical_language>this more readable cases switched</technical_language>

Target:
private <T> List<T> retrieveListOrSingleItem(List<T> list, T item) { if (list != null && list.size() > 0) { return list; } else if (item != null) { return Arrays.asList(item); } else { return new ArrayList<>(); } }
Source:
<code>public void testHuffmanIntHelper() throws IOException { <START> int size = 100; <END> HuffmanParamsCalculator cal = new HuffmanParamsCalculator(); for (int i = -300; i < 300; i++) { cal.add(i, 1+ (i + 300) / 3); } cal.calculate(); HuffmanIntHelper helper = new HuffmanIntHelper(cal.getValues(), cal.getBitLens()); ByteArrayOutputStream baos = new ByteArrayOutputStream(); DefaultBitOutputStream bos = new DefaultBitOutputStream(baos); for (int i = 0; i < size; i++) { for (int b : cal.getValues()) { helper.write(bos, b); } } bos.close(); ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); DefaultBitInputStream bis = new DefaultBitInputStream(bais); int counter = 0; for (int i = 0; i < size; i++) { for (int b : cal.getValues()) { int v = helper.read(bis); if (v != b) { Assert.fail("Mismatch: " + v + " vs " + b + " at " + counter); } counter++; } } }</code><technical_language>final int</technical_language>

Target:
public void testHuffmanIntHelper() throws IOException { final int size = 100; final HuffmanParamsCalculator cal = new HuffmanParamsCalculator(); for (int i = -300; i < 300; i++) { cal.add(i, 1+ (i + 300) / 3); } cal.calculate(); final HuffmanIntHelper helper = new HuffmanIntHelper(cal.getValues(), cal.getBitLens()); final ByteArrayOutputStream baos = new ByteArrayOutputStream(); final DefaultBitOutputStream bos = new DefaultBitOutputStream(baos); for (int i = 0; i < size; i++) { for (final int b : cal.getValues()) { helper.write(bos, b); } } bos.close(); final ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); final DefaultBitInputStream bis = new DefaultBitInputStream(bais); int counter = 0; for (int i = 0; i < size; i++) { for (final int b : cal.getValues()) { final int v = helper.read(bis); if (v != b) { Assert.fail("Mismatch: " + v + " vs " + b + " at " + counter); } counter++; } } }
Source:
<code>private double completePercentage() { int completed = 0; for (InflightMessage m : linkedMap.values()) { if (m.isComplete) completed ++; } <START> return ((double) completed) / ((double) linkedMap.size()); <END> }</code><technical_language>cast number double do</technical_language>

Target:
private double completePercentage() { long completed = linkedMap.values().stream().filter(m -> m.isComplete).count(); return completed / ((double) linkedMap.size()); }
Source:
<code>public VM get() { VM vm = performGet(VdcQueryType.GetVmByVmId, new GetVmByVmIdParameters(guid)); <START> return vm; <END> }</code><technical_language>moved code populate, reason get VM reference. change before</technical_language>

Target:
public VM get() { return performGet(VdcQueryType.GetVmByVmId, new GetVmByVmIdParameters(guid)); }
Source:
<code>public static String getVersion() { <START> return System.getProperty("java.vm.vendor", "UsNKNOWN_VM_VENDOR") + ' ' + <END> System.getProperty("java.version", "UNKNOWN_JAVA_VERSION") + '-' + System.getProperty("java.vm.version", "UNKNOWN_VM_VERSION"); }</code><technical_language>nit: typo UNKNOWN_VM_VENDOR</technical_language>

Target:
public static String getVersion() { return System.getProperty("java.vm.vendor", "UNKNOWN_VM_VENDOR") + ' ' + System.getProperty("java.version", "UNKNOWN_JAVA_VERSION") + '-' + System.getProperty("java.vm.version", "UNKNOWN_VM_VERSION"); }
Source:
<code>public synchronized ServletOutputStream getOutputStream() { checkState(writer == null, "getWriter() already called"); if (outputStream == null) { <START> final PrintWriter osWriter = new PrintWriter(actualBody); <END> outputStream = new ServletOutputStream() { @Override public void write(int c) throws IOException { osWriter.write(c); osWriter.flush(); } }; } return outputStream; }</code><technical_language>This necessary. write bytes actualBody</technical_language>

Target:
public synchronized ServletOutputStream getOutputStream() { checkState(writer == null, "getWriter() already called"); if (outputStream == null) { outputStream = new ServletOutputStream() { @Override public void write(int b) throws IOException { actualBody.write(b); } }; } return outputStream; }
Source:
<code>private JsonObject getHubConfiguration() throws Exception{ String hubApi = "http://" + nodeConfig.getConfiguration().get(RegistrationRequest.HUB_HOST) + ":" + nodeConfig.getConfiguration().get(RegistrationRequest.HUB_PORT) + "/grid/api/hub"; HttpClient client = httpClientFactory.getHttpClient(); URL api = new URL(hubApi); HttpHost host = new HttpHost(api.getHost(), api.getPort()); String url = api.toExternalForm(); BasicHttpEntityEnclosingRequest r = new BasicHttpEntityEnclosingRequest("GET", url); <START> HttpResponse response = client.execute(host, r); <END> return extractObject(response); }</code><technical_language>of a test failed this change</technical_language>

Target:
private JsonObject getHubConfiguration() throws Exception{ String hubApi = "http://" + nodeConfig.getConfiguration().get(RegistrationRequest.HUB_HOST) + ":" + nodeConfig.getConfiguration().get(RegistrationRequest.HUB_PORT) + "/grid/api/hub"; HttpClient client = httpClientFactory.getHttpClient(); URL api = new URL(hubApi); HttpHost host = new HttpHost(api.getHost(), api.getPort()); String url = api.toExternalForm(); BasicHttpRequest r = new BasicHttpRequest("GET", url); HttpResponse response = client.execute(host, r); return extractObject(response); }
Source:
<code>private static VariableAccessor buildAccessor( Config grants, String key, Config params, SecretProvider secretProvider) { if (grants.get(key, JsonNode.class).isObject()) { ConfigKey secretOnlyKey = grants.getNested(key).convert(SecretOnlyGrant.class).secret; return (required) -> { Optional<String> secret = secretProvider.getSecretOptional(secretOnlyKey.toString()); if (required && !secret.isPresent()) { throw new SecretNotFoundException(secretOnlyKey.toString()); } return secret.orNull(); }; } else { <START> ConfigKey secretSharedKey = grants.get(key, ConfigKey.class); <END> return (required) -> { Optional<String> secret = secretProvider.getSecretOptional(secretSharedKey.toString()); if (secret.isPresent()) { return secret.get(); } Config nested = params; for (String nestName : secretSharedKey.getNestNames()) { Optional<Config> optionalNested = nested.getOptionalNested(nestName); if (!optionalNested.isPresent()) { if (required) { throw new ConfigException("Nested object '" + nestName + "' out of " + secretSharedKey + " is required but not set"); } else { return null; } } nested = optionalNested.get(); } String value = nested.get(secretSharedKey.getLastName(), String.class, null); if (required && value == null) { throw new ConfigException("Nested object '" + secretSharedKey.getLastName() + "' out of " + secretSharedKey + " is required but not set"); } return value; }; } }</code><technical_language>a bit confused of word "shared". some name/wording more accurately describes here</technical_language>

Target:
private static VariableAccessor buildAccessor( Config grants, String key, Config params, SecretProvider secretProvider) { if (grants.get(key, JsonNode.class).isObject()) { ConfigKey secretOnlyKey = grants.getNested(key).convert(SecretOnlyGrant.class).secret; return (required) -> { Optional<String> secret = secretProvider.getSecretOptional(secretOnlyKey.toString()); if (required && !secret.isPresent()) { throw new SecretNotFoundException(secretOnlyKey.toString()); } return secret.orNull(); }; } else { ConfigKey secretKey = grants.get(key, ConfigKey.class); return (required) -> { Optional<String> secret = secretProvider.getSecretOptional(secretKey.toString()); if (secret.isPresent()) { return secret.get(); } Config nested = params; for (String nestName : secretKey.getNestNames()) { Optional<Config> optionalNested = nested.getOptionalNested(nestName); if (!optionalNested.isPresent()) { if (required) { throw new ConfigException("Nested object '" + nestName + "' out of " + secretKey + " is required but not set"); } else { return null; } } nested = optionalNested.get(); } String value = nested.get(secretKey.getLastName(), String.class, null); if (required && value == null) { throw new ConfigException("Nested object '" + secretKey.getLastName() + "' out of " + secretKey + " is required but not set"); } return value; }; } }
Source:
<code>private static byte[] createCryptoParameters(String version, Key encryptingKek, String encryptingKekId, String encryptingKeyManager, Key fek) { byte[] bytes; try (ByteArrayOutputStream baos = new ByteArrayOutputStream(); DataOutputStream params = new DataOutputStream(baos)) { <START> params.writeUTF("org.apache.accumulo.core.security.crypto.impl.AESCryptoService"); <END> params.writeUTF(version); params.writeUTF(encryptingKeyManager); params.writeUTF(encryptingKekId); byte[] wrappedFek = KeyManager.wrapKey(fek, encryptingKek); params.writeInt(wrappedFek.length); params.write(wrappedFek); bytes = baos.toByteArray(); } catch (IOException e) { throw new CryptoException("Error creating crypto params", e); } return bytes; }</code><technical_language>do AESCryptoService.class.getName()</technical_language>

Target:
private static byte[] createCryptoParameters(String version, Key encryptingKek, String encryptingKekId, String encryptingKeyManager, Key fek) { byte[] bytes; try (ByteArrayOutputStream baos = new ByteArrayOutputStream(); DataOutputStream params = new DataOutputStream(baos)) { params.writeUTF(AESCryptoService.class.getName()); params.writeUTF(version); params.writeUTF(encryptingKeyManager); params.writeUTF(encryptingKekId); byte[] wrappedFek = KeyManager.wrapKey(fek, encryptingKek); params.writeInt(wrappedFek.length); params.write(wrappedFek); bytes = baos.toByteArray(); } catch (IOException e) { throw new CryptoException("Error creating crypto params", e); } return bytes; }
Source:
<code>public boolean inputSet() { if (viewer == null) { return false; } final IBuildPlan plan = getPlan(); if (plan != null && refreshOperation == null) { GetBuildsRequest request = new GetBuildsRequest(plan, Kind.ALL, Scope.HISTORY); refreshOperation = new GetBuildsOperation(BuildsUiInternal.getFactory().getService(), request) { protected void schedule(List<BuildJob> jobs) { for (BuildJob job : jobs) { BuildHistoryPage.this.schedule(job); } } }; refreshOperation.addOperationChangeListener(new OperationChangeListener() { @Override public void done(OperationChangeEvent event) { <START> if (!event.getStatus().isOK()) { <END> refreshOperation = null; return; } if (Display.getDefault().isDisposed()) { refreshOperation = null; return; } final GetBuildsOperation operation = (GetBuildsOperation) event.getOperation(); Display.getDefault().asyncExec(new Runnable() { public void run() { if (viewer.getControl() != null && !viewer.getControl().isDisposed()) { List<IBuild> builds = operation.getBuilds(); if (builds != null) { for (IBuild build : builds) { build.setPlan(plan); build.setServer(plan.getServer()); } viewer.setInput(builds); } } } }); refreshOperation = null; } }); refreshOperation.execute(); return true; } return false; }</code><technical_language>work if set refreshOperation = null line of done()</technical_language>

Target:
public boolean inputSet() { if (viewer == null) { return false; } final IBuildPlan plan = getPlan(); if (plan != null && refreshOperation == null) { GetBuildsRequest request = new GetBuildsRequest(plan, Kind.ALL, Scope.HISTORY); refreshOperation = new GetBuildsOperation(BuildsUiInternal.getFactory().getService(), request) { protected void schedule(List<BuildJob> jobs) { for (BuildJob job : jobs) { BuildHistoryPage.this.schedule(job); } } }; refreshOperation.addOperationChangeListener(new OperationChangeListener() { @Override public void done(OperationChangeEvent event) { if (event.getStatus().isOK() && !Display.getDefault().isDisposed()) { final GetBuildsOperation operation = (GetBuildsOperation) event.getOperation(); Display.getDefault().asyncExec(new Runnable() { public void run() { if (viewer.getControl() != null && !viewer.getControl().isDisposed()) { List<IBuild> builds = operation.getBuilds(); if (builds != null) { for (IBuild build : builds) { build.setPlan(plan); build.setServer(plan.getServer()); } viewer.setInput(builds); } } } }); } refreshOperation = null; } }); refreshOperation.execute(); return true; } return false; }
Source:
<code>void put(SystemStreamPartition ssp, IncomingMessageEnvelope envelope) { List<IncomingMessageEnvelope> messages = bufferedMessages.get(ssp); String offset = String.valueOf(messages.size()); <START> if (!envelope.getOffset().equals(offset)) { <END> throw new SamzaException( String.format("Offset mismatch for ssp %s, expected %s found %s, please set the correct offset", ssp, offset, envelope.getOffset())); } bufferedMessages.get(ssp).add(envelope); }</code><technical_language>great if check if envelope.getOffset() is null</technical_language>

Target:
void put(SystemStreamPartition ssp, IncomingMessageEnvelope envelope) { Preconditions.checkNotNull(envelope); Preconditions.checkNotNull(envelope.getOffset()); List<IncomingMessageEnvelope> messages = bufferedMessages.get(ssp); String offset = String.valueOf(messages.size()); if (!envelope.getOffset().equals(offset)) { throw new SamzaException( String.format("Offset mismatch for ssp %s, expected %s found %s, please set the correct offset", ssp, offset, envelope.getOffset())); } bufferedMessages.get(ssp).add(envelope); }