auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
@Override protected DynamicFeature getAuthDynamicFeature(ContainerRequestFilter authFilter) { final Authenticator<BasicCredentials, JsonPrincipal> jsonAuthenticator = credentials -> { if (credentials.getUsername().equals(JSON_USERNAME)) { return Optional.<JsonPrincipal>of(new JsonPrincipal(credentials.getUsername())); } else { return Optional.empty(); } }; final Authenticator<BasicCredentials, NullPrincipal> nullAuthenticator = credentials -> { if (credentials.getUsername().equals(NULL_USERNAME)) { return Optional.<NullPrincipal>of(new NullPrincipal()); } else { return Optional.empty(); } }; final BasicCredentialAuthFilter jsonAuthFilter = new BasicCredentialAuthFilter.Builder<JsonPrincipal>() .setAuthenticator(jsonAuthenticator) .buildAuthFilter(); final BasicCredentialAuthFilter nullAuthFilter = new BasicCredentialAuthFilter.Builder<NullPrincipal>() .setAuthenticator(nullAuthenticator) .buildAuthFilter(); return new PolymorphicAuthDynamicFeature(ImmutableMap.of( JsonPrincipal.class, jsonAuthFilter, NullPrincipal.class, nullAuthFilter )); }

Target:
@Override protected DynamicFeature getAuthDynamicFeature(ContainerRequestFilter authFilter) { final Authenticator<BasicCredentials, JsonPrincipal> jsonAuthenticator = credentials -> { if (credentials.getUsername().equals(JSON_USERNAME)) { return Optional.of(new JsonPrincipal(credentials.getUsername())); } else { return Optional.empty(); } }; final Authenticator<BasicCredentials, NullPrincipal> nullAuthenticator = credentials -> { if (credentials.getUsername().equals(NULL_USERNAME)) { return Optional.of(new NullPrincipal()); } else { return Optional.empty(); } }; final BasicCredentialAuthFilter jsonAuthFilter = new BasicCredentialAuthFilter.Builder<JsonPrincipal>() .setAuthenticator(jsonAuthenticator) .buildAuthFilter(); final BasicCredentialAuthFilter nullAuthFilter = new BasicCredentialAuthFilter.Builder<NullPrincipal>() .setAuthenticator(nullAuthenticator) .buildAuthFilter(); return new PolymorphicAuthDynamicFeature<Principal>(ImmutableMap.of( JsonPrincipal.class, jsonAuthFilter, NullPrincipal.class, nullAuthFilter )); }
Source:
public void getRadiologyOrders_shouldReturnAllRadiologyOrdersForGivenUrgency() throws Exception { Patient patient = patientService.getPatient(PATIENT_ID_WITH_ONE_VOIDED_AND_TWO_NON_VOIDED_RADIOLOGY_ORDERS); RadiologyOrderSearchCriteria radiologyOrderSearchCriteria = new RadiologyOrderSearchCriteria.Builder().withPatient(patient) .withUrgency(Urgency.STAT) .build(); List<RadiologyOrder> radiologyOrders = radiologyOrderService.getRadiologyOrders(radiologyOrderSearchCriteria); assertThat(radiologyOrders.size(), is(2)); for (RadiologyOrder radiologyOrder : radiologyOrders) { assertThat(radiologyOrder.getUrgency(), is(Urgency.STAT)); } }

Target:
public void getRadiologyOrders_shouldReturnAllRadiologyOrdersForGivenUrgency() throws Exception { RadiologyOrderSearchCriteria radiologyOrderSearchCriteria = new RadiologyOrderSearchCriteria.Builder().withUrgency(Urgency.STAT) .build(); List<RadiologyOrder> radiologyOrders = radiologyOrderService.getRadiologyOrders(radiologyOrderSearchCriteria); assertThat(radiologyOrders.size(), is(5)); for (RadiologyOrder radiologyOrder : radiologyOrders) { assertThat(radiologyOrder.getUrgency(), is(Urgency.STAT)); } }
Source:
protected String getUrlValue() { return getUrlField().getSelectedItem().toString(); }

Target:
protected String getUrlValue() { Object item = getUrlField().getSelectedItem(); if (item != null) { return item.toString(); } return null; }
Source:
private void stage(final IStructuredSelection selection) { awaitStageThread(); stageThread = new Thread() { public void run() { syncLockUI(); try { Git git = new Git(currentRepository); AddCommand add = null; RmCommand rm = null; Iterator iterator = selection.iterator(); while (iterator.hasNext()) { StagingEntry entry = (StagingEntry) iterator.next(); switch (entry.getState()) { case ADDED: case CHANGED: case REMOVED: break; case CONFLICTING: case MODIFIED: case PARTIALLY_MODIFIED: case UNTRACKED: if (add == null) add = git.add(); add.addFilepattern(entry.getPath()); break; case MISSING: if (rm == null) rm = git.rm(); rm.addFilepattern(entry.getPath()); break; } } if (add != null) try { add.call(); } catch (NoFilepatternException e1) { } catch (Exception e2) { Activator.error(e2.getMessage(), e2); } if (rm != null) try { rm.call(); } catch (NoFilepatternException e) { } catch (Exception e2) { Activator.error(e2.getMessage(), e2); } } finally { syncUnlockUI(); } } }; stageThread.start(); }

Target:
private void stage(final IStructuredSelection selection) { awaitStageThread(); stageThread = new Thread() { public void run() { asyncLockUI(); try { Git git = new Git(currentRepository); AddCommand add = null; RmCommand rm = null; Iterator iterator = selection.iterator(); while (iterator.hasNext()) { StagingEntry entry = (StagingEntry) iterator.next(); switch (entry.getState()) { case ADDED: case CHANGED: case REMOVED: break; case CONFLICTING: case MODIFIED: case PARTIALLY_MODIFIED: case UNTRACKED: if (add == null) add = git.add(); add.addFilepattern(entry.getPath()); break; case MISSING: if (rm == null) rm = git.rm(); rm.addFilepattern(entry.getPath()); break; } } if (add != null) try { add.call(); } catch (NoFilepatternException e1) { } catch (Exception e2) { Activator.error(e2.getMessage(), e2); } if (rm != null) try { rm.call(); } catch (NoFilepatternException e) { } catch (Exception e2) { Activator.error(e2.getMessage(), e2); } } finally { asyncUnlockUI(); } } }; stageThread.start(); }
Source:
public void onResponse(ReplicaId replicaId, boolean isSuccessFul) { inflightCount--; if (isSuccessFul) { succeededCount++; } else { failedCount++; } getTracker(replicaId).update(time.milliseconds() - replicaRequestSendTimes.remove(replicaId)); }

