auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
public void saveContent(DownloadBundle bundle, AthenaUser user) { List<Long> idV4s = bundle.getVocabularyV4Ids(); try (FileOutputStream fout = new FileOutputStream(fileHelper.getZipPath(bundle.getUuid())); ZipOutputStream zos = new ZipOutputStream(new BufferedOutputStream(fout))) { List ids; List<? extends ISaver> savers; switch (bundle.getCdmVersion()) { case V4_5: ids = idV4s; savers = saversV4; break; case V5: ids = vocabularyConversionRepository.findIdsV5ByIdsV4(idV4s); savers = saversV5; break; default: throw new NotExistException("No savers for version " + bundle.getCdmVersion(), CDMVersion.class); } SaverService saver = new SaverService(downloadBundleService, ids, fileHelper); bundle = saver.save(zos, bundle, savers); zipWriter.addCPT4Utility(zos, bundle); LOGGER.info("Bundle is saved in zip: {}", bundle); updateStatus(bundle, DownloadBundleStatus.READY); final Map<String, String> includedVocabularies = bundle.getVocabularies().stream().map(DownloadItem::getVocabularyConversion) .filter(vocab -> !vocab.getOmopReqValue()).collect(Collectors.toMap(VocabularyConversion::getIdV5, VocabularyConversion::getName)); emailService.sendVocabularyDownloadLink(user, urlBuilder.downloadVocabulariesLink(bundle.getUuid()), bundle.getCdmVersion(), bundle.getReleaseVersion(), bundle.getName(), includedVocabularies); } catch (Exception ex) { updateStatus(bundle, DownloadBundleStatus.FAILED); LOGGER.error(ex.getMessage(), ex); emailService.sendFailedSaving(user); } }

Target:
public void saveContent(DownloadBundle bundle, AthenaUser user) { List<Long> idV4s = bundle.getVocabularyV4Ids(); try (FileOutputStream fout = new FileOutputStream(fileHelper.getZipPath(bundle.getUuid())); ZipOutputStream zos = new ZipOutputStream(new BufferedOutputStream(fout))) { List ids; List<? extends ISaver> savers; switch (bundle.getCdmVersion()) { case V4_5: ids = idV4s; savers = saversV4; break; case V5: ids = vocabularyConversionRepository.findIdsV5ByIdsV4(idV4s); savers = saversV5; break; default: throw new NotExistException("No savers for version " + bundle.getCdmVersion(), CDMVersion.class); } SaverService saver = new SaverService(downloadBundleService, ids, fileHelper); bundle = saver.save(zos, bundle, savers); zipWriter.addCPT4Utility(zos, bundle); LOGGER.info("Bundle is saved in zip: {}", bundle); updateStatus(bundle, DownloadBundleStatus.READY); final Map<String, String> includedVocabularies = bundle.getVocabularies().stream() .map(DownloadItem::getVocabularyConversion) .filter(vocab -> !vocab.getOmopReqValue()) .collect(toMap(VocabularyConversion::getIdV5, VocabularyConversion::getName)); emailService.sendVocabularyDownloadLink(user, urlBuilder.downloadVocabulariesLink(bundle.getUuid()), bundle.getCdmVersion(), bundle.getReleaseVersion(), bundle.getName(), includedVocabularies); } catch (Exception ex) { updateStatus(bundle, DownloadBundleStatus.FAILED); LOGGER.error(ex.getMessage(), ex); emailService.sendFailedSaving(user); } }
Source:
private Map<String, List<String>> extractHeaders(SlingHttpServletResponse response, HttpCacheConfig cacheConfig) { Map<String, List<String>> headers = new HashMap<>(); List<Pattern> excludedHeaders = Stream.concat(globalHeaderExclusions.stream(), cacheConfig.getExcludedResponseHeaderPatterns().stream()) .collect(Collectors.toList()); List<String> headerNames = new ArrayList<>(); headerNames.addAll(response.getHeaderNames()); for (String headerName : headerNames) { if (!isResponseHeaderExcluded(headerName, excludedHeaders)) { List<String> values = new ArrayList<>(); values.addAll(response.getHeaders(headerName)); headers.put(headerName, values); } } return headers; }

Target:
private Map<String, List<String>> extractHeaders(SlingHttpServletResponse response, HttpCacheConfig cacheConfig) { List<Pattern> excludedHeaders = Stream.concat(globalHeaderExclusions.stream(), cacheConfig.getExcludedResponseHeaderPatterns().stream()) .collect(Collectors.toList()); return response.getHeaderNames().stream() .filter(headerName -> excludedHeaders.stream() .noneMatch(pattern -> pattern.matcher(headerName).matches()) ).collect( Collectors.toMap(headerName -> headerName, headerName -> new ArrayList<>(response.getHeaders(headerName) ) )); }
Source:
public Session createSession() { Properties properties = new Properties(); if (hostName == null) { throw new IllegalArgumentException("Hostname cannot be null for smtp client."); } properties.setProperty(SMTP_HOST_PROPERTY, hostName); properties.setProperty(SMTP_PORT_PROPERTY, portNumber.toString()); ClassLoader originalContextClassLoader = Thread.currentThread().getContextClassLoader(); Thread.currentThread().setContextClassLoader(Provider.class.getClassLoader()); Session session; if (StringUtils.isNotBlank(userName)) { properties.put(SMTP_AUTH_PROPERTY, TRUE); properties.put(SMTP_START_TLS_ENABLE_PROPERTY, TRUE); session = Session.getInstance(properties, createAuthenticator()); } else { properties.setProperty(SMTP_AUTH_PROPERTY, FALSE); session = Session.getInstance(properties); } Thread.currentThread().setContextClassLoader(originalContextClassLoader); return session; }

