auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code><START> public static Collection<Object[]> data() { <END> return Arrays.asList(new Object[][] { { "plaintext", Config.build().withEncryptionLevel( Config.EncryptionLevel.NONE ) }, { "tls encrypted", Config.build().withEncryptionLevel( Config.EncryptionLevel.REQUIRED ) } }); }</code><technical_language>this method return a collection of Config.EncryptionLevel? I code simpler - need for testName constructor argument flat list of Config.EncryptionLevel returned</technical_language>

Target:
public static Collection<Object[]> data() { return Arrays.asList(new Object[][] { { "plaintext", Config.EncryptionLevel.NONE }, { "tls encrypted", Config.EncryptionLevel.REQUIRED } }); }
Source:
<code>public final synchronized void mark(int readlimit) { try { <START> mark = OptionalLong.of(position()); <END> } catch (IOException e) { } }</code><technical_language>in reviewing this concerned scenario position legitimately throws exception causing mark remain un-updated. In this cas, due catch, lead a silent error. ways this: 1. throw unchecked exception instead 2. specific exceptions thrown current implementations work 3. modify contract for position() throw, simultaneously modify implementations. if other solutions, please discuss</technical_language>

Target:
public final synchronized void mark(int readlimit) { try { mark = OptionalLong.of(position()); } catch (final ClosedChannelException e) { } catch (final IOException e) { throw new RuntimeIOException(e); } }
Source:
<code>public void testAbandonChange() throws Exception { String message1 = "abandon, time: " + System.currentTimeMillis(); ChangeDetail changeDetail = reviewHarness.getClient().abandon(reviewHarness.getShortId(), 1, message1, new NullProgressMonitor()); reviewHarness.retrieve(); assertThat(changeDetail, notNullValue()); assertThat(changeDetail.getChange().getStatus(), is(Status.ABANDONED)); List<ChangeMessage> messages = changeDetail.getMessages(); <START> int offset = COMMENT_OFFSET; <END> assertThat(messages.size(), is(offset + 1)); ChangeMessage lastMessage = messages.get(offset + 0); assertThat(lastMessage.getAuthor().get(), is(1000001)); assertThat(lastMessage.getMessage(), endsWith("Abandoned\n\n" + message1)); assertThat(getReview().getState(), is(ReviewStatus.ABANDONED)); List<IComment> comments = getReview().getComments(); assertThat(comments.size(), is(offset + 1)); IComment lastComment = comments.get(offset + 0); assertThat(lastComment.getAuthor().getDisplayName(), is("tests")); assertThat(lastComment.getAuthor().getId(), is("1000001")); assertThat(lastComment.getDescription(), endsWith("Abandoned\n\n" + message1)); }</code><technical_language>I get rid of constant local variable write e.g. 2 instead of offset+1</technical_language>

Target:
public void testAbandonChange() throws Exception { String message1 = "abandon, time: " + System.currentTimeMillis(); ChangeDetail changeDetail = reviewHarness.getClient().abandon(reviewHarness.getShortId(), 1, message1, new NullProgressMonitor()); reviewHarness.retrieve(); assertThat(changeDetail, notNullValue()); assertThat(changeDetail.getChange().getStatus(), is(Status.ABANDONED)); List<ChangeMessage> messages = changeDetail.getMessages(); assertThat(messages.size(), is(2)); ChangeMessage lastMessage = messages.get(1); assertThat(lastMessage.getAuthor().get(), is(1000001)); assertThat(lastMessage.getMessage(), endsWith("Abandoned\n\n" + message1)); assertThat(getReview().getState(), is(ReviewStatus.ABANDONED)); List<IComment> comments = getReview().getComments(); assertThat(comments.size(), is(2)); IComment lastComment = comments.get(1); assertThat(lastComment.getAuthor().getDisplayName(), is("tests")); assertThat(lastComment.getAuthor().getId(), is("1000001")); assertThat(lastComment.getDescription(), endsWith("Abandoned\n\n" + message1)); }
Source:
<code>public void setDepth(int depth) { int[] allowedValues = {2, 4, 8, 16, 32, 64, 256, 4096}; for (int i = 0; i < allowedValues.length; i++) { if(depth == allowedValues[i]) { this.depth = depth; return; } } <START> throw new IllegalArgumentException("Invalid depth value"); <END> }</code><technical_language>Please values in Exception message</technical_language>

Target:
public void setDepth(int depth) { int[] allowedValues = {2, 4, 8, 16, 32, 64, 256, 4096}; for (int i = 0; i < allowedValues.length; i++) { if(depth == allowedValues[i]) { this.depth = depth; return; } } throw new IllegalArgumentException("Invalid depth value. Valid values are 2, 4, 8, 16, 32, 64, 256, 4096."); }
Source:
<code>private boolean isFeatureSupportedAsAdditionalFeature(Guid clusterId, String featureName) { <START> Set<SupportedAdditionalClusterFeature> addtionalFeaturesSupported = clusterFeatureDao.getSupportedFeaturesByClusterId(clusterId); for (SupportedAdditionalClusterFeature supportedFeature : addtionalFeaturesSupported) { if (supportedFeature.getFeature().getName().equalsIgnoreCase(featureName)) { return supportedFeature.isEnabled(); } } <END> return false; }</code><technical_language>more expressive in functional form? clusterFeatureDao.getSupportedFeaturesByClusterId(clusterId).stream() .filter(SupportedAdditionalClusterFeature::isEnabled) .filter(f -> f.getFeature().getName().equals(featureName)) .findAny() .isPresent();</technical_language>

Target:
private boolean isFeatureSupportedAsAdditionalFeature(Guid clusterId, String featureName) { return clusterFeatureDao.getSupportedFeaturesByClusterId(clusterId).stream() .filter(SupportedAdditionalClusterFeature::isEnabled) .filter(f -> f.getFeature().getName().equals(featureName)) .findAny() .isPresent(); }
Source:
<code>public synchronized File getHibernateFile(String hibernateFileName) throws PropertyAccessException { checkEnvVarSet(); LOG.debug("Checking the hibernate file."); <START> String path = propertyFileDir + File.separator + "hibernate" + File.separator + hibernateFileName; <END> LOG.info(path); File result = new File(path); if (!result.exists()) { throw new PropertyAccessException("Unable to locate " + result); } return result; }</code><technical_language>Recommend StringBuilder concatenate string</technical_language>