Target:
public void onResponse(ReplicaId replicaId, boolean isSuccessFul) { super.onResponse(replicaId, isSuccessFul); long elapsedTime; if (unexpiredRequestSendTimes.containsKey(replicaId)) { elapsedTime = time.milliseconds() - unexpiredRequestSendTimes.remove(replicaId); } else { elapsedTime = time.milliseconds() - expiredRequestSendTimes.remove(replicaId); } getLatencyHistogram(replicaId).update(elapsedTime); }
Source:
private void doPublish(EventMessage<?> message, T target) { getHandler(message, target).ifPresent(h -> { try { h.handle(message, target); } catch (Exception e) { throw new MessageHandlerInvocationException( format("Error handling event of type [%s] in aggregate", message.getPayloadType()), e); } }); children.forEach(i -> i.publish(message, target)); }

Target:
private void doPublish(EventMessage<?> message, T target) { getHandler(message, target.getClass()).ifPresent(h -> { try { h.handle(message, target); } catch (Exception e) { throw new MessageHandlerInvocationException( format("Error handling event of type [%s] in aggregate", message.getPayloadType()), e); } }); children.forEach(i -> i.publish(message, target)); }
Source:
public <T> T request(Class<T> type) throws CamelExecutionException { validate(); T result; if (type == Exchange.class) { result = (T)template().request(endpoint, processorSupplier.get()); } else if (type == Message.class) { result = (T)template().request(endpoint, processorSupplier.get()).getIn(); } else { Exchange exchange = template().send(endpoint, ExchangePattern.InOut, processorSupplier.get()); result = context.getTypeConverter().convertTo( type, ExchangeHelper.extractResultBody(exchange, exchange.getPattern()) ); } return result; }

Target:
public <T> T request(Class<T> type) throws CamelExecutionException { T result; if (type == Exchange.class) { result = (T)template().request(endpoint, processorSupplier.get()); } else if (type == Message.class) { Exchange exchange = template().request(endpoint, processorSupplier.get()); result = exchange.hasOut() ? (T)exchange.getOut() : (T)exchange.getIn(); } else { Exchange exchange = template().send(endpoint, ExchangePattern.InOut, processorSupplier.get()); result = context.getTypeConverter().convertTo( type, ExchangeHelper.extractResultBody(exchange, exchange.getPattern()) ); } return result; }
Source:
private TestResult runAll() throws Exception { List<String> testClassNames = new ArrayList<>(); Files.walk(Paths.get(projectPath, "target", "test-classes")).forEach(filePath -> { if (Files.isRegularFile(filePath) && filePath.toString().toLowerCase().endsWith(".class")) { String path = Paths.get(projectPath, "target", "test-classes").relativize(filePath).toString(); String className = path.replace('/', '.'); className = className.replace('\\', '.'); className = className.substring(0, className.length() - 6); testClassNames.add(className); } }); List<Class> testableClasses = new ArrayList<>(); for (String className : testClassNames) { Class<?> clazz = Class.forName(className, false, projectClassLoader); if (isTestable(clazz)) { testableClasses.add(clazz); } } return runTestClasses(testableClasses.toArray(new Class[testableClasses.size()])); }

Target:
private TestResult runAll() throws Exception { List<String> testClassNames = new ArrayList<>(); Files.walk(Paths.get(projectPath, "target", "test-classes")).forEach(filePath -> { if (Files.isRegularFile(filePath) && filePath.toString().toLowerCase().endsWith(".class")) { String path = Paths.get(projectPath, "target", "test-classes").relativize(filePath).toString(); String className = path.replace(File.separatorChar, '.'); className = className.substring(0, className.length() - 6); testClassNames.add(className); } }); List<Class> testableClasses = new ArrayList<>(); for (String className : testClassNames) { Class<?> clazz = Class.forName(className, false, projectClassLoader); if (isTestable(clazz)) { testableClasses.add(clazz); } } return runTestClasses(testableClasses.toArray(new Class[testableClasses.size()])); }
Source:
private void showCallout(String title){ RelativeLayout calloutLayout = new RelativeLayout(getApplicationContext()); TextView calloutContent = new TextView(getApplicationContext()); calloutContent.setId(R.id.textview); calloutContent.setTextColor(Color.BLACK); calloutContent.setTextSize(18); calloutContent.setPadding(0,10,10,0); calloutContent.setText(title); RelativeLayout.LayoutParams relativeParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); relativeParams.addRule(RelativeLayout.RIGHT_OF, calloutContent.getId()); ImageView imageView = new ImageView(getApplicationContext()); imageView.setImageDrawable(getResources().getDrawable(R.drawable.ic_info_outline_black_18dp)); imageView.setLayoutParams(relativeParams); imageView.setOnClickListener(new ImageViewOnclickListener()); calloutLayout.addView(calloutContent); calloutLayout.addView(imageView); mCallout.setLocation(mMapView.screenToLocation(mClickPoint)); mCallout.setContent(calloutLayout); mCallout.show(); }

Target:
private void showCallout(String title){ RelativeLayout calloutLayout = new RelativeLayout(getApplicationContext()); TextView calloutContent = new TextView(getApplicationContext()); calloutContent.setId(R.id.textview); calloutContent.setTextColor(Color.BLACK); calloutContent.setTextSize(18); calloutContent.setPadding(0,10,10,0); calloutContent.setText(title); RelativeLayout.LayoutParams relativeParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); relativeParams.addRule(RelativeLayout.RIGHT_OF, calloutContent.getId()); ImageView imageView = new ImageView(getApplicationContext()); imageView.setImageDrawable(ContextCompat.getDrawable(getApplicationContext(), R.drawable.ic_info_outline_black_18dp)); imageView.setLayoutParams(relativeParams); imageView.setOnClickListener(new ImageViewOnclickListener()); calloutLayout.addView(calloutContent); calloutLayout.addView(imageView); mCallout.setLocation(mMapView.screenToLocation(mClickPoint)); mCallout.setContent(calloutLayout); mCallout.show(); }
Source:
static DataInfo getDataInfo(String storedText) { if (TextUtils.isEmpty(storedText)) { throw new NullPointerException("Text should not be null or empty"); } int index = storedText.indexOf(INFO_DELIMITER, 0); if (index == -1) { return getOldDataInfo(storedText); } return getNewDataInfo(storedText, index); }