Target:
public Session createSession() { Properties properties = new Properties(); if (hostName == null) { throw new IllegalArgumentException("Hostname cannot be null for smtp client."); } properties.setProperty(SMTP_HOST_PROPERTY, hostName); properties.setProperty(SMTP_PORT_PROPERTY, portNumber.toString()); ClassLoader originalContextClassLoader = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(Provider.class.getClassLoader()); if (StringUtils.isNotBlank(userName)) { properties.put(SMTP_AUTH_PROPERTY, TRUE); properties.put(SMTP_START_TLS_ENABLE_PROPERTY, TRUE); return Session.getInstance(properties, createAuthenticator()); } else { properties.setProperty(SMTP_AUTH_PROPERTY, FALSE); return Session.getInstance(properties); } } finally { Thread.currentThread().setContextClassLoader(originalContextClassLoader); } }
Source:
protected <T> Invoker<T> doSelect(List<Invoker<T>> invokers, URL url, Invocation invocation) { int length = invokers.size(); int leastActive = -1; int leastCount = 0; int[] leastIndexs = new int[length]; int taotalWeightWithWarmUp = 0; int firstWeightWithWarmUp = 0; boolean sameWeight = true; for (int i = 0; i < length; i++) { Invoker<T> invoker = invokers.get(i); int active = RpcStatus.getStatus(invoker.getUrl(), invocation.getMethodName()).getActive(); int afterWarmup = getWeight(invoker, invocation); if (leastActive == -1 || active < leastActive) { leastActive = active; leastCount = 1; leastIndexs[0] = i; taotalWeightWithWarmUp = afterWarmup; firstWeightWithWarmUp = afterWarmup; sameWeight = true; } else if (active == leastActive) { leastIndexs[leastCount++] = i; taotalWeightWithWarmUp += afterWarmup; if (sameWeight && i > 0 && afterWarmup != firstWeightWithWarmUp) { sameWeight = false; } } } if (leastCount == 1) { return invokers.get(leastIndexs[0]); } if (!sameWeight && taotalWeightWithWarmUp > 0) { int offsetWeight = random.nextInt(taotalWeightWithWarmUp) + 1; for (int i = 0; i < leastCount; i++) { int leastIndex = leastIndexs[i]; offsetWeight -= getWeight(invokers.get(leastIndex), invocation); if (offsetWeight <= 0) return invokers.get(leastIndex); } } return invokers.get(leastIndexs[random.nextInt(leastCount)]); }

Target:
protected <T> Invoker<T> doSelect(List<Invoker<T>> invokers, URL url, Invocation invocation) { int length = invokers.size(); int leastActive = -1; int leastCount = 0; int[] leastIndexes = new int[length]; int totalWeight = 0; int firstWeight = 0; boolean sameWeight = true; for (int i = 0; i < length; i++) { Invoker<T> invoker = invokers.get(i); int active = RpcStatus.getStatus(invoker.getUrl(), invocation.getMethodName()).getActive(); int afterWarmup = getWeight(invoker, invocation); if (leastActive == -1 || active < leastActive) { leastActive = active; leastCount = 1; leastIndexes[0] = i; totalWeight = afterWarmup; firstWeight = afterWarmup; sameWeight = true; } else if (active == leastActive) { leastIndexes[leastCount++] = i; totalWeight += afterWarmup; if (sameWeight && i > 0 && afterWarmup != firstWeight) { sameWeight = false; } } } if (leastCount == 1) { return invokers.get(leastIndexes[0]); } if (!sameWeight && totalWeight > 0) { int offsetWeight = ThreadLocalRandom.current().nextInt(totalWeight) + 1; for (int i = 0; i < leastCount; i++) { int leastIndex = leastIndexes[i]; offsetWeight -= getWeight(invokers.get(leastIndex), invocation); if (offsetWeight <= 0) return invokers.get(leastIndex); } } return invokers.get(leastIndexes[ThreadLocalRandom.current().nextInt(leastCount)]); }
Source:
LocalCacheManager(AlluxioConfiguration conf, MetaStore metaStore, PageStore pageStore, CacheEvictor evictor) { mMetaStore = metaStore; mPageStore = pageStore; mEvictor = evictor; mPageSize = conf.getBytes(PropertyKey.USER_CLIENT_CACHE_PAGE_SIZE); mAsyncWrite = conf.getBoolean(PropertyKey.USER_CLIENT_CACHE_ASYNC_WRITE_ENABLED); mCacheSize = pageStore.getCacheSize(); for (int i = 0; i < LOCK_SIZE; i++) { mPageLocks[i] = new ReentrantReadWriteLock(); } mPendingRequests = new ConcurrentHashSet<>(); mAsyncCacheExecutor = mAsyncWrite ? new ThreadPoolExecutor(0, conf.getInt(PropertyKey.USER_CLIENT_CACHE_ASYNC_WRITE_THREADS), 60, TimeUnit.SECONDS, new SynchronousQueue<>()) : null; Metrics.registerGauges(mCacheSize, mMetaStore); }

Target:
LocalCacheManager(AlluxioConfiguration conf, MetaStore metaStore, PageStore pageStore, CacheEvictor evictor) { mMetaStore = metaStore; mPageStore = pageStore; mEvictor = evictor; mPageSize = conf.getBytes(PropertyKey.USER_CLIENT_CACHE_PAGE_SIZE); mAsyncWrite = conf.getBoolean(PropertyKey.USER_CLIENT_CACHE_ASYNC_WRITE_ENABLED); mCacheSize = pageStore.getCacheSize(); for (int i = 0; i < LOCK_SIZE; i++) { mPageLocks[i] = new ReentrantReadWriteLock(); } mPendingRequests = new ConcurrentHashSet<>(); mAsyncCacheExecutor = mAsyncWrite ? new ThreadPoolExecutor(conf.getInt(PropertyKey.USER_CLIENT_CACHE_ASYNC_WRITE_THREADS), conf.getInt(PropertyKey.USER_CLIENT_CACHE_ASYNC_WRITE_THREADS), 60, TimeUnit.SECONDS, new SynchronousQueue<>()) : null; Metrics.registerGauges(mCacheSize, mMetaStore); }
Source:
public void setUp() { super.setUp(); VisitRepository visitRepository = new VisitRepository(restApi, visitDAO, locationDAO, new EncounterDAO()); presenter = new LoginPresenter(restApi, visitRepository, locationDAO, userService, view, openMRS, <<<<<<< HEAD openMRSLogger, authorizationManager); ======= openMRSLogger, authorizationManager); >>>>>>> removed context from presenter mockStaticMethods(); }

Target:
public void setUp() { super.setUp(); VisitRepository visitRepository = new VisitRepository(restApi, visitDAO, locationDAO, new EncounterDAO()); presenter = new LoginPresenter(restApi, visitRepository, locationDAO, userService, view, openMRS, openMRSLogger, authorizationManager); mockStaticMethods(); }
Source:
public boolean isLiteralText() { return blobExpression == null ? false : blobExpression.isLiteralText(); }

Target:
public boolean isLiteralText() { return blobExpression != null && blobExpression.isLiteralText(); }
Source:
public void savePatient_shouldFailSaveIfPatientsWithSameIdentifierAreSaved() { isSavePatientThreadsafe = new AtomicBoolean(false); UserContext ctx = Context.getUserContext(); Patient patient1 = new Patient(); patient1.setGender("M"); patient1.addName(new PersonName("Test1", "Sam", "Test")); Patient patient2 = new Patient(); patient2.setGender("M"); patient2.addName(new PersonName("Test2", "Samuel", "Test")); Runnable r1 = () -> savePatientOnThread(ctx, patient1); Runnable r2 = () -> savePatientOnThread(ctx, patient2); Thread t1 = new Thread(r1); Thread t2 = new Thread(r2); t1.start(); t2.start(); assertTrue(isSavePatientThreadsafe.get()); }