Target:
public synchronized File getHibernateFile(String hibernateFileName) throws PropertyAccessException { checkEnvVarSet(); LOG.debug("Checking the hibernate file."); StringBuilder builder = new StringBuilder(); builder.append(propertyFileDir); builder.append(File.separator); builder.append("hibernate"); builder.append(File.separator); builder.append(hibernateFileName); String path = builder.toString(); LOG.info("Hibernate file path is: ", path); File result = new File(path); if (!result.exists()) { throw new PropertyAccessException("Unable to locate " + result); } return result; }
Source:
<code>public Iterator<ObjectNode> convertObject(InputStream csvSource) throws IOException { <START> CountInputStream countInputStream = new CountInputStream(csvSource); <END> CsvSchema firstLineSchema = CsvSchema.emptySchema().withHeader(); Iterator<ObjectNode> objectItr = csvMapper.readerFor(ObjectNode.class).with(firstLineSchema) .readValues(countInputStream); return objectItr; }</code><technical_language>this line assign field instead of a local variable CSVConverter.getByteCount() method calls this instance of CountInputStream</technical_language>

Target:
public Iterator<ObjectNode> convertObject(InputStream csvSource) throws IOException { this.countInputStream = new CountInputStream(csvSource); CsvSchema firstLineSchema = CsvSchema.emptySchema().withHeader(); Iterator<ObjectNode> objectItr = csvMapper.readerFor(ObjectNode.class).with(firstLineSchema) .readValues(this.countInputStream); return objectItr; }
Source:
<code>public boolean isSatisfied(CommandContext ctx) { if(satisfied == null) { satisfied = checkAccess(ctx); if(log.isTraceEnabled()) { log.trace(toString() + " " + satisfied); <START> } <END> } return satisfied; }</code><technical_language>Nit: this a line log.tracef("%s %s", this, satisfied);</technical_language>

Target:
public boolean isSatisfied(CommandContext ctx) { if(satisfied == null) { satisfied = checkAccess(ctx); log.tracef("%s %s", this, satisfied); } return satisfied; }
Source:
<code><START> public void setBufferLineLimit(int bufferLines) { <END> if (bufferLines >= MIN_LOW_LINES_WATER_MARK) { int chars = bufferLines * CHARS_PER_LINE_AVG; setWaterMarks(chars, chars + LOW_TO_HIGH_BUFFER_CHARS_OFFSET); } }</code><technical_language>discussed, high watermark - buffer's size more constant, instead of varying 2 sizes. get rid of check of minimal number of lines buffer , check is done in preferences page</technical_language>

Target:
public void setBufferLineLimit(int bufferLines) { int chars = bufferLines * CHARS_PER_LINE_AVG; setWaterMarks(chars, chars); }
Source:
<code>private Set<FileRef> removeSmallest(Map<FileRef,DataFileValue> filesToCompact, int maxFilesToCompact) { if (filesToCompact.size() <= maxFilesToCompact) { <START> Set<FileRef> smallestFiles = new HashSet<FileRef>(filesToCompact.size()); <END> for (Iterator<FileRef> iterator = filesToCompact.keySet().iterator(); iterator.hasNext();) { smallestFiles.add(iterator.next()); iterator.remove(); } return smallestFiles; } PriorityQueue<Pair<FileRef,Long>> fileHeap = new PriorityQueue<Pair<FileRef,Long>>(filesToCompact.size(), new Comparator<Pair<FileRef,Long>>() { @Override public int compare(Pair<FileRef,Long> o1, Pair<FileRef,Long> o2) { if (o1.getSecond() == o2.getSecond()) return o1.getFirst().compareTo(o2.getFirst()); if (o1.getSecond() < o2.getSecond()) return -1; return 1; } }); for (Iterator<Entry<FileRef,DataFileValue>> iterator = filesToCompact.entrySet().iterator(); iterator.hasNext();) { Entry<FileRef,DataFileValue> entry = iterator.next(); fileHeap.add(new Pair<FileRef,Long>(entry.getKey(), entry.getValue().getSize())); } Set<FileRef> smallestFiles = new HashSet<FileRef>(); while (smallestFiles.size() < maxFilesToCompact && fileHeap.size() > 0) { Pair<FileRef,Long> pair = fileHeap.remove(); filesToCompact.remove(pair.getFirst()); smallestFiles.add(pair.getFirst()); } return smallestFiles; }</code><technical_language>do java Set<FileRef> smallestFiles = new HashSet<FileRef>(filesToCompact.keySet()); filesToCompact.clear(); return smallestFiles; slightly easier read for loop</technical_language>

Target:
private Set<FileRef> removeSmallest(Map<FileRef,DataFileValue> filesToCompact, int maxFilesToCompact) { if (filesToCompact.size() <= maxFilesToCompact) { Set<FileRef> smallestFiles = new HashSet<FileRef>(filesToCompact.keySet()); filesToCompact.clear(); return smallestFiles; } PriorityQueue<Pair<FileRef,Long>> fileHeap = new PriorityQueue<Pair<FileRef,Long>>(filesToCompact.size(), new Comparator<Pair<FileRef,Long>>() { @Override public int compare(Pair<FileRef,Long> o1, Pair<FileRef,Long> o2) { if (o1.getSecond() == o2.getSecond()) return o1.getFirst().compareTo(o2.getFirst()); if (o1.getSecond() < o2.getSecond()) return -1; return 1; } }); for (Iterator<Entry<FileRef,DataFileValue>> iterator = filesToCompact.entrySet().iterator(); iterator.hasNext();) { Entry<FileRef,DataFileValue> entry = iterator.next(); fileHeap.add(new Pair<FileRef,Long>(entry.getKey(), entry.getValue().getSize())); } Set<FileRef> smallestFiles = new HashSet<FileRef>(); while (smallestFiles.size() < maxFilesToCompact && fileHeap.size() > 0) { Pair<FileRef,Long> pair = fileHeap.remove(); filesToCompact.remove(pair.getFirst()); smallestFiles.add(pair.getFirst()); } return smallestFiles; }
Source:
<code>private List<Cookie> get(String domain, String path, boolean secure) { final boolean[] removeExpired = {false}; <START> final List<Cookie> results = new ArrayList<>(); <END> boolean exactDomainMatch = true; String subDomain = domain; while (MiscUtils.isNonEmpty(subDomain)) { results.addAll(getStoredCookies(subDomain, path, secure, removeExpired, exactDomainMatch)); exactDomainMatch = false; subDomain = DomainUtils.getSubDomain(subDomain); } return results; }</code><technical_language>Please reduce allocations here. Default ArrayList size is 10, pretty get more 2 cookies for a domain. Also, allocated lazily match (lots of AHC usage involve cookies all)</technical_language>