Target:
static DataInfo getDataInfo(String storedText) { HawkUtils.checkNullOrEmpty("Text", storedText); int start = storedText.indexOf(INFO_DELIMITER); if (start == -1) { throw new IllegalArgumentException("storedText is not valid"); } String keyClass = storedText.substring(0, start); int index = storedText.indexOf(INFO_DELIMITER, ++start); if (index == -1) { throw new IllegalArgumentException("Text should contain delimiter"); } String valueClass = storedText.substring(start, index); char dataType = storedText.charAt(++index); char newVersion = storedText.charAt(++index); if (newVersion != NEW_VERSION) { throw new IllegalStateException("storedText is not valid"); } index += 2; String cipherText = storedText.substring(index); HawkUtils.checkNullOrEmpty("Cipher text", cipherText); Class<?> keyClazz = null; Class<?> valueClazz = null; if (!TextUtils.isEmpty(keyClass)) { try { keyClazz = Class.forName(keyClass); } catch (ClassNotFoundException e) { Logger.d(e.getMessage()); } } if (!TextUtils.isEmpty(valueClass)) { try { valueClazz = Class.forName(valueClass); } catch (ClassNotFoundException e) { Logger.d(e.getMessage()); } } return new DataInfo(dataType, cipherText, keyClazz, valueClazz); }
Source:
public void testOnlyPostScriptContainsAPIBinding() throws InvalidScriptException { Script s = scriptWithApiBindingClient(); Script s2 = scriptWithoutApiBinding(); FlowScript fs = flowScriptWithoutApiBinding(); Mockito.when(it.getPreScript()).thenReturn(s2); Mockito.when(it.getPostScript()).thenReturn(s); Mockito.when(sec.getScript()).thenReturn(s2); Mockito.when(fe.getEnvScript()).thenReturn(s2); Mockito.when(it.getFlowScript()).thenReturn(fs); Boolean result = new CheckEligibleTaskDescriptorScript().isTaskContainsAPIBinding(etd); assertEquals(true, result); }

Target:
public void testOnlyPostScriptContainsAPIBinding() throws InvalidScriptException { Script s = scriptWithApiBindingClient(); Script s2 = scriptWithoutApiBinding(); FlowScript fs = flowScriptWithoutApiBinding(); Mockito.when(it.getPreScript()).thenReturn(s2); Mockito.when(it.getPostScript()).thenReturn(s); Mockito.when(sec.getScript()).thenReturn(s2); Mockito.when(fe.getEnvScript()).thenReturn(s2); Mockito.when(it.getFlowScript()).thenReturn(fs); assertTrue(new CheckEligibleTaskDescriptorScript().isTaskContainsAPIBinding(etd)); }
Source:
public Map<String, Set<DatastreamTask>> assign(List<Datastream> datastreams, List<String> instances, Map<String, Set<DatastreamTask>> currentAssignment) { Map<String, Set<DatastreamTask>> assignment = new HashMap<>(); for (String instance : instances) { Set<DatastreamTask> newAssignmentForInstance = new HashSet<>(); assignment.put(instance, newAssignmentForInstance); if (currentAssignment != null && currentAssignment.containsKey(instance)) { Collection<DatastreamTask> currentAssignmentForInstance = currentAssignment.get(instance); for (Datastream datastream : datastreams) { Optional<DatastreamTask> foundDatastreamTask = currentAssignmentForInstance.stream().filter(x -> x.getDatastreams().contains(datastream.getName())) .findFirst(); if (!foundDatastreamTask.isPresent()) { newAssignmentForInstance.add(new DatastreamTaskImpl(datastream)); } else { newAssignmentForInstance.add(foundDatastreamTask.get()); } } } else { for (Datastream datastream : datastreams) { newAssignmentForInstance.add(new DatastreamTaskImpl(datastream)); } } } return assignment; }

Target:
public Map<String, Set<DatastreamTask>> assign(List<Datastream> datastreams, List<String> instances, Map<String, Set<DatastreamTask>> currentAssignment) { Map<String, Set<DatastreamTask>> assignment = new HashMap<>(); for (String instance : instances) { Set<DatastreamTask> newAssignmentForInstance = new HashSet<>(); assignment.put(instance, newAssignmentForInstance); if (currentAssignment != null && currentAssignment.containsKey(instance)) { Map<String, DatastreamTask> datastreamToTaskMap = new HashMap<>(); Collection<DatastreamTask> currentAssignmentForInstance = currentAssignment.get(instance); for(DatastreamTask datastreamTask : currentAssignmentForInstance) { datastreamTask.getDatastreams().stream().forEach(d -> datastreamToTaskMap.put(d, datastreamTask)); } for (Datastream datastream : datastreams) { DatastreamTask foundDatastreamTask = datastreamToTaskMap.get(datastream.getName()); if (foundDatastreamTask == null) { newAssignmentForInstance.add(new DatastreamTaskImpl(datastream)); } else { newAssignmentForInstance.add(foundDatastreamTask); } } } else { for (Datastream datastream : datastreams) { newAssignmentForInstance.add(new DatastreamTaskImpl(datastream)); } } } return assignment; }
Source:
switch (BuildConfig.FLAVOR) { case "prod": case "beta": { DNS_SEED = new String[]{"dnsseed.dash.org"}; BIP44_PATH = DeterministicKeyChain.BIP44_ACCOUNT_ZERO_PATH; NETWORK_PARAMETERS = MainNetParams.get(); IS_PROD_BUILD = true; break; } case "_testNet3": { DNS_SEED = new String[]{"95.183.51.146", "35.161.101.35", "54.91.130.170"}; BIP44_PATH = DeterministicKeyChain.BIP44_ACCOUNT_ZERO_PATH_TESTNET; NETWORK_PARAMETERS = TestNet3Params.get(); IS_PROD_BUILD = false; break; } case "devNet": { DNS_SEED = new String[]{ "devnet-maithai.thephez.com", "34.212.238.34", "34.222.226.15", "52.25.134.163", "18.237.18.236", "54.201.32.143", "18.237.223.92", "54.187.24.244", "34.216.182.200", "54.244.102.48", "34.222.227.120", "34.222.92.227", "54.185.85.42", "34.209.237.218"}; BIP44_PATH = EvolutionWalletAppKit.EVOLUTION_ACCOUNT_PATH; NETWORK_PARAMETERS = DevNetParams.get("maithai", "yMtULrhoxd8vRZrsnFobWgRTidtjg2Rnjm", 20001, DNS_SEED); IS_PROD_BUILD = false; break; } default: { throw new IllegalStateException("Unsupported flavor " + BuildConfig.FLAVOR); } }