Target:
public void savePatient_shouldFailSaveIfPatientsWithSameIdentifierAreSaved() { isSavePatientThreadUnSafe = new AtomicBoolean(false); UserContext ctx = Context.getUserContext(); Patient patient1 = new Patient(); patient1.setGender("M"); patient1.addName(new PersonName("Test1", "Sam", "Test")); Patient patient2 = new Patient(); patient2.setGender("M"); patient2.addName(new PersonName("Test2", "Samuel", "Test")); Runnable r1 = () -> savePatientOnThread(ctx, patient1); Runnable r2 = () -> savePatientOnThread(ctx, patient2); Thread t1 = new Thread(r1); Thread t2 = new Thread(r2); t1.start(); t2.start(); try { t1.join(); } catch (InterruptedException e) { } assertTrue("IdentifierNotUniqueException not thrown, method not Threadsafe", isSavePatientThreadUnSafe.get()); deleteAllData(); }
Source:
public void applyConfig(Collection<PubSubConfig.Publisher> publishers) { Set<String> existingKeys = new HashSet<String>(subscribers.keySet()); for (final PubSubConfig.Publisher p : publishers) { Map<String, List<SubscribeCommand>> syncCommands; final String key = p.getKey(); existingKeys.remove(key); SubscribeTask task = subscribers.get(key); if (task == null) { try { task = new SubscribeTask(new SubscribeProcess( p.getUri(), new Subscriber())); } catch (Exception e) { printError(key, e); continue; } subscribers.put(key, task); } try { syncCommands = task.process.sync(p); } catch (Exception e) { printError(key, e); continue; } if (syncCommands.size() > 0) { task.stop(); task.start(p, syncCommands, key); } } for (String key : existingKeys) { SubscribeTask task = subscribers.get(key); task.close(); subscribers.remove(key); } }

Target:
public void applyConfig(Collection<PubSubConfig.Publisher> publishers) { Set<String> existingKeys = new HashSet<String>(subscribers.keySet()); for (final PubSubConfig.Publisher p : publishers) { existingKeys.remove(p.getKey()); SubscribeTask task = subscribers.get(p.getKey()); if (task == null) { try { SubscribeProcess sp = new SubscribeProcess( p.getUri(), new SubscriptionState()); task = new SubscribeTask(sp, p.getKey()); task.start(p); subscribers.put(p.getKey(), task); } catch (Exception e) { printError(p.getKey(), e); } } else { task.updatePublisher(p); } } for (String key : existingKeys) { SubscribeTask task = subscribers.remove(key); task.close(); } }
Source:
void validateSpans() throws Exception { List<Span> spans = SpanCollectorForTesting.getInstance().getCollectedSpans(); assertThat(spans.size(), is(equalTo(2))); Span serverSpan = spans.get(0); assertThat(serverSpan.getTrace_id(), is(equalTo(spans.get(1).getTrace_id()))); validateSpan(serverSpan, Arrays.asList("ss", "sr")); Optional<BinaryAnnotation> binaryAnnotation = serverSpan.getBinary_annotations().stream().filter(b -> b.getKey().equals(GrpcKeys.GRPC_REMOTE_ADDR)).findFirst(); assertTrue("Could not find binary annotation: " + GrpcKeys.GRPC_REMOTE_ADDR, binaryAnnotation.isPresent()); validateSpan(spans.get(1), Arrays.asList("cs", "cr")); }

Target:
void validateSpans() throws Exception { List<Span> spans = SpanCollectorForTesting.getInstance().getCollectedSpans(); assertThat(spans.size()).isEqualTo(2); Span serverSpan = spans.get(0); assertThat(serverSpan.getTrace_id()).isEqualTo(spans.get(1).getTrace_id()); validateSpan(serverSpan, Arrays.asList("sr", "ss")); assertThat(serverSpan.getBinary_annotations()) .filteredOn(b -> b.key.equals(GrpcKeys.GRPC_REMOTE_ADDR)) .extracting(b -> new String(b.value)) .has(new Condition<>(b -> b.matches("^/127.0.0.1:[\\d]+$"), "a local IP address"), atIndex(0)); validateSpan(spans.get(1), Arrays.asList("cs", "cr")); }
Source:
public Workflow refresh(@ApiParam(hidden = true) @Auth User user, @ApiParam(value = "workflow ID", required = true) @PathParam("workflowId") Long workflowId) { Workflow workflow = workflowDAO.findById(workflowId); checkEntry(workflow); checkCanWriteWorkflow(user, workflow); checkNotHosted(workflow); user = userDAO.findById(user.getId()); user.updateUserMetadata(tokenDAO); final SourceCodeRepoInterface sourceCodeRepo = getSourceCodeRepoInterface(workflow.getGitUrl(), user); workflow.setMode(WorkflowMode.FULL); if (!workflow.isIsChecker() && workflow.getDescriptorType().equals(CWL_STRING) || workflow.getDescriptorType().equals(WDL_STRING)) { String workflowName = workflow.getWorkflowName() == null ? "" : workflow.getWorkflowName(); String checkerWorkflowName = "/" + workflowName + (workflow.getDescriptorType().equals(CWL_STRING) ? CWL_CHECKER : WDL_CHECKER); Workflow byPath = workflowDAO.findByPath(workflow.getPath() + checkerWorkflowName, false); if (byPath != null && workflow.getCheckerWorkflow() == null) { workflow.setCheckerWorkflow(byPath); } } final Workflow newWorkflow = sourceCodeRepo.getWorkflow(workflow.getOrganization() + '/' + workflow.getRepository(), Optional.of(workflow)); workflow.getUsers().add(user); updateDBWorkflowWithSourceControlWorkflow(workflow, newWorkflow); FileFormatHelper.updateFileFormats(newWorkflow.getVersions(), fileFormatDAO); if (!workflow.isIsChecker() && workflow.getCheckerWorkflow() != null) { refresh(user, workflow.getCheckerWorkflow().getId()); } elasticManager.handleIndexUpdate(newWorkflow, ElasticMode.UPDATE); return workflow; }