Target:
private List<Cookie> get(String domain, String path, boolean secure) { boolean exactDomainMatch = true; String subDomain = domain; List<Cookie> results = null; while (MiscUtils.isNonEmpty(subDomain)) { final List<Cookie> storedCookies = getStoredCookies(subDomain, path, secure, exactDomainMatch); subDomain = DomainUtils.getSubDomain(subDomain); exactDomainMatch = false; if (storedCookies.isEmpty()) { continue; } if (results == null) { results = new ArrayList<>(4); } results.addAll(storedCookies); } return results == null ? Collections.emptyList() : results; }
Source:
<code>private X509ExtendedTrustManager getX509ExtendedTrustManager() { TrustManagerFactory factory; try { factory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); factory.init((KeyStore) null); } catch (NoSuchAlgorithmException nsae) { <START> log.error("Unable to initialize default TrustManagerFactory, using no-op X509ExtendedTrustManager", nsae); <END> return getNoOpInstance(); } catch (KeyStoreException nse) { log.error("Unable to initialize default TrustManagerFactory, using no-op X509ExtendedTrustManager", nse); return getNoOpInstance(); } for (TrustManager tm: factory.getTrustManagers()) { if (tm instanceof X509ExtendedTrustManager) { return (X509ExtendedTrustManager) tm; } } log.debug("No default X509TrustManager found, using no-op"); return getNoOpInstance(); }</code><technical_language>Do scenarios result in NoSuchAlgorithmException KeyStoreException? essentially disabling hostname verification if of excecptions occur, a no-op instance, is right</technical_language>

Target:
private X509ExtendedTrustManager getX509ExtendedTrustManager() { TrustManagerFactory factory; try { factory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); factory.init((KeyStore) null); } catch (NoSuchAlgorithmException nsae) { throw new RuntimeException("Unable to initialize default TrustManagerFactory", nsae); } catch (KeyStoreException nse) { throw new RuntimeException("Unable to initialize default TrustManagerFactory", nse); } for (TrustManager tm: factory.getTrustManagers()) { if (tm instanceof X509ExtendedTrustManager) { return (X509ExtendedTrustManager) tm; } } throw new RuntimeException("No default X509TrustManager found"); }
Source:
<code>protected void configureServlets() { filter("/").through(OAuthWebFilter.class); filter("/login").through(OAuthWebFilter.class); filter("/oauth").through(OAuthWebFilter.class); <START> bind(HttpClient.class).toProvider(PooledHttpClientProvider.class); <END> }</code><technical_language>This is missing .in(Scopes.SINGLETON)</technical_language>