Target:
switch (BuildConfig.FLAVOR) { case "prod": case "beta": { DNS_SEED = new String[]{"dnsseed.dash.org"}; BIP44_PATH = DeterministicKeyChain.BIP44_ACCOUNT_ZERO_PATH; NETWORK_PARAMETERS = MainNetParams.get(); IS_PROD_BUILD = true; FILENAME_NETWORK_SUFFIX = ""; WALLET_NAME_CURRENCY_CODE = "dash"; break; } case "_testNet3": { DNS_SEED = new String[]{"95.183.51.146", "35.161.101.35", "54.91.130.170"}; BIP44_PATH = DeterministicKeyChain.BIP44_ACCOUNT_ZERO_PATH_TESTNET; NETWORK_PARAMETERS = TestNet3Params.get(); IS_PROD_BUILD = false; FILENAME_NETWORK_SUFFIX = "-testnet"; WALLET_NAME_CURRENCY_CODE = "tdash"; break; } case "devNet": { DNS_SEED = new String[]{ "devnet-maithai.thephez.com", "54.187.113.35", "54.200.201.200", "34.216.233.163", "34.221.188.185", "54.189.63.67", "52.40.117.135", "54.187.111.107", "34.212.68.164", "18.237.142.23", "54.202.73.177" }; BIP44_PATH = DeterministicKeyChain.BIP44_ACCOUNT_ZERO_PATH_TESTNET; NETWORK_PARAMETERS = DevNetParams.get("maithai", "yMtULrhoxd8vRZrsnFobWgRTidtjg2Rnjm", 20001, DNS_SEED); IS_PROD_BUILD = false; FILENAME_NETWORK_SUFFIX = "-devnet"; WALLET_NAME_CURRENCY_CODE = "tdash"; break; } default: { throw new IllegalStateException("Unsupported flavor " + BuildConfig.FLAVOR); } }
Source:
public GremlinServer(final Settings settings) { settings.optionalMetrics().ifPresent(GremlinServer::configureMetrics); this.settings = settings; provideDefaultForGremlinPoolSize(settings); this.isEpollEnabled = settings.useEpollEventLoop && SystemUtils.IS_OS_LINUX; if(settings.useEpollEventLoop && !SystemUtils.IS_OS_LINUX){ logger.warn("cannot use epoll in non-linux env, falling back to NIO"); } Runtime.getRuntime().addShutdownHook(new Thread(() -> this.stop().join(), SERVER_THREAD_PREFIX + "shutdown")); final ThreadFactory threadFactoryBoss = ThreadFactoryUtil.create("boss-%d"); if(isEpollEnabled){ bossGroup = new EpollEventLoopGroup(settings.threadPoolBoss, threadFactoryBoss); } else { bossGroup = new NioEventLoopGroup(settings.threadPoolBoss, threadFactoryBoss); } final ThreadFactory threadFactoryWorker = ThreadFactoryUtil.create("worker-%d"); if(isEpollEnabled) { workerGroup = new EpollEventLoopGroup(settings.threadPoolWorker, threadFactoryWorker); }else { workerGroup = new NioEventLoopGroup(settings.threadPoolWorker, threadFactoryWorker); } serverGremlinExecutor = new ServerGremlinExecutor(settings, null, workerGroup, null); gremlinExecutorService = serverGremlinExecutor.getGremlinExecutorService(); OpLoader.init(settings); }

Target:
public GremlinServer(final Settings settings) { settings.optionalMetrics().ifPresent(GremlinServer::configureMetrics); this.settings = settings; provideDefaultForGremlinPoolSize(settings); this.isEpollEnabled = settings.useEpollEventLoop && SystemUtils.IS_OS_LINUX; if(settings.useEpollEventLoop && !SystemUtils.IS_OS_LINUX){ logger.warn("cannot use epoll in non-linux env, falling back to NIO"); } Runtime.getRuntime().addShutdownHook(new Thread(() -> this.stop().join(), SERVER_THREAD_PREFIX + "shutdown")); final ThreadFactory threadFactoryBoss = ThreadFactoryUtil.create("boss-%d"); if(isEpollEnabled){ bossGroup = new EpollEventLoopGroup(settings.threadPoolBoss, threadFactoryBoss); } else { bossGroup = new NioEventLoopGroup(settings.threadPoolBoss, threadFactoryBoss); } final ThreadFactory threadFactoryWorker = ThreadFactoryUtil.create("worker-%d"); if(isEpollEnabled) { workerGroup = new EpollEventLoopGroup(settings.threadPoolWorker, threadFactoryWorker); }else { workerGroup = new NioEventLoopGroup(settings.threadPoolWorker, threadFactoryWorker); } serverGremlinExecutor = new ServerGremlinExecutor(settings, null, workerGroup); gremlinExecutorService = serverGremlinExecutor.getGremlinExecutorService(); OpLoader.init(settings); }
Source:
List<Long> query(String queryString, int maxResults) { LOGGER.debug(queryString); SolrQuery query = new SolrQuery(queryString).setRows(maxResults); QueryResponse rsp; try { rsp = server.query(query); } catch (SolrServerException e) { throw new IndexException("Could not read Question from index", e); } SolrDocumentList docs = rsp.getResults(); List<Long> ids = new ArrayList<>(); for (SolrDocument doc : docs) { ids.add(Long.parseLong((String) doc.getFieldValue("id"))); } return ids; }

Target:
private List<Long> query(String queryString, int maxResults) { LOGGER.debug(queryString); SolrQuery query = new SolrQuery(queryString).setRows(maxResults); QueryResponse rsp; try { rsp = server.query(query); } catch (SolrServerException e) { throw new IndexException("Could not read Question from index", e); } SolrDocumentList docs = rsp.getResults(); List<Long> ids = new ArrayList<>(); for (SolrDocument doc : docs) { ids.add(Long.parseLong((String) doc.getFieldValue("id"))); } return ids; }
Source:
public List<IMethodInstance> intercept(List<IMethodInstance> methods, ITestContext context) { Comparator<IMethodInstance> compareByPackage = (IMethodInstance m1, IMethodInstance m2) -> { int val = 0; String p1 = getPackageName(m1); String p2 = getPackageName(m2); val = p1.compareTo(p2); val -= packagePriorityOffset(p1); val += packagePriorityOffset(p2); return val; }; Comparator<IMethodInstance> compareByClassPriority = Comparator.comparing((IMethodInstance m) -> getClassPriority(m)); Comparator<IMethodInstance> compareByClassName = Comparator.comparing((IMethodInstance m) -> getClassName(m)); Comparator<IMethodInstance> compareByMethodPriority = Comparator.comparing((IMethodInstance m) -> getMethodPriority(m)); Comparator<IMethodInstance> comparator = compareByPackage.thenComparing(compareByClassPriority) .thenComparing(compareByClassName) .thenComparing(compareByMethodPriority); IMethodInstance[] array = methods.toArray(new IMethodInstance[methods .size()]); Arrays.sort(array, comparator); return Arrays.asList(array); }