Target:
public Workflow refresh(@ApiParam(hidden = true) @Auth User user, @ApiParam(value = "workflow ID", required = true) @PathParam("workflowId") Long workflowId) { Workflow workflow = workflowDAO.findById(workflowId); checkEntry(workflow); checkUser(user, workflow); checkNotHosted(workflow); user = userDAO.findById(user.getId()); user.updateUserMetadata(tokenDAO); final SourceCodeRepoInterface sourceCodeRepo = getSourceCodeRepoInterface(workflow.getGitUrl(), user); workflow.setMode(WorkflowMode.FULL); if (!workflow.isIsChecker() && workflow.getDescriptorType().equals(CWL_STRING) || workflow.getDescriptorType().equals(WDL_STRING)) { String workflowName = workflow.getWorkflowName() == null ? "" : workflow.getWorkflowName(); String checkerWorkflowName = "/" + workflowName + (workflow.getDescriptorType().equals(CWL_STRING) ? CWL_CHECKER : WDL_CHECKER); Workflow byPath = workflowDAO.findByPath(workflow.getPath() + checkerWorkflowName, false); if (byPath != null && workflow.getCheckerWorkflow() == null) { workflow.setCheckerWorkflow(byPath); } } final Workflow newWorkflow = sourceCodeRepo.getWorkflow(workflow.getOrganization() + '/' + workflow.getRepository(), Optional.of(workflow)); workflow.getUsers().add(user); updateDBWorkflowWithSourceControlWorkflow(workflow, newWorkflow); FileFormatHelper.updateFileFormats(newWorkflow.getVersions(), fileFormatDAO); if (!workflow.isIsChecker() && workflow.getCheckerWorkflow() != null) { refresh(user, workflow.getCheckerWorkflow().getId()); } elasticManager.handleIndexUpdate(newWorkflow, ElasticMode.UPDATE); return workflow; }
Source:
@Test public void testNoCacheHeadersAreSet() throws Exception { List<NameValuePair> responseHeaders = j.createWebClient() .goTo("view/all/itemCategories", "application/json") .getWebResponse() .getResponseHeaders(); final Map<String, String> values = new HashMap<>(); for(NameValuePair p : responseHeaders) { values.put(p.getName(), p.getValue()); } String resp = values.get("Cache-Control"); assertThat(resp, is("no cache, no store, must revalidate")); assertThat(values.get("Expires"), is("0")); assertThat(values.get("Pragma"), is("no-cache")); }

Target:
@Test public void testNoCacheHeadersAreSet() throws Exception { List<NameValuePair> responseHeaders = j.createWebClient() .goTo("view/all/itemCategories", "application/json") .getWebResponse() .getResponseHeaders(); final Map<String, String> values = new HashMap<>(); for(NameValuePair p : responseHeaders) { values.put(p.getName(), p.getValue()); } String resp = values.get("Cache-Control"); assertThat(resp, is("no-cache, no-store, must-revalidate")); assertThat(values.get("Expires"), is("0")); assertThat(values.get("Pragma"), is("no-cache")); }
Source:
public void getInstance_differentConfigurationsShouldNotBlockEachOther() throws InterruptedException { final CountDownLatch bgThreadStarted = new CountDownLatch(1); final CountDownLatch realm2CreatedLatch = new CountDownLatch(1); final RealmConfiguration config1 = configFactory.createConfigurationBuilder() .name("config1") .initialData(new Realm.Transaction() { @Override public void execute(Realm realm) { TestHelper.awaitOrFail(realm2CreatedLatch); } }) .build(); RealmConfiguration config2 = configFactory.createConfigurationBuilder() .name("config2") .build(); Thread thread = new Thread(new Runnable() { @Override public void run() { bgThreadStarted.countDown(); Realm realm = Realm.getInstance(config1); realm.close(); } }); thread.start(); TestHelper.awaitOrFail(bgThreadStarted); Realm realm = Realm.getInstance(config2); realm2CreatedLatch.countDown(); realm.close(); thread.join(); }

Target:
public void getInstance_differentConfigurationsShouldNotBlockEachOther() throws InterruptedException { final CountDownLatch bgThreadStarted = new CountDownLatch(1); final CountDownLatch realm2CreatedLatch = new CountDownLatch(1); final RealmConfiguration config1 = configFactory.createConfigurationBuilder() .name("config1.realm") .initialData(new Realm.Transaction() { @Override public void execute(Realm realm) { bgThreadStarted.countDown(); TestHelper.awaitOrFail(realm2CreatedLatch); } }) .build(); RealmConfiguration config2 = configFactory.createConfigurationBuilder() .name("config2.realm") .build(); Thread thread = new Thread(new Runnable() { @Override public void run() { Realm realm = Realm.getInstance(config1); realm.close(); } }); thread.start(); TestHelper.awaitOrFail(bgThreadStarted); Realm realm = Realm.getInstance(config2); realm2CreatedLatch.countDown(); realm.close(); thread.join(); }
Source:
public void run() { while (!shutdown) { try { if (PluginImpl.getInstance() != null && PluginImpl.getInstance().getConfig() != null && isConnected()) { IGerritHudsonTriggerConfig activeConfig = PluginImpl.getInstance().getConfig(); SshConnection sshConnection = SshConnectionFactory.getConnection( activeConfig.getGerritHostName(), activeConfig.getGerritSshPort(), activeConfig.getGerritProxy(), activeConfig.getGerritAuthentication() ); setGerritProjects(readProjects(sshConnection.executeCommandReader(GERRIT_LS_PROJECTS))); sshConnection.disconnect(); runMissedPatchSets(); } } catch (SshException ex) { logger.warn("Could not connect to Gerrit server when updating Gerrit project list: ", ex); } catch (IOException ex) { logger.error("Could not read stream with Gerrit projects: ", ex); } try { synchronized (this) { wait(UPDATE_DELAY); } } catch (InterruptedException ex) { logger.warn("InterruptedException: ", ex); break; } } PluginImpl.getInstance().removeListener(this); }

Target:
public void run() { while (!shutdown) { try { if (PluginImpl.getInstance() != null && PluginImpl.getInstance().getConfig() != null && isConnected()) { IGerritHudsonTriggerConfig activeConfig = PluginImpl.getInstance().getConfig(); SshConnection sshConnection = SshConnectionFactory.getConnection( activeConfig.getGerritHostName(), activeConfig.getGerritSshPort(), activeConfig.getGerritProxy(), activeConfig.getGerritAuthentication() ); setGerritProjects(readProjects(sshConnection.executeCommandReader(GERRIT_LS_PROJECTS))); sshConnection.disconnect(); } } catch (SshException ex) { logger.warn("Could not connect to Gerrit server when updating Gerrit project list: ", ex); } catch (IOException ex) { logger.error("Could not read stream with Gerrit projects: ", ex); } try { synchronized (this) { wait(UPDATE_DELAY); } } catch (InterruptedException ex) { logger.warn("InterruptedException: ", ex); break; } } PluginImpl.getInstance().removeListener(this); }
Source:
private URI resolve(IResourceLocator locator) { String attributeDataPath = getAttributeDataPath(); StringBuilder builder = new StringBuilder(attributeDataPath); String rawPath = locator.getRawPath(); builder.append(rawPath); String pathname = builder.toString(); if (pathname.contains("workspace")) { pathname = pathname.replaceAll("\\\\", "/"); pathname = pathname.replaceFirst("file:", ""); } File file = new File(pathname); return file.toURI(); }