Target:
protected void configureServlets() { filter("/").through(OAuthWebFilter.class); filter("/login").through(OAuthWebFilter.class); filter("/oauth").through(OAuthWebFilter.class); bind(HttpClient.class).toProvider(PooledHttpClientProvider.class).in( Scopes.SINGLETON); }
Source:
<code>protected RevCommit findHead(Repository repo) { try (RevWalk walk = new RevWalk(repo)) { try { ObjectId head = repo.resolve(HEAD); return walk.parseCommit(head); <START> } catch (RevisionSyntaxException e) { <END> throw new RuntimeException(e); } catch (AmbiguousObjectException e) { throw new RuntimeException(e); } catch (IncorrectObjectTypeException e) { throw new RuntimeException(e); } catch (IOException e) { throw new RuntimeException(e); } } }</code><technical_language>handle exceptions in multi-catch: } catch (RevisionSyntaxException | AmbiguousObjectException | IncorrectObjectTypeException | IOException e) {</technical_language>

Target:
protected RevCommit findHead(Repository repo) { try (RevWalk walk = new RevWalk(repo)) { try { ObjectId head = repo.resolve(HEAD); return walk.parseCommit(head); } catch (RevisionSyntaxException | IOException e) { throw new RuntimeException(e); } } }
Source:
<code>public String getRequestTokenEndpoint() { <START> return null; <END> }</code><technical_language>return null. Instead throw exception, like: throw new OAuthException("Echo Api supports legged OAuth calls");</technical_language>

Target:
public String getRequestTokenEndpoint() { throw new OAuthException("Echo API only supports 2-legged OAuth calls"); }
Source:
<code>public void stop() { _runningTasks.values().forEach(AbstractKafkaBasedConnectorTask::stop); <START> _daemonThreadExecutorService.shutdown(); <END> _runningTasks.clear(); _taskThreads.clear(); _logger.info("stopped."); }</code><technical_language>shutdown daemon thread stop task threads</technical_language>

Target:
public void stop() { _daemonThreadExecutorService.shutdown(); _runningTasks.values().forEach(AbstractKafkaBasedConnectorTask::stop); _runningTasks.clear(); _taskThreads.clear(); _logger.info("stopped."); }
Source:
<code>public static MessageValues serializePayload(Message<?> message) { Object originalPayload = message.getPayload(); boolean setOriginalContentType = (originalPayload instanceof String); Assert.isTrue(originalPayload instanceof byte[] || originalPayload instanceof String, "Failed to convert message's payload. No suitable converter found for provided contentType: " + message.getHeaders().get(MessageHeaders.CONTENT_TYPE) + " and paylod: " + originalPayload); Object originalContentType = message.getHeaders().get(MessageHeaders.CONTENT_TYPE); String contentType = setOriginalContentType ? JavaClassMimeTypeUtils.mimeTypeFromObject(originalPayload, <START> ObjectUtils.nullSafeToString(originalContentType)).toString() : originalContentType.toString() ; <END> Object payload = originalPayload instanceof byte[] ? originalPayload : ((String) originalPayload).getBytes(StandardCharsets.UTF_8); MessageValues messageValues = new MessageValues(message); messageValues.setPayload(payload); messageValues.put(MessageHeaders.CONTENT_TYPE, contentType); if (originalContentType != null && !originalContentType.toString().equals(contentType.toString())) { messageValues.put(BinderHeaders.BINDER_ORIGINAL_CONTENT_TYPE, originalContentType.toString()); } return messageValues; }</code><technical_language>This throws NPE originalContentType is null setOriginalContentType is false</technical_language>

Target:
public static MessageValues serializePayload(Message<?> message) { Object originalPayload = message.getPayload(); boolean setOriginalContentType = (originalPayload instanceof String); Assert.isTrue(originalPayload instanceof byte[] || originalPayload instanceof String, "Failed to convert message's payload. No suitable converter found for provided contentType: " + message.getHeaders().get(MessageHeaders.CONTENT_TYPE) + " and paylod: " + originalPayload); Object originalContentType = message.getHeaders().get(MessageHeaders.CONTENT_TYPE); String contentType = null; if (originalContentType != null) { contentType = setOriginalContentType ? JavaClassMimeTypeUtils.mimeTypeFromObject(originalPayload, ObjectUtils.nullSafeToString(originalContentType)).toString() : originalContentType.toString() ; } Object payload = originalPayload instanceof byte[] ? originalPayload : ((String) originalPayload).getBytes(StandardCharsets.UTF_8); MessageValues messageValues = new MessageValues(message); messageValues.setPayload(payload); if (StringUtils.hasText(contentType)) { messageValues.put(MessageHeaders.CONTENT_TYPE, contentType); if (originalContentType != null && !originalContentType.toString().equals(contentType.toString())) { messageValues.put(BinderHeaders.BINDER_ORIGINAL_CONTENT_TYPE, originalContentType.toString()); } } return messageValues; }
Source:
<code>public void setup() { context.turnOffAuthorisationSystem(); parentCommunity = CommunityBuilder.createCommunity(context).withName("test").build(); <START> collection = CollectionBuilder.createCollection(context, parentCommunity).withName("Collection 1").build(); <END> }</code><technical_language>Please do *not* leave authorization turned test methods. This result in unexpected behavior. temporarily turned create (or delete) test content</technical_language>

Target:
public void setup() { context.turnOffAuthorisationSystem(); parentCommunity = CommunityBuilder.createCommunity(context).withName("test").build(); collection = CollectionBuilder.createCollection(context, parentCommunity).withName("Collection 1").build(); context.restoreAuthSystemState(); }
Source:
<code>public void validate() { if (clustering().cacheMode().isReplicated()) { <START> log.warnPartitionHandlingForReplicatedCaches(); <END> } }</code><technical_language>need log this if partition handling is enabled, else get a lot of warning spam I think</technical_language>

Target:
public void validate() { if (enabled && clustering().cacheMode().isReplicated()) { log.warnPartitionHandlingForReplicatedCaches(); } }
Source:
<code>public static int getBuf(FSDataInputStream f, ByteBuffer readBuf, int maxSize) throws IOException { int res = 0; if (useV21) { try { res = (Integer) invoke(fileAPI.PROVIDE_BUF_READ_METHOD, "Unexpected error reading into a ByteBuffer", readBuf); }catch (UnsupportedOperationException e) { } } else { byte[] buf = new byte[maxSize]; res = f.read(buf); readBuf.put(buf, 0, maxSize); } if (res == 0) { <START> throw new EOFException("Null ByteBuffer returned"); <END> } return res; }</code><technical_language>this lose original of error</technical_language>

Target:
public static int getBuf(FSDataInputStream f, ByteBuffer readBuf, int maxSize) throws IOException { int res; if (useV21) { try { res = (Integer) fileAPI.PROVIDE_BUF_READ_METHOD.invoke(f, readBuf); } catch (InvocationTargetException e) { if (e.getCause() instanceof UnsupportedOperationException) { useV21 = false; return getBuf(f, readBuf, maxSize); } else if (e.getCause() instanceof IOException) { throw (IOException) e.getCause(); } else { throw new IOException("Error reading out of an FSDataInputStream " + "using the Hadoop 2 ByteBuffer based read method.", e.getCause()); } } catch (IllegalAccessException e) { throw new ShouldNeverHappenException(e); } } else { byte[] buf = new byte[maxSize]; res = f.read(buf); readBuf.put(buf, 0, res); } return res; }
Source:
<code><START> synchronized Map<QueryId, Map<String, Long>> getTaggedMemoryAllocations() <END> { Map<QueryId, Map<String, Long>> queryIdMap = new HashMap<>(); taggedMemoryAllocations.forEach( (queryId, memoryAllocations) -> { queryIdMap.put( queryId, memoryAllocations.entrySet() .stream() .filter(entry -> !entry.getKey().equals(FORCE_FREE_TAG)) .collect(Collectors.toMap(map -> map.getKey(), map -> map.getValue()))); }); return ImmutableMap.copyOf(queryIdMap); }</code><technical_language>This is expensive. change this getTaggedMemoryAllocations(queryId) instead. If tests easy fix, introduce a separate function instead this (with implementation) is in tests</technical_language>

Target:
synchronized Map<QueryId, Map<String, Long>> getTaggedMemoryAllocations() { return taggedMemoryAllocations.keySet().stream() .collect(toImmutableMap(identity(), this::getTaggedMemoryAllocations)); }
Source:
<code>public synchronized <T> T bridgeCommunicate(BridgeCommunicationProtocol<T> communication, boolean useAuthentication) { logger.trace("bridgeCommunicate({},{}authenticated) called.", communication.name(), useAuthentication ? "" : "un"); if (!isAuthenticated()) { if (useAuthentication) { logger.trace("bridgeCommunicate(): no auth token available, aborting."); return null; } else { <START> logger.trace("bridgeCommunicate(): no auth token available, continueing."); <END> } } String sapURL = configuration.bridgeProtocol.concat("://").concat(configuration.bridgeIPAddress).concat(":") .concat(Integer.toString(configuration.bridgeTCPPort)).concat(communication.getURL()); logger.trace("bridgeCommunicate(): using SAP {}.", sapURL); Object getRequest = communication.getObjectOfRequest(); Class<T> classOfResponse = communication.getClassOfResponse(); T response; try { if (useAuthentication) { response = ioAuthenticated(sapURL, authenticationToken, getRequest, classOfResponse); } else { response = ioUnauthenticated(sapURL, getRequest, classOfResponse); } logger.trace("bridgeCommunicate(): communication result is {}, returning details.", communication.isCommunicationSuccessful(response)); return response; } catch (IOException ioe) { logger.info("bridgeCommunicate(): Exception occurred on accessing {}: {}.", sapURL, ioe.getMessage()); return null; } catch (JsonSyntaxException jse) { logger.info("bridgeCommunicate(): Exception occurred on (de-)serialization during accessing {}: {}.", sapURL, jse.getMessage()); return null; } }</code><technical_language>"continuing"</technical_language>

Target:
public synchronized <T> T bridgeCommunicate(BridgeCommunicationProtocol<T> communication, boolean useAuthentication) { logger.trace("bridgeCommunicate({},{}authenticated) called.", communication.name(), useAuthentication ? "" : "un"); if (!isAuthenticated()) { if (useAuthentication) { logger.trace("bridgeCommunicate(): no auth token available, aborting."); return null; } else { logger.trace("bridgeCommunicate(): no auth token available, continuing."); } } String sapURL = configuration.bridgeProtocol.concat("://").concat(configuration.bridgeIPAddress).concat(":") .concat(Integer.toString(configuration.bridgeTCPPort)).concat(communication.getURL()); logger.trace("bridgeCommunicate(): using SAP {}.", sapURL); Object getRequest = communication.getObjectOfRequest(); Class<T> classOfResponse = communication.getClassOfResponse(); T response; try { if (useAuthentication) { response = ioAuthenticated(sapURL, authenticationToken, getRequest, classOfResponse); } else { response = ioUnauthenticated(sapURL, getRequest, classOfResponse); } logger.trace("bridgeCommunicate(): communication result is {}, returning details.", communication.isCommunicationSuccessful(response)); return response; } catch (IOException ioe) { logger.info("bridgeCommunicate(): Exception occurred on accessing {}: {}.", sapURL, ioe.getMessage()); return null; } catch (JsonSyntaxException jse) { logger.info("bridgeCommunicate(): Exception occurred on (de-)serialization during accessing {}: {}.", sapURL, jse.getMessage()); return null; } }
Source:
<code>public boolean hasAnyTicket(String username) { <START> Collection<Ticket> tickets = ticketRepository.findAllByOwnerUsername(username); <END> return tickets.stream().anyMatch(Ticket::isValid); }</code><technical_language>I turn this in a one-liner</technical_language>

Target:
public boolean hasAnyTicket(String username) { return ticketRepository.findAllByOwnerUsername(username).stream().anyMatch(Ticket::isValid); }
Source:
<code>public void testContentTypeConfigurer() throws Exception { final CountDownLatch latch = new CountDownLatch(1); testSink.input().subscribe(new MessageHandler() { @Override public void handleMessage(Message<?> message) throws MessagingException { Assert.isTrue(message.getPayload() instanceof Tuple); Assert.isTrue(((Tuple)message.getPayload()).getFieldNames().get(0).equals("message")); Assert.isTrue(((Tuple) message.getPayload()).getValue(0).equals("Hi")); latch.countDown(); } }); testSource.output().send(MessageBuilder.withPayload("{\"message\":\"Hi\"}").build()); <START> latch.await(10, TimeUnit.SECONDS); <END> }</code><technical_language>Needs assertTrue(...)</technical_language>

Target:
public void testContentTypeConfigurer() throws Exception { final CountDownLatch latch = new CountDownLatch(1); MessageHandler messageHandler = new MessageHandler() { @Override public void handleMessage(Message<?> message) throws MessagingException { assertTrue(message.getPayload() instanceof Tuple); assertTrue(((Tuple) message.getPayload()).getFieldNames().get(0).equals("message")); assertTrue(((Tuple) message.getPayload()).getValue(0).equals("Hi")); latch.countDown(); } }; testSink.input().subscribe(messageHandler); testSource.output().send(MessageBuilder.withPayload("{\"message\":\"Hi\"}").build()); latch.await(10, TimeUnit.SECONDS); assertTrue(latch.getCount() == 0); testSink.input().unsubscribe(messageHandler); }
Source:
<code>private void extendDiskImageSize() { lockImageInDb(); <START> VdcReturnValueBase ret = getBackend().runInternalAction( <END> VdcActionType.ExtendImageSize, createExtendImageSizeParameters(), ExecutionHandler.createDefaultContexForTasks(getExecutionContext()) ); if (ret.getSucceeded()) { getReturnValue().getTaskIdList().addAll(ret.getInternalTaskIdList()); } else { propagateInternalCommandFailure(ret); unlockImageInDb(); getReturnValue().setFault(ret.getFault()); } setSucceeded(ret.getSucceeded()); }</code><technical_language>CDA messages of extend displayed in CDA phase</technical_language>

Target:
private void extendDiskImageSize() { lockImageInDb(); VdcReturnValueBase ret = getBackend().runInternalAction( VdcActionType.ExtendImageSize, createExtendImageSizeParameters(), ExecutionHandler.createDefaultContexForTasks(getExecutionContext()) ); if (ret.getSucceeded()) { getReturnValue().getTaskIdList().addAll(ret.getInternalTaskIdList()); } else { propagateInternalCommandFailure(ret); getReturnValue().setFault(ret.getFault()); } setSucceeded(ret.getSucceeded()); }
Source:
<code>public void testParseDateWithIncorrectWeekday() { <START> GregorianCalendar exp1 = new GregorianCalendar(2014, 9, 8, 9, 00, 00); <END> exp1.setTimeZone(TimeZone.getTimeZone("GMT")); Date expected = new Date(exp1.getTimeInMillis()); Date actual = DateUtils.parse("Thu, 8 Oct 2014 09:00:00 GMT"); assertEquals(expected, actual); }</code><technical_language>Intellij warns 00 is octal. a problem avoid warnings writing a single 0</technical_language>

Target:
public void testParseDateWithIncorrectWeekday() { GregorianCalendar exp1 = new GregorianCalendar(2014, 9, 8, 9, 0, 0); exp1.setTimeZone(TimeZone.getTimeZone("GMT")); Date expected = new Date(exp1.getTimeInMillis()); Date actual = DateUtils.parse("Thu, 8 Oct 2014 09:00:00 GMT"); assertEquals(expected, actual); }
Source:
<code>public static Application rebind(LocalManagementContext newManagementContext, ClassLoader classLoader, RebindExceptionHandler exceptionHandler) throws Exception { <START> Collection<Application> newApps = rebindAll(newManagementContext, classLoader, null); <END> if (newApps.isEmpty()) throw new IllegalStateException("Application could not be rebinded; serialization probably failed"); return Iterables.getFirst(newApps, null); }</code><technical_language>Passing null exceptionHandler argument</technical_language>

Target:
public static Application rebind(LocalManagementContext newManagementContext, ClassLoader classLoader, RebindExceptionHandler exceptionHandler) throws Exception { Collection<Application> newApps = rebindAll(newManagementContext, classLoader, exceptionHandler); if (newApps.isEmpty()) throw new IllegalStateException("Application could not be rebinded; serialization probably failed"); return Iterables.getFirst(newApps, null); }
Source:
<code><START> public ACHBank(String fileData) { <END> setBankRoutingNumber(getField(fileData, 1, 9)); setBankOfficeCode(getField(fileData, 10, 1)); setBankServiceNumber(getField(fileData, 11, 9)); setBankTypeCode(getField(fileData, 20, 1)); setBankNewRoutingNumber(getField(fileData, 27, 9)); setBankName(getField(fileData, 36, 36)); setBankStreetAddress(getField(fileData, 72, 36)); setBankCityName(getField(fileData, 108, 20)); setBankStateCode(getField(fileData, 128, 2)); setBankZipCode(getField(fileData, 130, 5)); setBankPhoneAreaCode(getField(fileData, 139, 3)); setBankPhonePrefixNumber(getField(fileData, 142, 3)); setBankPhoneSuffixNumber(getField(fileData, 145, 4)); setBankInstitutionStatusCode(getField(fileData, 149, 1)); setActive(true); setBankCountryCode(KFSConstants.COUNTRY_CODE_UNITED_STATES); }</code><technical_language>original file appears a call "setBankDataViewCode" in this method, I call in this overlay. please add in if necessary</technical_language>

Target:
public ACHBank(String fileData) { setBankRoutingNumber(getField(fileData, 1, 9)); setBankOfficeCode(getField(fileData, 10, 1)); setBankServiceNumber(getField(fileData, 11, 9)); setBankTypeCode(getField(fileData, 20, 1)); setBankNewRoutingNumber(getField(fileData, 27, 9)); setBankName(getField(fileData, 36, 36)); setBankStreetAddress(getField(fileData, 72, 36)); setBankCityName(getField(fileData, 108, 20)); setBankStateCode(getField(fileData, 128, 2)); setBankZipCode(getField(fileData, 130, 5)); setBankPhoneAreaCode(getField(fileData, 139, 3)); setBankPhonePrefixNumber(getField(fileData, 142, 3)); setBankPhoneSuffixNumber(getField(fileData, 145, 4)); setBankInstitutionStatusCode(getField(fileData, 149, 1)); setBankDataViewCode(getField(fileData, 150, 1)); setActive(true); setBankCountryCode(KFSConstants.COUNTRY_CODE_UNITED_STATES); }
Source:
<code>public int hashCode() { int result = container.hashCode(); <START> result = 31 * result + moduleSequence.hashCode(); <END> result = 31 * result + moduleDescriptorKey.hashCode(); return result; }</code><technical_language>this include key's hashCode adding sequence hashCode</technical_language>

Target:
public int hashCode() { int result = container.hashCode(); result = 31 * result + moduleSequence; result = 31 * result + moduleDescriptorKey.hashCode(); return result; }
Source:
<code>private String getResultFromStream(InputStream inputStream) { try (Scanner scanner = new Scanner(inputStream, charset.name())) { <START> return scanner.useDelimiter("\\A").next().trim(); <END> } }</code><technical_language>is useDelimiter("\\A") needed here? good BufferedReader.readLine()</technical_language>

Target:
private String getResultFromStream(InputStream inputStream) { try (Scanner scanner = new Scanner(inputStream, charset.name())) { String result = null; if (scanner.hasNextLine()) { result = scanner.nextLine(); if (scanner.hasNextLine()) { LOGGER.warn("External process has more than one line of output. " + "Only the first line is used."); } } else { LOGGER.warn("External process has not produced any output."); } return result; } }
Source:
<code>public boolean filter(Bundle bundle) { for (int i = 0; i < in.length; i++) { ValueObject v = in[i].getValue(bundle); if (v == null) { continue; } switch (v.getObjectType()) { case ARRAY: ValueArray arr = v.asArray(); if (arr.size() > 0) { if (which != null) { <START> ValueObject fieldName = ValueFactory.create(((CachingField) in[i]).name); <END> which.setValue(bundle, fieldName); } out.setValue(bundle, arr); return true; } break; default: String str = ValueUtil.asNativeString(v); if (!Strings.isEmpty(str)) { if (which != null) { ValueObject fieldName = ValueFactory.create(((CachingField) in[i]).name); which.setValue(bundle, fieldName); } out.setValue(bundle, v); return true; } break; } } return false; }</code><technical_language>declare field a CachingField if is enforced</technical_language>

Target:
public boolean filter(Bundle bundle) { for (int i = 0; i < in.length; i++) { ValueObject v = in[i].getValue(bundle); if (v == null) { continue; } switch (v.getObjectType()) { case ARRAY: ValueArray arr = v.asArray(); if (arr.size() > 0) { if (which != null) { ValueObject fieldName = ValueFactory.create(in[i].name); which.setValue(bundle, fieldName); } out.setValue(bundle, arr); return true; } break; default: String str = ValueUtil.asNativeString(v); if (!Strings.isEmpty(str)) { if (which != null) { ValueObject fieldName = ValueFactory.create(in[i].name); which.setValue(bundle, fieldName); } out.setValue(bundle, v); return true; } break; } } return false; }
Source:
<code>public String getColumnText(Object aObj, int aIndex) { if (aObj instanceof GerritTask) { GerritTask reviewSummary = (GerritTask) aObj; switch (aIndex) { <START> case 0: <END> return reviewSummary.getAttribute(GerritTask.IS_STARRED); case 1: return reviewSummary.getAttribute(GerritTask.SHORT_CHANGE_ID); case 2: return reviewSummary.getAttribute(GerritTask.SUBJECT); case 3: return reviewSummary.getAttribute(GerritTask.OWNER); case 4: return reviewSummary.getAttribute(GerritTask.PROJECT); case 5: return reviewSummary.getAttribute(GerritTask.BRANCH); case 6: return reviewSummary.getAttribute(GerritTask.TOPIC); case 7: return reviewSummary.getAttributeAsDate(GerritTask.DATE_MODIFICATION); default: return EMPTY_STRING; } } return EMPTY_STRING; }</code><technical_language>a note this (existing) of index Strikes fragile. If put constants in for of indexes code clearer worry potential mismatches</technical_language>

Target:
public String getColumnText(Object aObj, int aIndex) { if (aObj instanceof GerritTask) { GerritTask reviewSummary = (GerritTask) aObj; switch (aIndex) { case 0: return reviewSummary.getAttribute(GerritTask.IS_STARRED); case 1: return reviewSummary.getAttribute(GerritTask.SHORT_CHANGE_ID); case 2: return reviewSummary.getAttribute(GerritTask.SUBJECT); case 3: return reviewSummary.getAttribute(GerritTask.OWNER); case 4: return reviewSummary.getAttribute(GerritTask.PROJECT); case 5: String branch = reviewSummary.getAttribute(GerritTask.BRANCH); String topic = reviewSummary.getAttribute(GerritTask.TOPIC); if (topic != null && !topic.isEmpty()) { branch += " (" + reviewSummary.getAttribute(GerritTask.TOPIC) + ")"; } return branch; case 6: return reviewSummary.getAttributeAsDate(GerritTask.DATE_MODIFICATION); default: return EMPTY_STRING; } } return EMPTY_STRING; }
Source:
<code>public void onReceivedHttpAuthRequest(WebView view, final HttpAuthHandler handler, String host, String realm) { Logger.i(TAG, "onReceivedHttpAuthRequest for host:" + host, ""); <START> if (mUIEvent != null) { <END> mUIEvent.setNTLM(true); } HttpAuthDialog authDialog = new HttpAuthDialog(mCallingContext, host, realm); authDialog.setOkListener(new HttpAuthDialog.OkListener() { public void onOk(String host, String realm, String username, String password) { Logger.i(TAG, "onReceivedHttpAuthRequest: handler proceed" + host, ""); handler.proceed(username, password); } }); authDialog.setCancelListener(new HttpAuthDialog.CancelListener() { public void onCancel() { Logger.i(TAG, "onReceivedHttpAuthRequest: handler cancelled", ""); handler.cancel(); cancelWebViewRequest(); } }); Logger.i(TAG, "onReceivedHttpAuthRequest: show dialog", ""); authDialog.show(); }</code><technical_language>case, get ntlm challenge a null ui event? #Resolved</technical_language>

Target:
public void onReceivedHttpAuthRequest(WebView view, final HttpAuthHandler handler, String host, String realm) { Logger.i(TAG, "onReceivedHttpAuthRequest for host:" + host, ""); mUIEvent.setNTLM(true); HttpAuthDialog authDialog = new HttpAuthDialog(mCallingContext, host, realm); authDialog.setOkListener(new HttpAuthDialog.OkListener() { public void onOk(String host, String realm, String username, String password) { Logger.i(TAG, "onReceivedHttpAuthRequest: handler proceed" + host, ""); handler.proceed(username, password); } }); authDialog.setCancelListener(new HttpAuthDialog.CancelListener() { public void onCancel() { Logger.i(TAG, "onReceivedHttpAuthRequest: handler cancelled", ""); handler.cancel(); cancelWebViewRequest(); } }); Logger.i(TAG, "onReceivedHttpAuthRequest: show dialog", ""); authDialog.show(); }
Source:
<code>private void closeCachedLookupSources() { <START> rwLock.writeLock().lock(); <END> try { suppliedLookupSources.values().forEach(LookupSource::close); suppliedLookupSources.clear(); } finally { rwLock.writeLock().unlock(); } }</code><technical_language>this is called locks, want mark @GuardedBy(rwLock)</technical_language>

Target:
private void closeCachedLookupSources() { lock.writeLock().lock(); try { suppliedLookupSources.values().forEach(LookupSource::close); suppliedLookupSources.clear(); } finally { lock.writeLock().unlock(); } }
Source:
<code>protected IStatus run(final IProgressMonitor monitor) { int alreadyDone = 0; <START> ITmfTraceKnownSize traceWithSize = (ITmfTraceKnownSize) fTrace; <END> if (fTraceWithSize != null) { monitor.beginTask("", traceWithSize.size()); } else { monitor.beginTask("", IProgressMonitor.UNKNOWN); } while (!monitor.isCanceled()) { try { long prevNbEvents = fTrace.getNbEvents(); Thread.sleep(250); long nbEvents = fTrace.getNbEvents(); if (fTraceWithSize != null) { final int done = traceWithSize.progress(); monitor.worked(done - alreadyDone); alreadyDone = done; } setName(Messages.TmfCheckpointIndexer_Indexing + ' ' + fTrace.getName() + " (" + String.format("%,d", nbEvents) + ")"); long rate = (nbEvents - prevNbEvents) * 4; monitor.setTaskName(String.format("%,d", rate) + " " + Messages.TmfCheckpointIndexer_EventsPerSecond); } catch (final InterruptedException e) { return Status.OK_STATUS; } } monitor.done(); return fException != null ? new Status(IStatus.ERROR, Activator.PLUGIN_ID, fException.getMessage(), fException) : Status.OK_STATUS; }</code><technical_language>ClassCastException! fTraceWithSize, it</technical_language>

Target:
protected IStatus run(final IProgressMonitor monitor) { SubMonitor subMonitor = SubMonitor.convert(monitor); if (fTraceWithSize != null) { subMonitor.beginTask("", fTraceWithSize.size()); } else { subMonitor.beginTask("", IProgressMonitor.UNKNOWN); } while (!monitor.isCanceled()) { try { long prevNbEvents = fTrace.getNbEvents(); Thread.sleep(250); long nbEvents = fTrace.getNbEvents(); if (fTraceWithSize != null) { final int done = fTraceWithSize.progress(); subMonitor.setWorkRemaining(fTraceWithSize.size() - done); subMonitor.worked(done); } setName(Messages.TmfCheckpointIndexer_Indexing + ' ' + fTrace.getName() + " (" + String.format("%,d", nbEvents) + ")"); long rate = (nbEvents - prevNbEvents) * 4; subMonitor.setTaskName(String.format("%,d", rate) + " " + Messages.TmfCheckpointIndexer_EventsPerSecond); } catch (final InterruptedException e) { return Status.OK_STATUS; } } subMonitor.done(); monitor.done(); return fException != null ? new Status(IStatus.ERROR, Activator.PLUGIN_ID, fException.getMessage(), fException) : Status.OK_STATUS; }
Source:
<code>protected boolean assignHostsToGroups(CommandContext context) { boolean requiresRestart = false; Map<String, String> hostGroups = context.getAppConfig().getHostGroups(); HostManager hostMgr = new HostManager(context.getManageClient()); for (Map.Entry<String, String> entry : hostGroups.entrySet()) { String hostName = entry.getKey(); String groupName = entry.getValue(); ServerManager serverMgr = new ServerManager(context.getManageClient(), groupName); <START> if (serverMgr.exists(MANAGE_SERVER_NAME, "group-id="+groupName)) { <END> logger.info(format("%s appserver already exists in target group %s", MANAGE_SERVER_NAME, groupName)); } else { String manageServerPayload = format(MANAGE_SERVER_JSON_TEMPLATE, MANAGE_SERVER_NAME, groupName); serverMgr.save(manageServerPayload); logger.info(format("Created the %s appserver in target group %s", MANAGE_SERVER_NAME, groupName)); } if (serverMgr.exists(APP_SERVER_NAME, "group-id="+groupName)) { logger.info(format("%s appserver already exists in target group %s", APP_SERVER_NAME, groupName)); } else { String manageServerPayload = format(APP_SERVER_JSON_TEMPLATE, APP_SERVER_NAME, groupName); serverMgr.save(manageServerPayload); logger.info(format("Created the %s appserver in target group %s", APP_SERVER_NAME, groupName)); } if (hostMgr.getAssignedGroupName(hostName) != groupName) { hostMgr.setHostToGroup(hostName, groupName); requiresRestart = true; } } return requiresRestart; }</code><technical_language>need group-id bit here, ServerManager include automatically passed in constructor</technical_language>

Target:
protected boolean assignHostsToGroups(CommandContext context) { boolean requiresRestart = false; Map<String, String> hostGroups = context.getAppConfig().getHostGroups(); HostManager hostMgr = new HostManager(context.getManageClient()); for (Map.Entry<String, String> entry : hostGroups.entrySet()) { String hostName = entry.getKey(); String groupName = entry.getValue(); ServerManager serverMgr = new ServerManager(context.getManageClient(), groupName); if (serverMgr.exists(ManageServer.MANAGE_SERVER_NAME)) { logger.info(format("%s appserver already exists in target group %s", ManageServer.MANAGE_SERVER_NAME, groupName)); } else { manageServerTemplate.setGroupName(groupName); serverMgr.save(manageServerTemplate.getJson()); logger.info(format("Created the %s appserver in target group %s", ManageServer.MANAGE_SERVER_NAME, groupName)); } if (serverMgr.exists(AppServicesServer.APP_SERVICES_SERVER_NAME)) { logger.info(format("%s appserver already exists in target group %s", AppServicesServer.APP_SERVICES_SERVER_NAME, groupName)); } else { appServicesServerTemplate.setGroupName(groupName); serverMgr.save(appServicesServerTemplate.getJson()); logger.info(format("Created the %s appserver in target group %s", AppServicesServer.APP_SERVICES_SERVER_NAME, groupName)); } if (!groupName.equals(hostMgr.getAssignedGroupName(hostName))) { hostMgr.setHostToGroup(hostName, groupName); requiresRestart = true; } } return requiresRestart; }
Source:
<code>public void test_n_iterations() { ArrayList<CandidateClusterContext> arrayList = new ArrayList<CandidateClusterContext>(); int n = 15; for (int i = 0; i < 10; i++) { arrayList.add(createContext()); } <START> ClientDiscoveryService discoveryService = new ClientDiscoveryService(15, arrayList); <END> int count = 0; while (discoveryService.hasNext()) { discoveryService.next(); count++; } assertEquals(10 * n, count); discoveryService.next(); }</code><technical_language>replace 15 n</technical_language>

Target:
public void test_n_iterations() { ArrayList<CandidateClusterContext> arrayList = new ArrayList<CandidateClusterContext>(); int n = 15; for (int i = 0; i < 10; i++) { arrayList.add(createContext()); } ClientDiscoveryService discoveryService = new ClientDiscoveryService(n, arrayList); int count = 0; while (discoveryService.hasNext()) { discoveryService.next(); count++; } assertEquals(10 * n, count); discoveryService.next(); }
Source:
<code><START> public synchronized String getFieldString(int size, String s) { <END> try { buffer.replace(0, size, emptyString); buffer.setLength(size); int maxSize = size; if (s != null) { buffer.replace(0, size, s); int currentBytes = s.substring(0, Math.min(size, s.length())) .getBytes(charset.name()).length; if (currentBytes > size) { char[] c = new char[1]; for (int index = size - 1; currentBytes > size; index--) { c[0] = buffer.charAt(index); String string = new String(c); buffer.deleteCharAt(index); currentBytes -= string.getBytes().length; maxSize--; } } else { if (s.length() < size) { maxSize = size - (currentBytes - s.length()); for (int i = s.length(); i < size; i++) { buffer.append(' '); } } } } buffer.setLength(maxSize); return buffer.toString(); } catch(UnsupportedEncodingException e) { throw new RuntimeException("This error should never occurr", e); } }</code><technical_language>user of FieldFormatter is DbaseFileWriter, in turn possibly multiple thread in parallel state position dbase file. synchronized statements useful, if vm is smart enough get rid of runtime (it be, knows) harmful. Please remove them</technical_language>

Target:
public String getFieldString(int size, String s) { try { buffer.replace(0, size, emptyString); buffer.setLength(size); int maxSize = size; if (s != null) { buffer.replace(0, size, s); int currentBytes = s.substring(0, Math.min(size, s.length())) .getBytes(charset.name()).length; if (currentBytes > size) { char[] c = new char[1]; for (int index = size - 1; currentBytes > size; index--) { c[0] = buffer.charAt(index); String string = new String(c); buffer.deleteCharAt(index); currentBytes -= string.getBytes().length; maxSize--; } } else { if (s.length() < size) { maxSize = size - (currentBytes - s.length()); for (int i = s.length(); i < size; i++) { buffer.append(' '); } } } } buffer.setLength(maxSize); return buffer.toString(); } catch(UnsupportedEncodingException e) { throw new RuntimeException("This error should never occurr", e); } }
Source:
<code>public void autoSelectResumeBehavior(VmBase vmBase, Version clusterVersion) { Version version = CompatibilityVersionUtils.getEffective(vmBase.getCustomCompatibilityVersion(), () -> clusterVersion); if <START> (Version.v4_2.lessOrEquals(version)) <END> { if (vmBase.isAutoStartup() && vmBase.getLeaseStorageDomainId() != null) { vmBase.setResumeBehavior(ResumeBehavior.KILL); } } }</code><technical_language>feature-supported</technical_language>

Target:
public void autoSelectResumeBehavior(VmBase vmBase, Version clusterVersion) { Version version = CompatibilityVersionUtils.getEffective(vmBase.getCustomCompatibilityVersion(), () -> clusterVersion); if (FeatureSupported.isResumeBehaviorSupported(version)) { if (vmBase.isAutoStartup() && vmBase.getLeaseStorageDomainId() != null) { vmBase.setResumeBehavior(VmResumeBehavior.KILL); } else if (vmBase.getResumeBehavior() == null) { vmBase.setResumeBehavior(VmResumeBehavior.AUTO_RESUME); } } }