Target:
public List<IMethodInstance> intercept(List<IMethodInstance> methods, ITestContext context) { Comparator<IMethodInstance> compareByPackage = (m1, m2) -> { String p1 = getPackageName(m1); String p2 = getPackageName(m2); return p1.compareTo(p2) - getPackagePriority(p1) + getPackagePriority(p2); }; Comparator<IMethodInstance> comparator = compareByPackage .thenComparing(m -> getClassPriority(m)) .thenComparing(m -> getClassName(m)) .thenComparing(m -> getMethodPriority(m)); methods.sort(comparator); return methods; }
Source:
public HDFSTransactionLogReaderV2(SequenceFile.Reader reader) { super(reader); this.transactionEdits = new ArrayDeque<>(); this.key = new LongWritable(); this.rawKey = new DataOutputBuffer(); this.value = new ByteArrayOutputStream(Integer.SIZE); this.outputStream = new DataOutputStream(value); }

Target:
public HDFSTransactionLogReaderV2(SequenceFile.Reader reader) { this.reader = reader; this.transactionEdits = new ArrayDeque<>(); this.key = new LongWritable(); this.commitMarkerCodec = new CommitMarkerCodec(); }
Source:
<T extends ParseObject> List<T> convertFindResponse(ParseQuery.State<T> state, JSONObject response) throws JSONException { ArrayList<T> answer = new ArrayList<>(); JSONArray results = response.getJSONArray("results"); if (results == null) { PLog.d(TAG, "null results in find response"); } else { String resultClassName = response.optString("className", null); if (resultClassName == null) { resultClassName = state.className(); } boolean isSubset = state.selectedKeys() != null; JSONArray selectedKeys = isSubset ? new JSONArray(state.selectedKeys()) : null; for (int i = 0; i < results.length(); ++i) { JSONObject data = results.getJSONObject(i); if (isSubset) data.put(ParseObject.KEY_SELECTED_KEYS, selectedKeys); T object = ParseObject.fromJSON(data, resultClassName, !isSubset); answer.add(object); ParseQuery.RelationConstraint relation = (ParseQuery.RelationConstraint) state.constraints().get("$relatedTo"); if (relation != null) { relation.getRelation().addKnownObject(object); } } } return answer; }

Target:
<T extends ParseObject> List<T> convertFindResponse(ParseQuery.State<T> state, JSONObject response) throws JSONException { ArrayList<T> answer = new ArrayList<>(); JSONArray results = response.getJSONArray("results"); if (results == null) { PLog.d(TAG, "null results in find response"); } else { String resultClassName = response.optString("className", null); if (resultClassName == null) { resultClassName = state.className(); } for (int i = 0; i < results.length(); ++i) { JSONObject data = results.getJSONObject(i); T object = ParseObject.fromJSON(data, resultClassName, ParseDecoder.get(), state.selectedKeys()); answer.add(object); ParseQuery.RelationConstraint relation = (ParseQuery.RelationConstraint) state.constraints().get("$relatedTo"); if (relation != null) { relation.getRelation().addKnownObject(object); } } } return answer; }
Source:
private void validateReplacements(String config) { Pattern pattern = Pattern.compile("\\$\\{(\\d+)}"); Matcher partsMatcher = pattern.matcher(getString(config)); String dir = partsMatcher.replaceAll("").replace("${topic}", ""); Pattern invalid = Pattern.compile("\\$\\{.*}"); Matcher invalidMatcher = invalid.matcher(dir); if (invalidMatcher.find()) { throw new ConfigException( String.format( "%s: %s contains an invalid ${} substitution %s", config, getString(config), invalidMatcher.group() ) ); } }

Target:
private void validateReplacements(String config) { Matcher partsMatcher = SUBSTITUTION_PATTERN.matcher(getString(config)); String dir = partsMatcher.replaceAll("").replace("${topic}", ""); Matcher invalidMatcher = INVALID_SUB_PATTERN.matcher(dir); if (invalidMatcher.find()) { throw new ConfigException( String.format( "%s: %s contains an invalid ${} substitution %s. Valid substitutions are ${topic} " + "and ${n} where n >= 0.", config, getString(config), invalidMatcher.group() ) ); } }
Source:
protected Object doExecute() throws Exception { printInitCommand("Removing all actions of the queue"); try { IResourceManager resourceManager = getResourceManager(); String[] argsRouterName = new String[2]; argsRouterName = splitResourceName(resourceId); IResourceIdentifier resourceIdentifier = null; resourceIdentifier = resourceManager.getIdentifierFromResourceName(argsRouterName[0], argsRouterName[1]); if (resourceIdentifier == null) { printError("Could not get resource with name: " + argsRouterName[0] + ":" + argsRouterName[1]); printEndCommand(); return -1; } IResource resource = resourceManager.getResource(resourceIdentifier); validateResource(resource); ICapability queue = getCapability(resource.getCapabilities(), QueueManager.QUEUE); if (queue == null) { printError("Could not found capability " + QueueManager.QUEUE + " in resource " + resourceId); return -1; } List<IAction> listActions = (List<IAction>) queue.sendMessage(QueueConstants.GETQUEUE, null); int numActions = listActions.size(); for (int i = 0; i < numActions; i++) { ModifyParams params = ModifyParams.newRemoveOperation(0); Response resp = (Response) queue.sendMessage(QueueConstants.MODIFY, params); } printInfo("Removed " + numActions + " actions from the queue"); } catch (Exception e) { printError(e.getMessage()); printEndCommand(); return -1; } printEndCommand(); return null; }

Target:
protected Object doExecute() throws Exception { printInitCommand("Removing all actions of the queue"); try { IResource resource = getResourceFromFriendlyName(resourceId); validateResource(resource); QueueManager queue = (QueueManager) getCapability(resource.getCapabilities(), QueueManager.QUEUE); queue.empty(); printInfo("Removed all actions from the queue"); } catch (Exception e) { printError(e.getMessage()); printEndCommand(); return -1; } printEndCommand(); return null; }
Source:
public int run() throws Exception { SitePaths sitePaths = new SitePaths(getSitePath()); File newSecureStoreFile = new File(newSecureStoreLib); if (!newSecureStoreFile.exists()) { throw new RuntimeException(String.format("File %s doesn't exists", newSecureStoreFile.getAbsolutePath())); } String newSecureStore = getNewSecureStoreClassName(newSecureStoreFile); String currentSecureStoreName = getCurrentSecureStoreClassName(sitePaths); if (currentSecureStoreName.equals(newSecureStore)) { log.error( "Old and new SecureStore implementation names are the same. Migration will not work"); return -1; } IoUtil.loadJARs(newSecureStoreFile); SiteLibraryLoaderUtil.loadSiteLib(sitePaths.lib_dir); log.info("Current secureStoreClass property ({}) will be replaced with {}", currentSecureStoreName, newSecureStore); Injector dbInjector = createDbInjector(SINGLE_USER); SecureStore currentStore = getSecureStore(currentSecureStoreName, dbInjector); SecureStore newStore = getSecureStore(newSecureStore, dbInjector); migrateProperties(currentStore, newStore); removeOldLib(sitePaths, currentSecureStoreName); copyNewLib(sitePaths, newSecureStoreFile); updateGerritConfig(sitePaths, newSecureStore); return 0; }