Target:
private URI resolve(IResourceLocator locator) { String attributeDataPath = getAttributeDataPath(); String rawPath = locator.getRawPath(); String pathname = attributeDataPath + rawPath; if (pathname.contains("workspace")) { pathname = pathname.replaceAll("\\\\", "/"); pathname = pathname.replaceFirst("file:", ""); } File file = new File(pathname); return file.toURI(); }
Source:
public static double number(Object value) { if (value == null) return Double.NaN; if (value instanceof Number) { Number number = (Number) value; return number.doubleValue(); } if (value instanceof String) { String text = (String) value; try { Number number = (Number) gets(text, Number.class); return number.doubleValue(); } catch (Throwable e) { throw new IllegalArgumentException("Unable to decode '" + text + "' as a number"); } } if (value instanceof ComplexAttribute) { ComplexAttribute complexAttrib = (ComplexAttribute) value; Iterator<Property> iterator = (Iterator<Property>) complexAttrib.getValue().iterator(); if (iterator.hasNext()) { Class valueClass = iterator.next().getType().getBinding(); Object result = Converters.convert(value, valueClass); Number number = (Number) result; return number.doubleValue(); } } if (value instanceof Expression) { throw new IllegalArgumentException("Cannot deal with un evaulated Expression"); } throw new IllegalArgumentException( "Unable to evaulate " + value.getClass() + " in a numeric context"); }

Target:
public static double number(Object value) { if (value == null) return Double.NaN; if (value instanceof Number) { Number number = (Number) value; return number.doubleValue(); } if (value instanceof String) { String text = (String) value; try { Number number = (Number) gets(text, Number.class); return number.doubleValue(); } catch (Throwable e) { throw new IllegalArgumentException("Unable to decode '" + text + "' as a number"); } } if (value instanceof Expression) { throw new IllegalArgumentException("Cannot deal with un evaulated Expression"); } throw new IllegalArgumentException( "Unable to evaulate " + value.getClass() + " in a numeric context"); }
Source:
protected boolean isBackChannelLogoutRequest(final HttpServletRequest request) { return "POST".equals(request.getMethod()) && !isMultipartRequest(request) && CommonUtils.isNotBlank(CommonUtils.safeGetParameter(request, this.logoutParameterName, this.safeParameters)); }

Target:
private boolean isBackChannelLogoutRequest(final HttpServletRequest request) { return "POST".equals(request.getMethod()) && !isMultipartRequest(request) && CommonUtils.isNotBlank(CommonUtils.safeGetParameter(request, this.logoutParameterName, this.safeParameters)); }
Source:
public void testSingleRollingFileEmptyWindowsWrite() { SingleHDFSExactlyOnceWriter writer = new SingleHDFSExactlyOnceWriter(); testSingleRollingFileEmptyWindowsWriteHelper(writer); String singleFileName = testMeta.getDir() + File.separator + SINGLE_FILE; int numberOfFiles = new File(testMeta.getDir()).listFiles().length; String correctContents = "0\n" + "1\n" + "2\n"; checkOutput(0, singleFileName, correctContents); Assert.assertEquals("More than one File in Directory", 1, numberOfFiles); }

Target:
public void testSingleRollingFileEmptyWindowsWrite() { SingleHDFSExactlyOnceWriter writer = new SingleHDFSExactlyOnceWriter(); testSingleRollingFileEmptyWindowsWriteHelper(writer); String singleFileName = testMeta.getDir() + File.separator + SINGLE_FILE; int numberOfFiles = new File(testMeta.getDir()).listFiles().length; Assert.assertEquals("More than one File in Directory", 1, numberOfFiles); String correctContents = "0\n" + "1\n" + "2\n"; checkOutput(0, singleFileName, correctContents); }
Source:
public static CRUD grantServiceAccountInstanceCreateReadUpdateDelete(GetPermissionsRequest request, ServiceAccount serviceAccount) { info().serviceAccountID(serviceAccount.getId()) .datasetID(request.getDatasetID()) .log("granting full CRUD instance permissions to service account"); return new CRUD().permit(CREATE, READ, UPDATE, DELETE); }

Target:
public static CRUD grantServiceAccountInstanceCreateReadUpdateDelete(GetPermissionsRequest request, ServiceAccount serviceAccount) { info().serviceAccountID(serviceAccount.getID()) .datasetID(request.getDatasetID()) .log("granting full CRUD instance permissions to service account"); return new CRUD().permit(CREATE, READ, UPDATE, DELETE); }
Source:
void build(Repository git, TagSet old, TagMatcher m) { if (old != null && m != null && refresh(old, m)) { return; } TagWalk rw = new TagWalk(git); rw.setRetainBody(false); try { for (Ref ref : git.getRefDatabase().getRefs(RefDatabase.ALL).values()) { if (skip(ref)) { continue; } else if (isTag(ref)) { addTag(rw, git.peel(ref)); } else { addRef(rw, ref); } } TagCommit c; while ((c = (TagCommit) rw.next()) != null) { BitSet mine = c.refFlags; int pCnt = c.getParentCount(); for (int pIdx = 0; pIdx < pCnt; pIdx++) { ((TagCommit) c.getParent(pIdx)).refFlags.or(mine); } } } catch (IOException e) { log.warn("Repository " + projectName + " has corruption", e); } finally { rw.release(); } }

Target:
void build(Repository git, TagSet old, TagMatcher m) { if (old != null && m != null && refresh(old, m)) { return; } TagWalk rw = new TagWalk(git); rw.setRetainBody(false); try { for (Ref ref : git.getRefDatabase().getRefs(RefDatabase.ALL).values()) { if (skip(ref)) { continue; } else if (isTag(ref)) { addTag(rw, git.peel(ref)); } else { addRef(rw, ref); } } TagCommit c; while ((c = (TagCommit) rw.next()) != null) { BitSet mine = c.refFlags; int pCnt = c.getParentCount(); for (int pIdx = 0; pIdx < pCnt; pIdx++) { ((TagCommit) c.getParent(pIdx)).refFlags.or(mine); } } } catch (IOException e) { log.warn("Error building tags for repository " + projectName, e); } finally { rw.release(); } }
Source:
public Subscription getSubscription(final String subscriptionId) throws NoSuchSubscriptionException, ServiceTemporarilyUnavailableException { try { return subscriptionsCache.get(subscriptionId); } catch (final UncheckedExecutionException e) { final Throwable cause = e.getCause(); if (cause instanceof NoSuchSubscriptionException) { throw new NoSuchSubscriptionException(e.getCause().getMessage()); } throw new ServiceTemporarilyUnavailableException(e.getCause().getMessage()); } catch (final ExecutionException e) { throw new ServiceTemporarilyUnavailableException(e.getCause().getMessage()); } }

Target:
public Subscription getSubscription(final String subscriptionId) throws NoSuchSubscriptionException, ServiceTemporarilyUnavailableException { try { return subscriptionsCache.get(subscriptionId); } catch (final UncheckedExecutionException e) { final Throwable cause = e.getCause(); if (cause instanceof NoSuchSubscriptionException) { throw (NoSuchSubscriptionException) cause; } throw new ServiceTemporarilyUnavailableException("Failed to access subscription cache", cause); } catch (final ExecutionException e) { throw new ServiceTemporarilyUnavailableException("Failed to access subscription cache", e.getCause()); } }
Source:
public DefaultAuditRecordService(AuditRecordRepository auditRecordRepository, ObjectMapper objectMapper) { super(); Assert.notNull(auditRecordRepository, "auditRecordRepository must not be null."); Assert.notNull(auditRecordRepository, "objectMapper must not be null."); this.auditRecordRepository = auditRecordRepository; this.objectMapper = objectMapper; }

Target:
public DefaultAuditRecordService(AuditRecordRepository auditRecordRepository, ObjectMapper objectMapper) { Assert.notNull(auditRecordRepository, "auditRecordRepository must not be null."); Assert.notNull(objectMapper, "objectMapper must not be null."); this.auditRecordRepository = auditRecordRepository; this.objectMapper = objectMapper; }
Source:
static Object checkAndCopy(Object val, boolean copy) { if (val == null) { } else if (val instanceof Number && !(val instanceof BigDecimal)) { } else if (val instanceof Boolean) { } else if (val instanceof String) { } else if (val instanceof CharSequence) { val = val.toString(); } else if (val instanceof JsonObject) { if (copy) { val = ((JsonObject) val).copy(); } } else if (val instanceof JsonArray) { if (copy) { val = ((JsonArray) val).copy(); } } else if (val instanceof Map) { if (copy) { val = (new JsonObject((Map)val)).copy(); } else { val = new JsonObject((Map)val); } } else if (val instanceof List) { if (copy) { val = (new JsonArray((List)val)).copy(); } else { val = new JsonArray((List)val); } } else if (val instanceof byte[]) { val = Base64.getEncoder().encodeToString((byte[])val); } else if (val instanceof Instant) { val = OffsetDateTime.ofInstant((Instant) val, ZoneOffset.UTC).format(ISO_OFFSET_DATE_TIME); } else { throw new IllegalStateException("Illegal type in JsonObject: " + val.getClass()); } return val; }

Target:
static Object checkAndCopy(Object val, boolean copy) { if (val == null) { } else if (val instanceof Number && !(val instanceof BigDecimal)) { } else if (val instanceof Boolean) { } else if (val instanceof String) { } else if (val instanceof Character) { } else if (val instanceof CharSequence) { val = val.toString(); } else if (val instanceof JsonObject) { if (copy) { val = ((JsonObject) val).copy(); } } else if (val instanceof JsonArray) { if (copy) { val = ((JsonArray) val).copy(); } } else if (val instanceof Map) { if (copy) { val = (new JsonObject((Map)val)).copy(); } else { val = new JsonObject((Map)val); } } else if (val instanceof List) { if (copy) { val = (new JsonArray((List)val)).copy(); } else { val = new JsonArray((List)val); } } else if (val instanceof byte[]) { val = Base64.getEncoder().encodeToString((byte[])val); } else { throw new IllegalStateException("Illegal type in JsonObject: " + val.getClass()); } return val; }
Source:
public OWLOntology loadOntology(IRI ontologyIRI, String catalogPath) throws IOException { OWLOntology ontology; File catalogFile = null; if (catalogPath != null) { catalogFile = new File(catalogPath); if (!catalogFile.isFile()) { throw new IOException(String.format(fileDoesNotExistError, catalogPath)); } } try { OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); if (catalogFile != null) { manager.setIRIMappers(Sets.newHashSet(new CatalogXmlIRIMapper(catalogFile))); } if (ontologyIRI.toString().endsWith("gz")) { ontology = loadCompressedOntology(new URL(ontologyIRI.toString()), catalogPath); } else { ontology = manager.loadOntologyFromOntologyDocument(ontologyIRI); } } catch (OWLOntologyCreationException e) { throw new IOException(e); } return ontology; }

Target:
public OWLOntology loadOntology(IRI ontologyIRI, String catalogPath) throws IOException { OWLOntology ontology; File catalogFile = null; if (catalogPath != null) { catalogFile = new File(catalogPath); if (!catalogFile.isFile()) { throw new IOException(String.format(fileDoesNotExistError, catalogPath)); } } try { OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); if (catalogFile != null) { manager.setIRIMappers(Sets.newHashSet(new CatalogXmlIRIMapper(catalogFile))); } if (ontologyIRI.toString().endsWith(".gz")) { ontology = loadCompressedOntology(new URL(ontologyIRI.toString()), catalogPath); } else { ontology = manager.loadOntologyFromOntologyDocument(ontologyIRI); } } catch (OWLOntologyCreationException e) { throw new IOException(e); } return ontology; }
Source:
public Builder setDefaultHandshakeMode(String defaultHandshakeMode) { if (config.serverOnly) { throw new IllegalStateException("default handshake modes are not supported for server only!"); } if (defaultHandshakeMode != null) { if (!defaultHandshakeMode.equals(DtlsEndpointContext.HANDSHAKE_MODE_AUTO) && !defaultHandshakeMode.equals(DtlsEndpointContext.HANDSHAKE_MODE_NONE)) { throw new IllegalArgumentException( "default handshake mode must be either \"" + DtlsEndpointContext.HANDSHAKE_MODE_AUTO + "\" or \"" + DtlsEndpointContext.HANDSHAKE_MODE_NONE + "\"!"); } } config.defaultHandshakeMode = defaultHandshakeMode; return this; }