Target:
public int run() throws Exception { SitePaths sitePaths = new SitePaths(getSitePath()); File newSecureStoreFile = new File(newSecureStoreLib); if (!newSecureStoreFile.exists()) { throw new RuntimeException(String.format("File %s doesn't exists", newSecureStoreFile.getAbsolutePath())); } String newSecureStore = getNewSecureStoreClassName(newSecureStoreFile); String currentSecureStoreName = getCurrentSecureStoreClassName(sitePaths); if (currentSecureStoreName.equals(newSecureStore)) { log.error("Old and new SecureStore implementation names " + "are the same. Migration will not work"); return -1; } IoUtil.loadJARs(newSecureStoreFile); SiteLibraryLoaderUtil.loadSiteLib(sitePaths.lib_dir); log.info("Current secureStoreClass property ({}) will be replaced with {}", currentSecureStoreName, newSecureStore); Injector dbInjector = createDbInjector(SINGLE_USER); SecureStore currentStore = getSecureStore(currentSecureStoreName, dbInjector); SecureStore newStore = getSecureStore(newSecureStore, dbInjector); migrateProperties(currentStore, newStore); removeOldLib(sitePaths, currentSecureStoreName); copyNewLib(sitePaths, newSecureStoreFile); updateGerritConfig(sitePaths, newSecureStore); return 0; }
Source:
public void testParseEncoding_ISO8859_1_encoding() { Charset result = RawParseUtils.parseEncoding("encoding ISO-8859-1\n" .getBytes()); assertNotNull(result); }

Target:
public void testParseEncoding_ISO8859_1_encoding() { Charset result = RawParseUtils.parseEncoding(Constants .encodeASCII("encoding ISO-8859-1\n")); assertNotNull(result); }
Source:
public void testAddMavenDescriptorNotAddedPerDefault() throws Exception { File basedir = getBasedir("projects/addMavenDescriptorDefault"); File platform = new File("src/test/resources/eclipse"); List<MavenProject> projects = getSortedProjects(basedir, platform); MavenProject project = getProject(projects, "addMavenDescriptorDefault"); PackageFeatureMojo mojo = (PackageFeatureMojo) lookupMojo("package-feature", project.getFile()); setVariableValueToObject(mojo, "project", project); setVariableValueToObject(mojo, "session", newMavenSession(project, projects)); setVariableValueToObject(mojo, "finalName", "feature"); mojo.execute(); ZipFile zip = new ZipFile(new File(basedir, "target/feature.jar")); ZipEntry entry = zip.getEntry("META-INF/maven"); assertNull("No 'META-INF/maven/' entry must be in the feature.jar!", entry); zip.close(); }

Target:
public void testAddMavenDescriptorNotAddedPerDefault() throws Exception { File basedir = getBasedir("projects/addMavenDescriptor/featureDefault/"); File platform = new File("src/test/resources/eclipse"); List<MavenProject> projects = getSortedProjects(basedir, platform); MavenProject project = getProject(projects, "featureDefault"); PackageFeatureMojo mojo = (PackageFeatureMojo) lookupMojo("package-feature", project.getFile()); setVariableValueToObject(mojo, "project", project); setVariableValueToObject(mojo, "session", newMavenSession(project, projects)); mojo.execute(); ZipFile zip = new ZipFile(new File(basedir, "target/featureDefault.jar")); try { ZipEntry entry = zip.getEntry("META-INF/maven"); assertNull("No 'META-INF/maven/' entry must be in the feature.jar!", entry); } finally { zip.close(); } }
Source:
public void initialize() throws SchedulerConfigException { executorService = new ThreadPoolExecutor(10, count, 60L, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(queueSize), new SchedulerThreadFactory(this), new BlockedRejectedExecutionHandler(log)); }

Target:
public void initialize() throws SchedulerConfigException { executorService = new ThreadPoolExecutor(10, count, 60L, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(queueSize), new SchedulerThreadFactory(this), isBlockIfFull() ? new BlockedRejectedExecutionHandler(log) : new ThreadPoolExecutor.AbortPolicy()); }
Source:
public void setupMqtt() throws MqttException { if (preferences.isMqttEnabled()) { if (!preferences.getMqttUser().equals("") && !preferences.getMqttPass().equals("") && !preferences.getMqttEndpoint().equals("")) { MqttConnectOptions mqttOptions = new MqttConnectOptions(); mqttOptions.setCleanSession(true); mqttOptions.setKeepAliveInterval(150000); mqttOptions.setUserName(preferences.getMqttUser()); mqttOptions.setPassword(preferences.getMqttPass().toCharArray()); String androidId = Settings.Secure.getString(getContentResolver(), Settings.Secure.ANDROID_ID); MemoryPersistence dataStore = new MemoryPersistence(); MqttClient client = new MqttClient(preferences.getMqttEndpoint(), androidId, dataStore); MqttPinger pinger = new AndroidMqttPinger(getApplicationContext(), 0, client, 150000); MqttTimer timer = new AndroidMqttTimer(getApplicationContext(), 0); mqttManager = new MqttEventMgr(client, mqttOptions, pinger, timer, reporter); mqttManager.connect(); mSyncButton.setBackgroundResource(R.drawable.ic_cloud); } } }

Target:
public void setupMqtt() throws MqttException { if (preferences.isMqttEnabled()) { if (!preferences.getMqttUser().equals("") && !preferences.getMqttPass().equals("") && !preferences.getMqttEndpoint().equals("")) { MqttConnectOptions mqttOptions = new MqttConnectOptions(); mqttOptions.setCleanSession(false); mqttOptions.setKeepAliveInterval(150000); mqttOptions.setUserName(preferences.getMqttUser()); mqttOptions.setPassword(preferences.getMqttPass().toCharArray()); String androidId = Settings.Secure.getString(getContentResolver(), Settings.Secure.ANDROID_ID); MemoryPersistence dataStore = new MemoryPersistence(); MqttClient client = new MqttClient(preferences.getMqttEndpoint(), androidId, dataStore); MqttPinger pinger = new AndroidMqttPinger(getApplicationContext(), 0, client, 150000); MqttTimer timer = new AndroidMqttTimer(getApplicationContext(), 0); mqttManager = new MqttEventMgr(client, mqttOptions, pinger, timer, reporter); mqttManager.connect(); mSyncButton.setBackgroundResource(R.drawable.ic_cloud); } } }
Source:
public EclipseReferencePointManager() { referencePointToProjectMapper = new ConcurrentHashMap<IReferencePoint, org.eclipse.core.resources.IProject>(); }