Target:
public Builder setDefaultHandshakeMode(String defaultHandshakeMode) { if (config.serverOnly != null && config.serverOnly) { throw new IllegalStateException("default handshake modes are not supported for server only!"); } if (defaultHandshakeMode != null) { if (!defaultHandshakeMode.equals(DtlsEndpointContext.HANDSHAKE_MODE_AUTO) && !defaultHandshakeMode.equals(DtlsEndpointContext.HANDSHAKE_MODE_NONE)) { throw new IllegalArgumentException( "default handshake mode must be either \"" + DtlsEndpointContext.HANDSHAKE_MODE_AUTO + "\" or \"" + DtlsEndpointContext.HANDSHAKE_MODE_NONE + "\"!"); } } config.defaultHandshakeMode = defaultHandshakeMode; return this; }
Source:
public List<? extends Module> getJacksonModules() { return ImmutableList.of( new SimpleModule(getClass().getSimpleName()) .registerSubtypes( new NamedType(MaterializedViewSupervisorSpec.class, "view"), new NamedType(DerivativeDataSourceMetadata.class, "view") ) ); }

Target:
public List<? extends Module> getJacksonModules() { return ImmutableList.of( new SimpleModule(getClass().getSimpleName()) .registerSubtypes( new NamedType(MaterializedViewSupervisorSpec.class, "derivativeDataSource"), new NamedType(DerivativeDataSourceMetadata.class, "derivativeDataSource") ) ); }
Source:
private static void addMethod(FieldNode fieldNode, BlockStatement body, ClassNode type) { int visibility = ACC_PUBLIC; if (fieldNode.isStatic()) visibility |= ACC_STATIC; String propName = MetaClassHelper.capitalize(fieldNode.getName().substring(1)); fieldNode.getDeclaringClass().addMethod("get" + propName, visibility, type, Parameter.EMPTY_ARRAY, ClassNode.EMPTY_ARRAY, body); if (ClassHelper.boolean_TYPE.equals(type)) { fieldNode.getDeclaringClass().addMethod("is" + propName, visibility, type, Parameter.EMPTY_ARRAY, ClassNode.EMPTY_ARRAY, body); } }

Target:
private static void addMethod(FieldNode fieldNode, BlockStatement body, ClassNode type) { int visibility = ACC_PUBLIC; if (fieldNode.isStatic()) visibility |= ACC_STATIC; String propName = MetaClassHelper.capitalize(fieldNode.getName().substring(1)); fieldNode.getDeclaringClass().addMethod("get" + propName, visibility, type, Parameter.EMPTY_ARRAY, ClassNode.EMPTY_ARRAY, body); if (ClassHelper.boolean_TYPE.equals(type)) { fieldNode.getDeclaringClass().addMethod("is" + propName, visibility, type, Parameter.EMPTY_ARRAY, ClassNode.EMPTY_ARRAY, stmt(callThisX("get" + propName))); } }
Source:
public Filter newCorsFilter() { UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); CorsConfiguration config = new CorsConfiguration(); config.setAllowCredentials(true); config.setAllowedOrigins(stormpathCorsAllowedOrigins()); config.setAllowedHeaders(Arrays.asList("Content-Type", "Accept", "X-Requested-With", "remember-me")); config.setAllowedMethods(Arrays.asList("POST", "GET", "OPTIONS", "DELETE")); source.registerCorsConfiguration("/**", config); return new CorsFilter(source); }

Target:
public Filter newCorsFilter() { UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); CorsConfiguration config = new CorsConfiguration(); config.setAllowCredentials(true); config.setAllowedOrigins(stormpathCorsAllowedOrigins()); config.setAllowedHeaders(stormpathCorsAllowedHeaders()); config.setAllowedMethods(stormpathCorsAllowedMethods()); source.registerCorsConfiguration("/**", config); return new CorsFilter(source); }
Source:
public void cacheUpdateNewerResponse() throws Exception { final Map<String, String> headers = Collections.singletonMap( LastModifiedCachingWire.LAST_MODIFIED, LastModifiedCachingWireTest.LONG_AGO ); final MkContainer container = new MkGrizzlyContainer() .next( new MkAnswer.Simple( HttpURLConnection.HTTP_OK, headers.entrySet(), BODY.getBytes() ) ) .next(new MkAnswer.Simple(HttpURLConnection.HTTP_NOT_MODIFIED)) .next( new MkAnswer.Simple( HttpURLConnection.HTTP_OK, headers.entrySet(), BODY_UPDATED.getBytes() ) ) .next(new MkAnswer.Simple(HttpURLConnection.HTTP_NOT_MODIFIED)) .start(); try { final Request req = new JdkRequest(container.home()) .through(LastModifiedCachingWire.class); for (int idx = 0; idx < 2; ++idx) { req.fetch().as(RestResponse.class) .assertStatus(HttpURLConnection.HTTP_OK) .assertBody(Matchers.equalTo(BODY)); } for (int idx = 0; idx < 2; ++idx) { req.fetch().as(RestResponse.class) .assertStatus(HttpURLConnection.HTTP_OK) .assertBody(Matchers.equalTo(BODY_UPDATED)); } MatcherAssert.assertThat( container.queries(), Matchers.equalTo(2 + 2) ); } finally { container.stop(); } }

Target:
public void cacheUpdateNewerResponse() throws Exception { final Map<String, String> headers = Collections.singletonMap( LastModifiedCachingWire.LAST_MODIFIED, "Wed, 16 Nov 1995 04:58:08 GMT" ); final MkContainer container = new MkGrizzlyContainer() .next( new MkAnswer.Simple( HttpURLConnection.HTTP_OK, headers.entrySet(), LastModifiedCachingWireTest.BODY.getBytes() ) ) .next(new MkAnswer.Simple(HttpURLConnection.HTTP_NOT_MODIFIED)) .next( new MkAnswer.Simple( HttpURLConnection.HTTP_OK, headers.entrySet(), LastModifiedCachingWireTest.BODY_UPDATED.getBytes() ) ) .next(new MkAnswer.Simple(HttpURLConnection.HTTP_NOT_MODIFIED)) .start(); try { final Request req = new JdkRequest(container.home()) .through(LastModifiedCachingWire.class); for (int idx = 0; idx < 2; ++idx) { req.fetch().as(RestResponse.class) .assertStatus(HttpURLConnection.HTTP_OK) .assertBody( Matchers.equalTo(LastModifiedCachingWireTest.BODY) ); } for (int idx = 0; idx < 2; ++idx) { req.fetch().as(RestResponse.class) .assertStatus(HttpURLConnection.HTTP_OK) .assertBody( Matchers.equalTo( LastModifiedCachingWireTest.BODY_UPDATED ) ); } MatcherAssert.assertThat( container.queries(), Matchers.equalTo(2 + 2) ); } finally { container.stop(); } }
Source:
public Poller<CertificateOperation> createCertificate(String name, CertificatePolicy policy, Map<String, String> tags) { return new Poller<CertificateOperation>(Duration.ofSeconds(1), createPollOperation(name), actvationOperation(name, policy, tags), cancelOperation(name)); }