Target:
public EclipseReferencePointManager() { referencePointToProjectMapper = new ConcurrentHashMap<>(); }
Source:
public void edit(final HostBondInterfaceModel object) { super.edit(object); info.setVisible(false); message.setVisible(false); checkConnectivity.setVisible(false); commitChanges.setVisible(false); layoutPanel.remove(infoPanel); layoutPanel.setWidgetSize(mainPanel, 300); asPopupPanel().setPixelSize(400, 400); }

Target:
public void edit(final HostBondInterfaceModel object) { super.edit(object); info.setVisible(false); message.setVisible(false); layoutPanel.remove(infoPanel); layoutPanel.setWidgetSize(mainPanel, 300); asPopupPanel().setPixelSize(400, 400); }
Source:
String buildBulkImportSessionName(PluginTask task, ExecSession exec) { if (task.getSession().isPresent()) { return task.getSession().get(); } else { Timestamp time = exec.getTransactionTime(); return String.format("embulk_%s_%09d_%s", DateTimeFormatter.ofPattern("yyyyMMdd_HHmmss").withZone(ZoneId.of("UTC")).format(time.getInstant()), time.getNano(), UUID.randomUUID().toString().replace('-', '_')); } }

Target:
String buildBulkImportSessionName(PluginTask task, ExecSession exec) { if (task.getSession().isPresent()) { return task.getSession().get(); } else { Timestamp time = exec.getTransactionTime(); final DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyyMMdd_HHmmss") .withZone(ZoneOffset.UTC); return String.format("embulk_%s_%09d_%s", dateTimeFormatter.format(time.getInstant()), time.getNano(), UUID.randomUUID().toString().replace('-', '_')); } }
Source:
public boolean showMuteOverlayOnVideoCall() { if (carrierConfig == null) { return true; } return carrierConfig.getBoolean(CarrierConfigManager.KEY_VIDEO_CALL_MUTE_OVERLAY_VISIBLE_BOOL); }

Target:
public boolean showMuteOverlayOnVideoCall() { if (carrierConfig == null) { return true; } return carrierConfig.getBoolean( CarrierConfigManager.KEY_VIDEO_CALL_MUTE_OVERLAY_VISIBLE_BOOL, true); }
Source:
public final void setBool(boolean reverse, IntsRef ref, boolean value) { if (store2DirectedValues && reverse) { int flags = ref.ints[bwdDataIndex + ref.offset]; flags &= ~bwdMask; if (value) flags = flags | (1 << bwdShift); ref.ints[bwdDataIndex + ref.offset] = flags; } else { int flags = ref.ints[fwdDataIndex + ref.offset]; flags &= ~fwdMask; if (value) flags = flags | (1 << fwdShift); ref.ints[fwdDataIndex + ref.offset] = flags; } }

Target:
public final void setBool(boolean reverse, IntsRef ref, boolean value) { if (storeBothDirections && reverse) { int flags = ref.ints[bwdDataIndex + ref.offset]; flags &= ~bwdMask; if (value) flags = flags | (1 << bwdShift); ref.ints[bwdDataIndex + ref.offset] = flags; } else { int flags = ref.ints[fwdDataIndex + ref.offset]; flags &= ~fwdMask; if (value) flags = flags | (1 << fwdShift); ref.ints[fwdDataIndex + ref.offset] = flags; } }
Source:
public EventHubConsumer createConsumer(String consumerGroup, String partitionId, EventPosition eventPosition, EventHubConsumerOptions options) { Objects.requireNonNull(eventPosition); Objects.requireNonNull(options); if (ImplUtils.isNullOrEmpty(consumerGroup)) { throw new IllegalArgumentException("'partitionId' cannot be null or empty."); } if (ImplUtils.isNullOrEmpty(consumerGroup)) { throw new IllegalArgumentException("'partitionId' cannot be null or empty."); } final EventHubConsumerOptions clonedOptions = options.clone(); if (clonedOptions.scheduler() == null) { clonedOptions.scheduler(connectionOptions.scheduler()); } if (clonedOptions.retry() == null) { clonedOptions.retry(connectionOptions.retryPolicy()); } final String linkName = StringUtil.getRandomString("PR"); final String entityPath = String.format(Locale.US, RECEIVER_ENTITY_PATH_FORMAT, eventHubPath, consumerGroup, partitionId); final Mono<AmqpReceiveLink> receiveLinkMono = connectionMono.flatMap(connection -> connection.createSession(entityPath)) .cast(EventHubSession.class) .flatMap(session -> { final Long priority = options.ownerLevel().isPresent() ? options.ownerLevel().get() : null; return session.createConsumer(linkName, entityPath, eventPosition.getExpression(), connectionOptions.timeout(), clonedOptions.retry(), priority, options.identifier()); }) .cast(AmqpReceiveLink.class); return new EventHubConsumer(receiveLinkMono, clonedOptions, connectionOptions.timeout()); }

Target:
public EventHubConsumer createConsumer(String consumerGroup, String partitionId, EventPosition eventPosition, EventHubConsumerOptions options) { Objects.requireNonNull(eventPosition); Objects.requireNonNull(options); if (ImplUtils.isNullOrEmpty(consumerGroup)) { throw new IllegalArgumentException("'consumerGroup' cannot be null or empty."); } if (ImplUtils.isNullOrEmpty(partitionId)) { throw new IllegalArgumentException("'partitionId' cannot be null or empty."); } final EventHubConsumerOptions clonedOptions = options.clone(); if (clonedOptions.scheduler() == null) { clonedOptions.scheduler(connectionOptions.scheduler()); } if (clonedOptions.retry() == null) { clonedOptions.retry(connectionOptions.retryPolicy()); } final String linkName = StringUtil.getRandomString("PR"); final String entityPath = String.format(Locale.US, RECEIVER_ENTITY_PATH_FORMAT, eventHubPath, consumerGroup, partitionId); final Mono<AmqpReceiveLink> receiveLinkMono = connectionMono.flatMap(connection -> connection.createSession(entityPath)) .cast(EventHubSession.class) .flatMap(session -> { return session.createConsumer(linkName, entityPath, eventPosition.getExpression(), connectionOptions.timeout(), clonedOptions.retry(), options.ownerLevel(), options.identifier()); }) .cast(AmqpReceiveLink.class); return new EventHubConsumer(receiveLinkMono, clonedOptions, connectionOptions.timeout()); }
Source:
public JsonElement serialize(JsonSerializationContext context) { JsonObject serialized = context.serialize(flag).getAsJsonObject(); serialized.add("body", serialized.remove("comment")); if (flag.getUserProfileId() != null) { serialized.remove("userProfileID"); serialized.add("creator", context.serialize(new UserIdView(flag.getUserProfileId()))); } serialized.add("flaggedComment", context.serialize(flaggedComment)); return serialized; }

Target:
public JsonElement serialize(JsonSerializationContext context) { JsonObject serialized = context.serialize(flag).getAsJsonObject(); serialized.add("body", serialized.remove("comment")); serialized.remove("userProfileID"); if (flag.getUserProfileId() != null) { serialized.add("creator", context.serialize(new UserIdView(flag.getUserProfileId()))); } serialized.add("flaggedComment", context.serialize(flaggedComment)); return serialized; }
Source:
public void testOptimizedCreateStandardSyncTasks() { List<TreeResponse> treeResponses = Arrays.asList(treeResponse(addr1, range1, "one", range2, "one"), treeResponse(addr2, range1, "one", range2, "two"), treeResponse(addr3, range1, "three", range2, "two")); Map<SyncNodePair, SyncTask> tasks = toMap(RepairJob.createOptimisedSyncingSyncTasks(desc, treeResponses, addr4, noTransient(), addr -> "DC1", false, PreviewKind.ALL)); assertEquals(Arrays.asList(range1), tasks.get(pair(addr1, addr3)).rangesToSync); assertEquals(Arrays.asList(range2), tasks.get(pair(addr1, addr2)).rangesToSync); assertEquals(Arrays.asList(range1), tasks.get(pair(addr2, addr3)).rangesToSync); assertEquals(Arrays.asList(range2), tasks.get(pair(addr2, addr1)).rangesToSync); assertEquals(Arrays.asList(range1), tasks.get(pair(addr3, addr2)).rangesToSync); assertEquals(Arrays.asList(range2), tasks.get(pair(addr3, addr1)).rangesToSync); }

Target:
public void testOptimizedCreateStandardSyncTasks() { List<TreeResponse> treeResponses = Arrays.asList(treeResponse(addr1, range1, "one", range2, "one"), treeResponse(addr2, range1, "one", range2, "two"), treeResponse(addr3, range1, "three", range2, "two")); Map<SyncNodePair, SyncTask> tasks = toMap(RepairJob.createOptimisedSyncingSyncTasks(desc, treeResponses, addr4, noTransient(), addr -> "DC1", false, PreviewKind.ALL)); for (SyncTask task : tasks.values()) assertTrue(task instanceof AsymmetricRemoteSyncTask); assertEquals(Arrays.asList(range1), tasks.get(pair(addr1, addr3)).rangesToSync); assertStreamRangeFromEither(tasks, Arrays.asList(range2), addr1, addr2, addr3); assertEquals(Arrays.asList(range1), tasks.get(pair(addr2, addr3)).rangesToSync); assertEquals(Arrays.asList(range2), tasks.get(pair(addr2, addr1)).rangesToSync); assertStreamRangeFromEither(tasks, Arrays.asList(range1), addr3, addr2, addr1); assertEquals(Arrays.asList(range2), tasks.get(pair(addr3, addr1)).rangesToSync); }
Source:
public boolean tableExists(String tableName) throws IOException { boolean retval = false; final Scan scan = new Scan() .addColumn(mFamilyBytes, QUALIFIER_LAYOUT_BYTES) .setMaxVersions(1); final ResultScanner resultScanner = mTable.getScanner(scan); for (Result result : resultScanner) { if (tableName.equals(Bytes.toString(result.getRow()))) { retval = true; break; } } resultScanner.close(); return retval; }

Target:
public boolean tableExists(String tableName) throws IOException { boolean retval = false; final Scan scan = new Scan() .addColumn(mFamilyBytes, QUALIFIER_LAYOUT_BYTES) .setMaxVersions(1); ResultScanner resultScanner = null; try { resultScanner = mTable.getScanner(scan); for (Result result : resultScanner) { if (tableName.equals(Bytes.toString(result.getRow()))) { retval = true; break; } } } finally { if (null != resultScanner) { resultScanner.close(); } } return retval; }
Source:
public static String getAppConfigFolder(String appName) { Path configRoot = null; String osName = System.getProperty("os.name"); if ("Mac OS X".equals(osName)) { configRoot = Paths.get(System.getProperty("user.home"), "Library", "Java"); } else if (osName.startsWith("Windows")) { try { configRoot = Paths.get(System.getenv("APPDATA")); if (configRoot != null) { configRoot = configRoot.resolve("Sun").resolve("Java"); } } catch (SecurityException e) { } } if (configRoot == null) { configRoot = Paths.get(System.getProperty("user.home"), ".config"); } return configRoot.resolve(appName).toString(); }

Target:
public static String getAppConfigFolder(String appName) { Path configRoot = null; String osName = System.getProperty("os.name"); if ("Mac OS X".equals(osName)) { configRoot = Paths.get(System.getProperty("user.home"), "Library", "Java"); } else if (osName.startsWith("Windows")) { try { String appData = System.getenv("APPDATA"); if (appData != null) { configRoot = Paths.get(appData).resolve("Sun").resolve("Java"); } } catch (SecurityException e) { } } if (configRoot == null) { configRoot = Paths.get(System.getProperty("user.home"), ".config"); } return configRoot.resolve(appName).toString(); }
Source:
private UserAndRoleMap fetchUserAndRoleMapFromCoordinator(String prefix, boolean isInit) { try { return RetryUtils.retry( () -> { return tryFetchMapsFromCoordinator(prefix); }, e -> true, commonCacheConfig.getMaxSyncRetries() ); } catch (Exception e) { LOG.makeAlert(e, "Encountered exception while fetching user and role map for authorizer [%s]", prefix); if (isInit) { if (commonCacheConfig.getCacheDirectory() != null) { try { LOG.info("Attempting to load user map snapshot from disk."); return loadUserAndRoleMapFromDisk(prefix); } catch (Exception e2) { LOG.makeAlert(e2, "Encountered exception while loading user-role map snapshot for authorizer [%s]", prefix); } } } return null; } }

Target:
private UserAndRoleMap fetchUserAndRoleMapFromCoordinator(String prefix, boolean isInit) { try { return RetryUtils.retry( () -> { return tryFetchMapsFromCoordinator(prefix); }, e -> true, commonCacheConfig.getMaxSyncRetries() ); } catch (Exception e) { LOG.makeAlert(e, "Encountered exception while fetching user and role map for authorizer [%s]", prefix); if (isInit) { if (commonCacheConfig.getCacheDirectory() != null) { try { LOG.info("Attempting to load user map snapshot from disk."); return loadUserAndRoleMapFromDisk(prefix); } catch (Exception e2) { e2.addSuppressed(e); LOG.makeAlert(e2, "Encountered exception while loading user-role map snapshot for authorizer [%s]", prefix); } } } return null; } }