Target:
public Poller<CertificateOperation> createCertificate(String name, CertificatePolicy policy, Map<String, String> tags) { return new Poller<CertificateOperation>(Duration.ofSeconds(1), createPollOperation(name), activationOperation(name, policy, tags), cancelOperation(name)); }
Source:
private InterpreterResult executeQuery(String sql) throws IOException { HttpResponse response = prepareRequest(sql); String result; try { int code = response.getStatusLine().getStatusCode(); result = IOUtils.toString(response.getEntity().getContent(), "UTF-8"); if (code != 200) { StringBuilder errorMessage = new StringBuilder("Failed : HTTP error code " + code); logger.error("Failed to execute query: " + result); KylinErrorResponse kylinErrorResponse = KylinErrorResponse.fromJson(result); if (kylinErrorResponse == null) { logger.error("Cannot get json from string: " + result); if (code == 401) { errorMessage.append(". Error message: Unauthorized. This request requires " + "HTTP authentication. Please make sure your have set your credentials" + " correctly."); } else { errorMessage.append(". Error message: " + result); } } else { String exception = kylinErrorResponse.getException(); logger.error("The exception is " + exception); errorMessage.append(". Error message: " + exception); } return new InterpreterResult(InterpreterResult.Code.ERROR, errorMessage.toString()); } } catch (NullPointerException | IOException e) { throw new IOException(e); } return new InterpreterResult(InterpreterResult.Code.SUCCESS, formatResult(result)); }

Target:
private InterpreterResult executeQuery(String sql) throws IOException { HttpResponse response = prepareRequest(sql); String result; try { int code = response.getStatusLine().getStatusCode(); result = IOUtils.toString(response.getEntity().getContent(), "UTF-8"); if (code != 200) { StringBuilder errorMessage = new StringBuilder("Failed : HTTP error code " + code + " ."); logger.error("Failed to execute query: " + result); KylinErrorResponse kylinErrorResponse = KylinErrorResponse.fromJson(result); if (kylinErrorResponse == null) { logger.error("Cannot get json from string: " + result); if (code == 401) { errorMessage.append(" Error message: Unauthorized. This request requires " + "HTTP authentication. Please make sure your have set your credentials " + "correctly."); } else { errorMessage.append(" Error message: " + result + " ."); } } else { String exception = kylinErrorResponse.getException(); logger.error("The exception is " + exception); errorMessage.append(" Error message: " + exception + " ."); } return new InterpreterResult(InterpreterResult.Code.ERROR, errorMessage.toString()); } } catch (NullPointerException | IOException e) { throw new IOException(e); } return new InterpreterResult(InterpreterResult.Code.SUCCESS, formatResult(result)); }
Source:
private synchronized RequestFuture<ByteBuffer> initiateJoinGroup() { if (joinFuture == null) { disableHeartbeatThread(); state = MemberState.REBALANCING; if (lastRebalanceStartMs == -1L) lastRebalanceStartMs = time.milliseconds(); joinFuture = sendJoinGroupRequest(); joinFuture.addListener(new RequestFutureListener<ByteBuffer>() { @Override public void onSuccess(ByteBuffer value) { synchronized (AbstractCoordinator.this) { log.info("Successfully joined group with generation {}", generation.generationId); state = MemberState.STABLE; rejoinNeeded = false; lastRebalanceEndMs = time.milliseconds(); sensors.rebalanceLatency.record(lastRebalanceEndMs - lastRebalanceStartMs); lastRebalanceStartMs = -1L; if (heartbeatThread != null) heartbeatThread.enable(); } } @Override public void onFailure(RuntimeException e) { synchronized (AbstractCoordinator.this) { state = MemberState.UNJOINED; } } }); } return joinFuture; }

Target:
private synchronized RequestFuture<ByteBuffer> initiateJoinGroup() { if (joinFuture == null) { disableHeartbeatThread(); state = MemberState.REBALANCING; if (lastRebalanceStartMs == -1L) lastRebalanceStartMs = time.milliseconds(); joinFuture = sendJoinGroupRequest(); joinFuture.addListener(new RequestFutureListener<ByteBuffer>() { @Override public void onSuccess(ByteBuffer value) { synchronized (AbstractCoordinator.this) { log.info("Successfully joined group with generation {}", generation.generationId); state = MemberState.STABLE; rejoinNeeded = false; lastRebalanceEndMs = time.milliseconds(); sensors.successfulRebalanceSensor.record(lastRebalanceEndMs - lastRebalanceStartMs); lastRebalanceStartMs = -1L; if (heartbeatThread != null) heartbeatThread.enable(); } } @Override public void onFailure(RuntimeException e) { synchronized (AbstractCoordinator.this) { state = MemberState.UNJOINED; sensors.failedRebalanceSensor.record(); } } }); } return joinFuture; }
Source:
public static Type fromValue(String type) { return types.get(type); }

Target:
public static Type fromValue(String type) { if (type != null) { for (Type value : Type.values()) { if (type.equals(value.type)) { return value; } } return UNRECOGNIZED; } return null; }
Source:
private static <T> ImmutableList<ImmutableList<T>> toImmutables(List<List<T>> lists) { ImmutableList.Builder<ImmutableList<T>> builder = ImmutableList.builder(); for (List<T> innerList : lists) { if (innerList instanceof ImmutableList) { builder.add((ImmutableList<T>) innerList); } else { builder.add(ImmutableList.copyOf(innerList)); } } return builder.build(); }

Target:
private static <T> ImmutableList<ImmutableList<T>> toImmutables(List<List<T>> lists) { return lists.stream() .map(ImmutableList::copyOf) .collect(Guavate.toImmutableList()); }
Source:
public Navigator getNavigator() { return BaseUI.getCurrent().getNavigator(); }

Target:
public Navigator getNavigator() { return BaseUI.getCurrentNavigator(); }
Source:
private String replaceEscapedLiterals(String resolvedMessage) { resolvedMessage = LEFT_BRACE.matcher(resolvedMessage).replaceAll("{"); resolvedMessage = RIGHT_BRACE.matcher(resolvedMessage).replaceAll("}"); resolvedMessage = SLASH.matcher(resolvedMessage).replaceAll("\\"); resolvedMessage = DOLLAR.matcher(resolvedMessage).replaceAll("$"); return resolvedMessage; }

Target:
private String replaceEscapedLiterals(String resolvedMessage) { resolvedMessage = LEFT_BRACE.matcher(resolvedMessage).replaceAll("{"); resolvedMessage = RIGHT_BRACE.matcher(resolvedMessage).replaceAll("}"); resolvedMessage = SLASH.matcher(resolvedMessage).replaceAll(Matcher.quoteReplacement("\\")); resolvedMessage = DOLLAR.matcher(resolvedMessage).replaceAll(Matcher.quoteReplacement("$")); return resolvedMessage; }