auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public void execute() throws Exception { ConfigActionType actionType = parser.getConfigAction(); log.debug("execute: beginning execution of action " + actionType + "."); switch (actionType) { case ACTION_ALL: printAllValues(); break; case ACTION_LIST: printAvailableKeys(); break; case ACTION_GET: printKey(); break; case ACTION_SET: persistValue(); break; case ACTION_RELOAD: reloadConfigurations(); break; default: log.debug("execute: unable to recognize action: " + actionType + "."); <START> throw new UnsupportedOperationException("Please tell me what to do: list? get? set? get-all?"); <END> } }</code><technical_language>add reload</technical_language>

Target:
public void execute() throws Exception { ConfigActionType actionType = parser.getConfigAction(); log.debug("execute: beginning execution of action " + actionType + "."); switch (actionType) { case ACTION_ALL: printAllValues(); break; case ACTION_LIST: printAvailableKeys(); break; case ACTION_GET: printKey(); break; case ACTION_SET: persistValue(); break; case ACTION_RELOAD: reloadConfigurations(); break; default: log.debug("execute: unable to recognize action: " + actionType + "."); throw new UnsupportedOperationException("Please tell me what to do: list? get? set? get-all? reload?"); } }
Source:
<code>public void perform(@Nonnull Run<?, ?> run, @Nonnull FilePath workspace, @Nonnull Launcher launcher, @Nonnull TaskListener listener) { try { String sha = getCommitShaSource().get(run, listener); List<GHRepository> repos = getReposSource().repos(run, listener); String contextName = getContextSource().context(run, listener); String backref = run.getAbsoluteUrl(); GitHubStatusResultSource.StatusResult result = getStatusResultSource().get(run, listener); String message = result.getMsg(); GHCommitState state = result.getState(); listener.getLogger().printf( <START> "[GitHub Commit Status Setter] Going to set status %s on repos %s (sha:%7.7s) with context:%s%n", <END> state, repos, sha, contextName ); for (GHRepository repo : repos) { listener.getLogger().println( GitHubCommitNotifier_SettingCommitStatus(repo.getHtmlUrl() + "/commit/" + sha) ); repo.createCommitStatus(sha, state, backref, message, contextName); } } catch (Exception e) { CombineErrorHandler.errorHandling().withHandlers(getErrorHandlers()).handle(e, run, listener); } }</code><technical_language>prefix short name plugin UI name i.e. [GitHub] [getDescriptor().getDisplayName()]</technical_language>

Target:
public void perform(@Nonnull Run<?, ?> run, @Nonnull FilePath workspace, @Nonnull Launcher launcher, @Nonnull TaskListener listener) { try { String sha = getCommitShaSource().get(run, listener); List<GHRepository> repos = getReposSource().repos(run, listener); String contextName = getContextSource().context(run, listener); String backref = getStatusBackrefSource().get(run, listener); GitHubStatusResultSource.StatusResult result = getStatusResultSource().get(run, listener); String message = result.getMsg(); GHCommitState state = result.getState(); listener.getLogger().printf( "[%s] %s on repos %s (sha:%7.7s) with context:%s%n", getDescriptor().getDisplayName(), state, repos, sha, contextName ); for (GHRepository repo : repos) { listener.getLogger().println( GitHubCommitNotifier_SettingCommitStatus(repo.getHtmlUrl() + "/commit/" + sha) ); repo.createCommitStatus(sha, state, backref, message, contextName); } } catch (Exception e) { CombineErrorHandler.errorHandling().withHandlers(getErrorHandlers()).handle(e, run, listener); } }
Source:
<code>private void registerFabUploadListeners() { getFabUpload().setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent action = new Intent(getActivity(), UploadFilesActivity.class); action.putExtra( UploadFilesActivity.EXTRA_ACCOUNT, ((FileActivity)getActivity()).getAccount() ); <START> getActivity().startActivityForResult( <END> action, FileDisplayActivity.ACTION_SELECT_MULTIPLE_FILES ); getFabMain().collapse(); recordMiniFabClick(); } }); getFabUpload().setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { Toast.makeText(getActivity(), R.string.actionbar_upload, Toast.LENGTH_SHORT).show(); return true; } }); }</code><technical_language>FileDiplayActivity exposes a public method do this , prefer here</technical_language>

Target:
private void registerFabUploadListeners() { getFabUpload().setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { UploadFilesActivity.startUploadActivityForResult(getActivity(), ((FileActivity)getActivity()) .getAccount(), FileDisplayActivity.ACTION_SELECT_MULTIPLE_FILES); getFabMain().collapse(); recordMiniFabClick(); } }); getFabUpload().setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { Toast.makeText(getActivity(), R.string.actionbar_upload, Toast.LENGTH_SHORT).show(); return true; } }); }
Source:
<code>public void should_display_members_page() { String orgKey = createOrganization(); String userFoo = createUser("foo"); <START> String userBar = createUser("bar"); <END> createUser(); adminClient.organizations().addMember(orgKey, userFoo); adminClient.organizations().addMember(orgKey, userBar); MembersPage page = nav.openOrganizationMembers(orgKey); page .canNotAddMember() .shouldHaveTotal(3); page.getMembersByIdx(0).shouldBeNamed("admin", "Administrator"); page.getMembersByIdx(1).shouldBeNamed(userBar, userBar); page.getMembersByIdx(2) .shouldBeNamed(userFoo, userFoo) .shouldNotHaveActions(); }</code><technical_language>consider rearranging order of lines, more obvious, of users is a member</technical_language>

Target:
public void should_display_members_page() { String orgKey = createOrganization(); String userFoo = createUser("foo"); adminClient.organizations().addMember(orgKey, userFoo); String userBar = createUser("bar"); adminClient.organizations().addMember(orgKey, userBar); createUser(); MembersPage page = nav.openOrganizationMembers(orgKey); page .canNotAddMember() .shouldHaveTotal(3); page.getMembersByIdx(0).shouldBeNamed("admin", "Administrator"); page.getMembersByIdx(1).shouldBeNamed(userBar, userBar); page.getMembersByIdx(2) .shouldBeNamed(userFoo, userFoo) .shouldNotHaveActions(); }
Source:
<code>public void set(String replState, String dbName, String tableName, Map <String, String> partSpec) { <START> updateMetaDataList.add(new UpdateMetaData(replState, dbName, tableName, partSpec)); <END> String key = getKey(normalizeIdentifier(dbName), normalizeIdentifier(tableName)); updateMetaDataMap.put(key, updateMetaDataList.size() - 1); }</code><technical_language>Safer check if entry exists for table. If yes, re-use else put new one</technical_language>

Target:
public void set(String replState, String dbName, String tableName, Map <String, String> partSpec) throws SemanticException { if (dbName == null) { throw new SemanticException("db name can not be null"); } String key = getKey(normalizeIdentifier(dbName), normalizeIdentifier(tableName)); Integer idx = updateMetaDataMap.get(key); if (idx == null) { updateMetaDataList.add(new UpdateMetaData(replState, dbName, tableName, partSpec)); updateMetaDataMap.put(key, updateMetaDataList.size() - 1); } else { updateMetaDataList.get(idx).addPartition(partSpec); } }
Source:
<code><START> public void shouldRetrieveRepresentationRevision() throws MCSException { <END> RecordServiceClient instance = new RecordServiceClient("http://localhost:8080/mcs", "metis_test", "1RkZBuVf"); List<Representation> representations = instance.getRepresentationsByRevision("Z6DX3RWCEFUUSGRUWP6QZWRIZKY7HI5Y7H4UD3OQVB3SRPAUVZHA", "REPRESENTATION1", "Revision_2", "Revision_Provider", "2018-08-28T07:13:34.658"); assertNotNull(representations); assertTrue(representations.size() == 1); assertEquals("REPRESENTATION1", representations.get(0).getRepresentationName()); assertEquals("68b4cc30-aa8d-11e8-8289-1c6f653f9042", representations.get(0).getVersion()); }</code><technical_language>remove credentials</technical_language>

Target:
public void shouldRetrieveRepresentationRevision() throws MCSException { RecordServiceClient instance = new RecordServiceClient("http://localhost:8080/mcs", "admin", "admin"); List<Representation> representations = instance.getRepresentationsByRevision("Z6DX3RWCEFUUSGRUWP6QZWRIZKY7HI5Y7H4UD3OQVB3SRPAUVZHA", "REPRESENTATION1", "Revision_2", "Revision_Provider", "2018-08-28T07:13:34.658"); assertNotNull(representations); assertTrue(representations.size() == 1); assertEquals("REPRESENTATION1", representations.get(0).getRepresentationName()); assertEquals("68b4cc30-aa8d-11e8-8289-1c6f653f9042", representations.get(0).getVersion()); }
Source:
<code>public void testCreateNodeWithCustomHardwareUsingMins() throws Exception { Template template = buildTemplate(templateBuilder() .minCores(2).minRam(2048).minDisk(10)); try { NodeMetadata node = getOnlyElement(client.createNodesInGroup(group + "custom", 1, template)); assertThat(node.getHardware().getRam()).isEqualTo(2048); assertThat(node.getHardware().getProcessors().get(0).getCores()).isEqualTo(2); <START> assertThat(node.getHardware().getVolumes().get(0).getSize()).isEqualTo(10); <END> } finally { client.destroyNodesMatching(inGroup(group + "custom")); } }</code><technical_language>Add assertion check hardwre id</technical_language>

Target:
public void testCreateNodeWithCustomHardwareUsingMins() throws Exception { Template template = buildTemplate(templateBuilder() .minCores(2).minRam(2048).minDisk(10)); try { NodeMetadata node = getOnlyElement(client.createNodesInGroup(group + "custom", 1, template)); assertThat(node.getHardware().getRam()).isEqualTo(2048); assertThat(node.getHardware().getProcessors().get(0).getCores()).isEqualTo(2); assertThat(node.getHardware().getVolumes().get(0).getSize()).isEqualTo(10); assertThat(node.getHardware().getId()).isEqualTo("cpu=2,ram=2048,disk=10"); } finally { client.destroyNodesMatching(inGroup(group + "custom")); } }
Source:
<code>private void doTestJavaProfile(String javaSpecVersion, String expectedEEName, String releaseName) throws FileNotFoundException, IOException { if (releaseName != null) { File release = getContext().getDataFile("jre/release"); release.getParentFile().mkdirs(); Properties props = new Properties(); props.put("JAVA_PROFILE", releaseName); <START> props.store(new FileOutputStream(release), null); <END> System.setProperty("java.home", release.getParentFile().getAbsolutePath()); } System.setProperty("java.specification.version", javaSpecVersion); File config = OSGiTestsActivator.getContext().getDataFile(getName() + javaSpecVersion); Map<String, Object> configuration = new HashMap<String, Object>(); configuration.put(Constants.FRAMEWORK_STORAGE, config.getAbsolutePath()); Equinox equinox = new Equinox(configuration); try { equinox.init(); } catch (BundleException e) { fail("Unexpected exception in init()", e); } @SuppressWarnings("deprecation") String osgiEE = equinox.getBundleContext().getProperty(Constants.FRAMEWORK_EXECUTIONENVIRONMENT); try { equinox.stop(); } catch (BundleException e) { fail("Unexpected error stopping framework", e); } try { equinox.waitForStop(10000); } catch (InterruptedException e) { fail("Unexpected interrupted exception", e); } assertEquals("Wrong state for SystemBundle", Bundle.RESOLVED, equinox.getState()); assertTrue("Wrong osgi EE: expected: " + expectedEEName + " but was: " + osgiEE, osgiEE.endsWith(expectedEEName)); }</code><technical_language>need close output stream. try-with-resource</technical_language>

Target:
private void doTestJavaProfile(String javaSpecVersion, String expectedEEName, String releaseName) throws FileNotFoundException, IOException { if (releaseName != null) { File release = getContext().getDataFile("jre/release"); release.getParentFile().mkdirs(); Properties props = new Properties(); props.put("JAVA_PROFILE", releaseName); FileOutputStream propStream = new FileOutputStream(release); try { props.store(propStream, null); } finally { propStream.close(); } System.setProperty("java.home", release.getParentFile().getAbsolutePath()); } System.setProperty("java.specification.version", javaSpecVersion); File config = OSGiTestsActivator.getContext().getDataFile(getName() + javaSpecVersion); Map<String, Object> configuration = new HashMap<String, Object>(); configuration.put(Constants.FRAMEWORK_STORAGE, config.getAbsolutePath()); Equinox equinox = new Equinox(configuration); try { equinox.init(); } catch (BundleException e) { fail("Unexpected exception in init()", e); } @SuppressWarnings("deprecation") String osgiEE = equinox.getBundleContext().getProperty(Constants.FRAMEWORK_EXECUTIONENVIRONMENT); try { equinox.stop(); } catch (BundleException e) { fail("Unexpected error stopping framework", e); } try { equinox.waitForStop(10000); } catch (InterruptedException e) { fail("Unexpected interrupted exception", e); } assertEquals("Wrong state for SystemBundle", Bundle.RESOLVED, equinox.getState()); assertTrue("Wrong osgi EE: expected: " + expectedEEName + " but was: " + osgiEE, osgiEE.endsWith(expectedEEName)); }
Source:
<code>public static void updateMaxMemorySize(VmBase vmBase, Version effectiveCompatibilityVersion) { if (vmBase.getMaxMemorySizeMb() == 0) { final int maxMemorySize = VmCommonUtils.maxMemorySizeWithHotplugInMb(vmBase.getOsId(), effectiveCompatibilityVersion); vmBase.setMaxMemorySizeMb(maxMemorySize); <START> } <END> }</code><technical_language>scenario happen? in engine 5.7 create a VM vm1 max memory X in engine 4.1 max memory MAX is X export vm1 engine 5.7 import in engine 4.1 -> import fail X is higher maximum allowed if is possible, do want want fix maxMemory while importing a VM exported in a version maxMemory higher allowed in destination cluster</technical_language>

Target:
public static void updateMaxMemorySize(VmBase vmBase, Version effectiveCompatibilityVersion) { final int maxMaxMemorySize = VmCommonUtils.maxMemorySizeWithHotplugInMb(vmBase.getOsId(), effectiveCompatibilityVersion); if (vmBase.getMaxMemorySizeMb() == 0 || vmBase.getMaxMemorySizeMb() > maxMaxMemorySize) { vmBase.setMaxMemorySizeMb(maxMaxMemorySize); } }
Source:
<code>public QueryInterruptedException(Throwable e, String host) { super(e); this.host = host; <START> causeMessage = null; <END> }</code><technical_language>set e.getMessage()</technical_language>

Target:
public QueryInterruptedException(Throwable e, String host) { super(e); this.host = host; causeMessage = e.getMessage(); }
Source:
<code>protected boolean sendDataOut(SimpleBinaryItemData data) { <START> logger.warn("{} - Generic device cant send data", this.toString()); <END> return false; }</code><technical_language>"can't"</technical_language>

Target:
protected boolean sendDataOut(SimpleBinaryItemData data) { logger.warn("{} - Generic device can't send data", this.toString()); return false; }
Source:
<code>public Object instantiateItem(ViewGroup container, int position) { layoutInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); View view = layoutInflater.inflate(layouts[position], container, false); Button btnGrantStoragePerm = (Button) view.findViewById(R.id.btnGrantStoragePerm); if (btnGrantStoragePerm != null) { btnGrantStoragePerm.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { requestStoragePermission(); } }); <START> } <END> Button btnGrantLocationPerm = (Button) view.findViewById(R.id.btnGrantLocationPerm); if (btnGrantLocationPerm != null) { btnGrantLocationPerm.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { requestLocationPermission(); } }); } container.addView(view); return view; }</code><technical_language>If null, do in case</technical_language>

Target:
public Object instantiateItem(ViewGroup container, int position) { layoutInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); View view = layoutInflater.inflate(mLayouts[position], container, false); Button btnGrantStoragePerm = (Button) view.findViewById(R.id.btnGrantStoragePerm); if (btnGrantStoragePerm != null) { btnGrantStoragePerm.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { requestStoragePermission(); } }); } Button btnGrantLocationPerm = (Button) view.findViewById(R.id.btnGrantLocationPerm); if (btnGrantLocationPerm != null) { btnGrantLocationPerm.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { requestLocationPermission(); } }); } container.addView(view); return view; }
Source:
<code>private void createServer(Module module, boolean queryParamsAsFormParams) throws Exception { server = Guice.createInjector( new ApplicationNameModule("test-application"), new TestingNodeModule(), explicitJaxrsModule(), new JsonModule(), new ReportingModule(), new TestingHttpServerModule(), new ConfigurationModule(new ConfigurationFactory(ImmutableMap.of("jaxrs.query-params-as-form-params", String.valueOf(queryParamsAsFormParams)))), <START> module) <END> .getInstance(TestingHttpServer.class); server.start(); }</code><technical_language>worth converting Bootstrap.bootstrapTest()</technical_language>

Target:
private void createServer(Module module, boolean queryParamsAsFormParams) throws Exception { Injector injector = bootstrapTest() .withModules( new TestingNodeModule(), explicitJaxrsModule(), new JsonModule(), new ReportingModule(), new TestingHttpServerModule(), module) .setRequiredConfigurationProperty("jaxrs.query-params-as-form-params", String.valueOf(queryParamsAsFormParams)) .initialize(); lifeCycleManager = injector.getInstance(LifeCycleManager.class); server = injector.getInstance(TestingHttpServer.class); }
Source:
<code>public MetaSyntax(String commentStartSyntax, String commentEndSyntax) { this.commentStartRegex = SPACES + commentStartSyntax + SPACES; this.commentEndRegex = SPACES + commentEndSyntax + SPACES; this.beginSolutionRegex = commentStartRegex + BEGIN_SOLUTION + commentEndRegex; this.endSolutionRegex = commentStartRegex + END_SOLUTION + commentEndRegex; this.solutionFileRegex = commentStartRegex + SOLUTION_FILE + commentEndRegex; this.stubRegex = commentStartRegex + STUB + "(.*)" + commentEndRegex; <START> this.stubMarker = commentStartSyntax + STUB; END> }</code><technical_language>A picky stylistic note: While horizontal alignment is forbidden, is problem free. f.ex. this quote style guide: > Alignment aid readability, creates problems for future maintenance. Consider a future change needs touch line. This change leave formerly-pleasing formatting mangled, is allowed. More prompts coder (perhaps you) adjust whitespace nearby lines well, possibly triggering a cascading series of reformattings. one-line change a "blast radius." This worst result in pointless busywork, corrupts version history information, slows reviewers exacerbates merge conflicts. horizontal alignment **greatly** improves legibility suggest it</technical_language>

Target:
public MetaSyntax(String commentStartSyntax, String commentEndSyntax) { this.commentStartRegex = "^" + SPACES + commentStartSyntax + SPACES; this.commentEndRegex = SPACES + commentEndSyntax + SPACES + "$"; this.beginSolutionRegex = commentStartRegex + BEGIN_SOLUTION + commentEndRegex; this.endSolutionRegex = commentStartRegex + END_SOLUTION + commentEndRegex; this.solutionFileRegex = commentStartRegex + SOLUTION_FILE + commentEndRegex; this.stubMarker = commentStartSyntax + SPACES + STUB + SPACES; this.stubBeginsRegex = commentStartRegex + STUB + "(.*)"; }
Source:
<code>public void evaluateUnaryOperators() { evaluate("+1",1); evaluate("+1.0",1.0); evaluate("+1*2",2); evaluate("+1.0*2.0",2.0); evaluate("2*(+1)",2); evaluate("2.0*(+1.0)",2.0); evaluate("-1",-1); evaluate("-1.0",-1.0); evaluate("-1*2",-2); evaluate("-1.0*2.0",-2.0); evaluate("2*(-1)",-2); evaluate("2.0*(-1.0)",-2.0); <START> try { <END> evaluate("*1",1); throw new AssertionError("Input \"*1\" expected to cause ExprSyntaxException"); } catch (ExprSyntaxException excp) { } try { evaluate("*1.0",1.0); throw new AssertionError("Input \"*1.0\" expected to cause ExprSyntaxException"); } catch (ExprSyntaxException excp) { } try { evaluate("1*",1); throw new AssertionError("Input \"1*\" expected to cause ExprSyntaxException"); } catch (ExprSyntaxException excp) { } try { evaluate("1.0*",1.0); throw new AssertionError("Input \"1.0*\" expected to cause ExprSyntaxException"); } catch (ExprSyntaxException excp) { } try { evaluate("/1",1); throw new AssertionError("Input \"/1\" expected to cause ExprSyntaxException"); } catch (ExprSyntaxException excp) { } try { evaluate("/1.0",1.0); throw new AssertionError("Input \"/1.0\" expected to cause ExprSyntaxException"); } catch (ExprSyntaxException excp) { } try { evaluate("1/",1); throw new AssertionError("Input \"1/\" expected to cause ExprSyntaxException"); } catch (ExprSyntaxException excp) { } try { evaluate("1.0/",1.0); throw new AssertionError("Input \"1.0/\" expected to cause ExprSyntaxException"); } catch (ExprSyntaxException excp) { } }</code><technical_language>Extract this (repeated) logic a seperate function called "evaluateAndExpectException(String)" easier read</technical_language>

Target:
public void evaluateUnaryOperators() { evaluate("+1",1); evaluate("+1.0",1.0); evaluate("+1*2",2); evaluate("+1.0*2.0",2.0); evaluate("2*(+1)",2); evaluate("2.0*(+1.0)",2.0); evaluate("-1",-1); evaluate("-1.0",-1.0); evaluate("-1*2",-2); evaluate("-1.0*2.0",-2.0); evaluate("2*(-1)",-2); evaluate("2.0*(-1.0)",-2.0); evaluateAndExpectSyntaxException("*1"); evaluateAndExpectSyntaxException("*1.0"); evaluateAndExpectSyntaxException("1*"); evaluateAndExpectSyntaxException("1.0*"); evaluateAndExpectSyntaxException("/1"); evaluateAndExpectSyntaxException("/1.0"); evaluateAndExpectSyntaxException("1/"); evaluateAndExpectSyntaxException("1.0/"); }
Source:
<code>protected void doPut(Event event) throws InterruptedException { type = TransactionType.PUT; <START> if (!serializedEvents.isPresent()) { <END> serializedEvents = Optional.of(new LinkedList<byte[]>()); } try { if (!tempOutStream.isPresent()) { tempOutStream = Optional.of(new ByteArrayOutputStream()); } if (!writer.isPresent()) { writer = Optional .of(new SpecificDatumWriter<AvroFlumeEvent>( AvroFlumeEvent.class)); } tempOutStream.get().reset(); AvroFlumeEvent e = new AvroFlumeEvent( toCharSeqMap(event.getHeaders()), ByteBuffer.wrap(event .getBody())); encoder = EncoderFactory.get().directBinaryEncoder( tempOutStream.get(), encoder); writer.get().write(e, encoder); serializedEvents.get().add(tempOutStream.get().toByteArray()); } catch (Exception e) { throw new ChannelException("Error while serializing event", e); } }</code><technical_language>initialize empty list? Optional.ifPresent(Consumer<? super T> consumer) end, get() is called</technical_language>

Target:
protected void doPut(Event event) throws InterruptedException { type = TransactionType.PUT; try { tempOutStream.reset(); AvroFlumeEvent e = new AvroFlumeEvent(toCharSeqMap(event.getHeaders()), ByteBuffer.wrap(event.getBody())); encoder = EncoderFactory.get().directBinaryEncoder(tempOutStream, encoder); writer.write(e, encoder); serializedEvents.add(tempOutStream.toByteArray()); } catch (Exception e) { throw new ChannelException("Error while serializing event", e); } }
Source:
<code>public WorkflowScheme findScheme(String id) throws DotDataException, DotSecurityException { if (!SYSTEM_WORKFLOW_ID.equals(id)) { if (!hasValidLicense() && !this.getFriendClass().isFriend()) { <START> throw new DotSecurityException("You must have a valid license to gain access to schemes."); <END> } } return workFlowFactory.findScheme(id); }</code><technical_language>i18n</technical_language>

Target:
public WorkflowScheme findScheme(String id) throws DotDataException, DotSecurityException { if (!SYSTEM_WORKFLOW_ID.equals(id)) { if (!hasValidLicense() && !this.getFriendClass().isFriend()) { throw new DotSecurityException("Workflow-Schemes-License-required"); } } return workFlowFactory.findScheme(id); }
Source:
<code>public static Map<String, String> validateCategory(InputStream inputStream) { <START> XSDParser parse = new XSDParser(null); <END> parse.parse(inputStream); XSDSchema schema = parse.getSchema(); return validateCategory(schema); }</code><technical_language>parser a name parse</technical_language>

Target:
public static Map<String, String> validateCategory(InputStream inputStream) { XSDParser parser = new XSDParser(null); parser.parse(inputStream); XSDSchema schema = parser.getSchema(); return validateCategory(schema); }
Source:
<code>@Override public Object evaluate(List args) throws XPathFunctionException { String result = ""; if (args.size() == 2 && args.get(0) instanceof ArrayList && args.get(1) instanceof String) { ArrayList nodeList = (ArrayList) args.get(0); String delimiter = (String) args.get(1); int length = nodeList.size(); for (int i = 0; i < length; i++) { try { String item = ((Element) nodeList.get(i)).getTextContent(); result = result.concat(item); if (i != length - 1) { result = result.concat(delimiter); } } catch (DOMException e) { throw new HumanTaskRuntimeException( "Invalid arguments:" + args.get(0) + ", for function concatWithDelimiter()", e); <START> } catch (ClassCastException e) { <END> throw new HumanTaskRuntimeException( "Invalid arguments:" + args.get(0) + " , for function concatWithDelimiter()"); } } } else { throw new HumanTaskRuntimeException( "Invalid arguments: " + args + ", for function concatWithDelimiter()"); } return result; }</code><technical_language>exception missing newly created exception</technical_language>

Target:
public Object evaluate(List args) throws XPathFunctionException { String result = ""; if (args.size() == 2 && args.get(0) instanceof ArrayList && args.get(1) instanceof String) { ArrayList nodeList = (ArrayList) args.get(0); String delimiter = (String) args.get(1); int length = nodeList.size(); for (int i = 0; i < length; i++) { try { String item = ((Element) nodeList.get(i)).getTextContent(); result = result.concat(item); if (i != length - 1) { result = result.concat(delimiter); } } catch (DOMException e) { throw new HumanTaskRuntimeException( "Invalid arguments:" + args.get(0) + ", for function concatWithDelimiter()", e); } catch (ClassCastException e) { throw new HumanTaskRuntimeException( "Invalid arguments:" + args.get(0) + " , for function concatWithDelimiter()",e); } } } else { throw new HumanTaskRuntimeException( "Invalid arguments: " + args + ", for function concatWithDelimiter()"); } return result; }
Source:
<code>protected Result verifyConnectivity(Map<String, Object> parameters) { ResultBuilder builder = ResultBuilder.withStatusAndScope(Result.Status.OK, Scope.CONNECTIVITY); try { DdbConfiguration configuration = setProperties(new DdbConfiguration(), parameters); AWSCredentials credentials = new BasicAWSCredentials(configuration.getAccessKey(), configuration.getSecretKey()); AWSCredentialsProvider credentialsProvider = new AWSStaticCredentialsProvider(credentials); AmazonDynamoDB client = AmazonDynamoDBClientBuilder.standard().withCredentials(credentialsProvider).withRegion(Regions.valueOf(configuration.getRegion())).build(); client.listTables(); } catch (SdkClientException e) { ResultErrorBuilder errorBuilder = ResultErrorBuilder.withCodeAndDescription(VerificationError.StandardCode.AUTHENTICATION, e.getMessage()) .detail("aws_ddb_exception_message", e.getMessage()).detail(VerificationError.ExceptionAttribute.EXCEPTION_CLASS, e.getClass().getName()) .detail(VerificationError.ExceptionAttribute.EXCEPTION_INSTANCE, e); builder.error(errorBuilder.build()); <START> } catch (@SuppressWarnings("PMD.AvoidCatchingGenericException") Exception e) { <END> builder.error(ResultErrorBuilder.withException(e).build()); } return builder.build(); }</code><technical_language>need for suppressWarnings in Camel project</technical_language>

Target:
protected Result verifyConnectivity(Map<String, Object> parameters) { ResultBuilder builder = ResultBuilder.withStatusAndScope(Result.Status.OK, Scope.CONNECTIVITY); try { DdbConfiguration configuration = setProperties(new DdbConfiguration(), parameters); AWSCredentials credentials = new BasicAWSCredentials(configuration.getAccessKey(), configuration.getSecretKey()); AWSCredentialsProvider credentialsProvider = new AWSStaticCredentialsProvider(credentials); AmazonDynamoDB client = AmazonDynamoDBClientBuilder.standard().withCredentials(credentialsProvider).withRegion(Regions.valueOf(configuration.getRegion())).build(); client.listTables(); } catch (SdkClientException e) { ResultErrorBuilder errorBuilder = ResultErrorBuilder.withCodeAndDescription(VerificationError.StandardCode.AUTHENTICATION, e.getMessage()) .detail("aws_ddb_exception_message", e.getMessage()).detail(VerificationError.ExceptionAttribute.EXCEPTION_CLASS, e.getClass().getName()) .detail(VerificationError.ExceptionAttribute.EXCEPTION_INSTANCE, e); builder.error(errorBuilder.build()); } catch (Exception e) { builder.error(ResultErrorBuilder.withException(e).build()); } return builder.build(); }
Source:
<code>private void transposeLimitExchange(RelOptRuleCall call) { VoltPhysicalLimit coordinatorLimit = (VoltPhysicalLimit) call.rels[0]; Exchange exchange = (Exchange) call.rels[1]; RelNode child = call.rels[2]; VoltRelUtil.buildFragmentLimit(coordinatorLimit, exchange.getDistribution(), child) .ifPresent(fragmentLimit -> { Exchange newExchange = exchange.copy(exchange.getTraitSet(), fragmentLimit, exchange.getDistribution()); <START> VoltPhysicalLimit newCoordinatorLimit = new VoltPhysicalLimit( <END> coordinatorLimit.getCluster(), coordinatorLimit.getTraitSet(), newExchange, coordinatorLimit.getOffset(), coordinatorLimit.getLimit(), true); call.transformTo(newCoordinatorLimit); }); }</code><technical_language>Minor: factor out creation of VoltPhysicalLimit object a static method? private static VoltPhysicalLimit of(VoltPhysicalLimit limit, RelNode input) (or put a constructor of VoltPhysicalLimit class)</technical_language>

Target:
private void transposeLimitExchange(RelOptRuleCall call) { VoltPhysicalLimit coordinatorLimit = (VoltPhysicalLimit) call.rels[0]; Exchange exchange = (Exchange) call.rels[1]; RelNode child = call.rels[2]; VoltRelUtil.buildFragmentLimit(coordinatorLimit, exchange.getDistribution(), child) .ifPresent(fragmentLimit -> { Exchange newExchange = exchange.copy(exchange.getTraitSet(), fragmentLimit, exchange.getDistribution()); VoltPhysicalLimit newCoordinatorLimit = coordinatorLimit.copy( coordinatorLimit.getTraitSet(), newExchange, coordinatorLimit.getOffset(), coordinatorLimit.getLimit(), true); call.transformTo(newCoordinatorLimit); }); }
Source:
<code>public void exec( String name, String containerName, int timeoutMin, String[] command, BiConsumer<String, String> outputConsumer) throws InfrastructureException { final String podName = getPodName(name); final ExecWatchdog watchdog = new ExecWatchdog(); final ByteArrayOutputStream errStream = new ByteArrayOutputStream(ERROR_BUFF_INITIAL_CAP); final ByteArrayOutputStream outputStream = new ByteArrayOutputStream(ERROR_BUFF_INITIAL_CAP); try (ExecWatch watch = clientFactory .create(workspaceId) .pods() .inNamespace(namespace) .withName(podName) .inContainer(containerName) .writingOutput(outputStream) .writingError(errStream) .usingListener(watchdog) .exec(encode(command))) { try { watchdog.wait(timeoutMin, TimeUnit.MINUTES); <START> final byte[] output = outputStream.toByteArray(); <END> if (output.length > 0) { final String cmd = Arrays.stream(command).collect(Collectors.joining(" ", "", "\n")); final String err = new String(output, UTF_8); outputConsumer.accept(STDOUT, cmd); outputConsumer.accept(STDERR, err); } final byte[] error = errStream.toByteArray(); if (error.length > 0) { final String cmd = Arrays.stream(command).collect(Collectors.joining(" ", "", "\n")); final String err = new String(error, UTF_8); outputConsumer.accept(STDOUT, cmd); outputConsumer.accept(STDERR, err); throw new InfrastructureException(err); } } catch (InterruptedException ex) { Thread.currentThread().interrupt(); throw new InfrastructureException(ex.getMessage(), ex); } } catch (KubernetesClientException ex) { throw new KubernetesInfrastructureException(ex); } }</code><technical_language>elaborate need this now</technical_language>

Target:
public void exec( String name, String containerName, int timeoutMin, String[] command, BiConsumer<String, String> outputConsumer) throws InfrastructureException { final String podName = getPodName(name); final ExecWatchdog watchdog = new ExecWatchdog(); final ByteArrayOutputStream errStream = new ByteArrayOutputStream(ERROR_BUFF_INITIAL_CAP); try (ExecWatch watch = clientFactory .create(workspaceId) .pods() .inNamespace(namespace) .withName(podName) .inContainer(containerName) .writingError(errStream) .usingListener(watchdog) .exec(encode(command))) { try { watchdog.wait(timeoutMin, TimeUnit.MINUTES); final byte[] error = errStream.toByteArray(); if (error.length > 0) { final String cmd = Arrays.stream(command).collect(Collectors.joining(" ", "", "\n")); final String err = new String(error, UTF_8); outputConsumer.accept(STDOUT, cmd); outputConsumer.accept(STDERR, err); throw new InfrastructureException(err); } } catch (InterruptedException ex) { Thread.currentThread().interrupt(); throw new InfrastructureException(ex.getMessage(), ex); } } catch (KubernetesClientException ex) { throw new KubernetesInfrastructureException(ex); } }
Source:
<code>private void setupMessageHandlers() { bridge.addListener("requestSection", new CommunicationBridge.JSEventListener() { @Override public void onMessage(String messageType, JSONObject messagePayload) { try { int index = messagePayload.optInt("index"); if (index >= page.getSections().size()) { bridge.sendMessage("noMoreSections", new JSONObject()); } else { JSONObject wrapper = new JSONObject(); wrapper.put("section", page.getSections().get(index).toJSON()); wrapper.put("index", index); wrapper.put("isLast", index == page.getSections().size() - 1); wrapper.put("fragment", page.getTitle().getFragment()); bridge.sendMessage("displaySection", wrapper); if (section != null && index == page.getSections().size() - 1) { <START> JSONObject payload = new JSONObject(); <END> try { payload.put("anchor", section.isLead() ? "heading_" + section.getId() : section.getAnchor()); } catch (JSONException e) { throw new RuntimeException(e); } bridge.sendMessage("scrollToSection", payload); section = null; } } } catch (JSONException e) { throw new RuntimeException(e); } } }); boolean isAnonEditingDisabled = app.getRemoteConfig().getConfig().has("disableAnonEditing") && app.getRemoteConfig().getConfig().optBoolean("disableAnonEditing") && !app.getUserInfoStorage().isLoggedIn(); if (isAnonEditingDisabled || title.isFilePage()) { bridge.sendMessage("hideEditButtons", new JSONObject()); } }</code><technical_language>a function called scrollToSection in ToCHandler this. need do is change function private public, call tocHandler.scrollToSection(section) here</technical_language>

Target:
private void setupMessageHandlers() { bridge.addListener("requestSection", new CommunicationBridge.JSEventListener() { @Override public void onMessage(String messageType, JSONObject messagePayload) { try { int index = messagePayload.optInt("index"); if (index >= page.getSections().size()) { bridge.sendMessage("noMoreSections", new JSONObject()); } else { JSONObject wrapper = new JSONObject(); wrapper.put("section", page.getSections().get(index).toJSON()); wrapper.put("index", index); wrapper.put("isLast", index == page.getSections().size() - 1); wrapper.put("fragment", page.getTitle().getFragment()); bridge.sendMessage("displaySection", wrapper); if (scrollSectionId != -1 && index == page.getSections().size() - 1 && tocHandler != null) { Section scrollSection = page.getSections().get(scrollSectionId); tocHandler.scrollToSection(scrollSection); scrollSectionId = -1; } } } catch (JSONException e) { throw new RuntimeException(e); } } }); boolean isAnonEditingDisabled = app.getRemoteConfig().getConfig().has("disableAnonEditing") && app.getRemoteConfig().getConfig().optBoolean("disableAnonEditing") && !app.getUserInfoStorage().isLoggedIn(); if (isAnonEditingDisabled || title.isFilePage()) { bridge.sendMessage("hideEditButtons", new JSONObject()); } }
Source:
<code>public AuthenticationProvider oidcAuthenticationProvider() { SimpleGrantedAuthority ROLE_ADMIN = new SimpleGrantedAuthority("ROLE_ADMIN"); SimpleGrantedAuthority ROLE_COMMITTEE = new SimpleGrantedAuthority("ROLE_COMMITTEE"); SimpleGrantedAuthority ROLE_USER = new SimpleGrantedAuthority("ROLE_USER"); OIDCAuthenticationProvider authenticationProvider = new OIDCAuthenticationProvider(); authenticationProvider.setUserInfoFetcher(new CHUserInfoFetcher()); authenticationProvider.setAuthoritiesMapper((idToken, userInfo) -> { if (userInfo instanceof CHUserInfo) { CHUserInfo info = (CHUserInfo) userInfo; if (properties.getAdminGroups().stream().anyMatch(info.getLdapGroups()::contains)) { return ImmutableSet.of(ROLE_ADMIN, ROLE_USER, ROLE_COMMITTEE); <START> } else if (info.getLdapGroups().stream().filter(group -> group.equals("users")).count() > 0) { <END> return ImmutableSet.of(ROLE_USER, ROLE_COMMITTEE); } else { return ImmutableSet.of(ROLE_USER); } } throw new AccessDeniedException("Invalid user info!"); }); return authenticationProvider; }</code><technical_language>info.getLdapGroups().contains("users")</technical_language>

Target:
public AuthenticationProvider oidcAuthenticationProvider() { final SimpleGrantedAuthority roleAdmin = new SimpleGrantedAuthority("ROLE_ADMIN"); final SimpleGrantedAuthority roleCommittee = new SimpleGrantedAuthority("ROLE_COMMITTEE"); final SimpleGrantedAuthority roleUser = new SimpleGrantedAuthority("ROLE_USER"); OIDCAuthenticationProvider authenticationProvider = new OIDCAuthenticationProvider(); authenticationProvider.setUserInfoFetcher(new CHUserInfoFetcher()); authenticationProvider.setAuthoritiesMapper((idToken, userInfo) -> { if (userInfo instanceof CHUserInfo) { CHUserInfo info = (CHUserInfo) userInfo; if (properties.getAdminGroups().stream().anyMatch(info.getLdapGroups()::contains)) { return ImmutableSet.of(roleAdmin, roleUser, roleCommittee); } else if (info.getLdapGroups().stream().filter(group -> !group.equals("users")).count() > 0) { return ImmutableSet.of(roleUser, roleCommittee); } else { return ImmutableSet.of(roleUser); } } throw new AccessDeniedException("Invalid user info!"); }); return authenticationProvider; }
Source:
<code>public void onResume() { super.onResume(); ActivityId.trackLastActivity(ActivityId.COMMENT_DETAIL); AnalyticsUtils.trackCommentActionWithSiteDetails( <START> Stat.COMMENT_VIEWED, mCommentSource.toAnalyticsCommentActionSource(), mSite); <END> if (!TextUtils.isEmpty(mRestoredNoteId)) { setNote(mRestoredNoteId); mRestoredNoteId = null; } }</code><technical_language>avoid tracking this if coming another screen? wdyt</technical_language>

Target:
public void onResume() { super.onResume(); ActivityId.trackLastActivity(ActivityId.COMMENT_DETAIL); if (!TextUtils.isEmpty(mRestoredNoteId)) { setNote(mRestoredNoteId); mRestoredNoteId = null; } }
Source:
<code>private void handleReceiveSubscriptionEntity(SubscriptionEntity subscriptionEntity) { compositeDisposable.add( subscriptionService.getChannelInfo(subscriptionEntity) .observeOn(Schedulers.io()) <START> .onErrorComplete((@io.reactivex.annotations.NonNull Throwable throwable) -> FeedFragment.super.onError( <END> throwable)) .subscribe(this.getReceiveChannelInfoHandler(subscriptionEntity.getUrl()), getFetchChannelInfoErrorHandler(subscriptionEntity.getServiceId(), subscriptionEntity.getUrl()))); }</code><technical_language>@io.reactivex.annotations.NonNull imported referenced @NonNull</technical_language>

Target:
private void handleReceiveSubscriptionEntity(SubscriptionEntity subscriptionEntity) { compositeDisposable.add( subscriptionService.getChannelInfo(subscriptionEntity) .observeOn(Schedulers.io()) .onErrorComplete((@NonNull Throwable throwable) -> FeedFragment.super.onError( throwable)) .subscribe(this.getReceiveChannelInfoHandler(subscriptionEntity.getUrl()), getFetchChannelInfoErrorHandler(subscriptionEntity.getServiceId(), subscriptionEntity.getUrl()))); }
Source:
<code>public void cleanup() throws DBException { <START> synchronized (GoraBenchmarkClient.class) { <END> if (dataStore != null) dataStore.close(); } }</code><technical_language>explain chosen synchronization here? allow single thread execute close method dataStore? isClosed similar state variable for init(). If s a possibility of this method cleanup() multiple threads, threads execute this method sequentially. in dataStores, handled close method, multiple calls close() try close closed dataStore, log handle error there. Is cases need propagate DBException exception higher layer? dont propagate throw exceptions dataStore.close()</technical_language>

Target:
public void cleanup() throws DBException { if (dataStore != null) dataStore.close(); }
Source:
<code>private static Bitmap attemptBoundedScaleUp(String imageFilepath, int desiredHeight, int desiredWidth, int boundingHeight, int boundingWidth) { if (boundingHeight < desiredHeight || boundingWidth < desiredWidth) { <START> float heightScale = ((float)boundingHeight) / desiredHeight; <END> float widthScale = ((float)boundingWidth) / desiredWidth; float boundingScaleDownFactor = Math.min(heightScale, widthScale); desiredHeight = Math.round(desiredHeight * boundingScaleDownFactor); desiredWidth = Math.round(desiredWidth * boundingScaleDownFactor); } try { BitmapFactory.Options o = new BitmapFactory.Options(); o.inScaled = false; Bitmap originalBitmap = BitmapFactory.decodeFile(imageFilepath, o); try { return Bitmap.createScaledBitmap(originalBitmap, desiredWidth, desiredHeight, false); } catch (OutOfMemoryError e) { return originalBitmap; } } catch (OutOfMemoryError e) { return performSafeScaleDown(imageFilepath, 2, 1); } }</code><technical_language>This pattern a times. wondering improve clarity a submethod</technical_language>

Target:
private static Bitmap attemptBoundedScaleUp(String imageFilepath, int desiredHeight, int desiredWidth, int boundingHeight, int boundingWidth) { if (boundingHeight < desiredHeight || boundingWidth < desiredWidth) { Pair<Integer, Integer> dimensImposedByContainer = getProportionalDimensForContainer( desiredHeight, desiredWidth, boundingHeight, boundingWidth); desiredWidth = dimensImposedByContainer.first; desiredHeight = dimensImposedByContainer.second; } try { BitmapFactory.Options o = new BitmapFactory.Options(); o.inScaled = false; Bitmap originalBitmap = BitmapFactory.decodeFile(imageFilepath, o); try { return Bitmap.createScaledBitmap(originalBitmap, desiredWidth, desiredHeight, false); } catch (OutOfMemoryError e) { return originalBitmap; } } catch (OutOfMemoryError e) { return performSafeScaleDown(imageFilepath, 2, 1); } }
Source:
<code>public void testDroppedColumns() throws SQLException { if (!TestUtil.haveMinimumServerVersion(con, ServerVersion.v8_4)) { return; } Statement stmt = con.createStatement(); stmt.execute("ALTER TABLE metadatatest DROP name"); stmt.execute("ALTER TABLE metadatatest DROP colour"); stmt.close(); DatabaseMetaData dbmd = con.getMetaData(); ResultSet rs = dbmd.getColumns(null, null, "metadatatest", null); assertTrue(rs.next()); assertEquals("id", rs.getString("COLUMN_NAME")); assertEquals(1, rs.getInt("ORDINAL_POSITION")); assertTrue(rs.next()); assertEquals("updated", rs.getString("COLUMN_NAME")); assertEquals(2, rs.getInt("ORDINAL_POSITION")); assertTrue(rs.next()); assertEquals("quest", rs.getString("COLUMN_NAME")); assertEquals(3, rs.getInt("ORDINAL_POSITION")); rs.close(); rs = dbmd.getColumns(null, null, "metadatatest", "quest"); assertTrue(rs.next()); assertEquals("quest", rs.getString("COLUMN_NAME")); assertEquals(3, rs.getInt("ORDINAL_POSITION")); assertTrue(!rs.next()); rs.close(); <START> rs = dbmd.getFunctionColumns(null, null, "f2", null); <END> assertTrue(rs.next()); assertTrue(rs.next()); assertEquals("a", rs.getString(4)); assertTrue(rs.next()); assertEquals("b", rs.getString(4)); assertTrue(!rs.next()); rs.close(); }</code><technical_language>this reproduce problem? I thought function relate table. I see, f2 is defined f2(a int, b varchar) RETURNS int, I is related TABLE metadatatest</technical_language>

Target:
public void testDroppedColumns() throws SQLException { if (!TestUtil.haveMinimumServerVersion(con, ServerVersion.v8_4)) { return; } Statement stmt = con.createStatement(); stmt.execute("ALTER TABLE metadatatest DROP name"); stmt.execute("ALTER TABLE metadatatest DROP colour"); stmt.close(); DatabaseMetaData dbmd = con.getMetaData(); ResultSet rs = dbmd.getColumns(null, null, "metadatatest", null); assertTrue(rs.next()); assertEquals("id", rs.getString("COLUMN_NAME")); assertEquals(1, rs.getInt("ORDINAL_POSITION")); assertTrue(rs.next()); assertEquals("updated", rs.getString("COLUMN_NAME")); assertEquals(2, rs.getInt("ORDINAL_POSITION")); assertTrue(rs.next()); assertEquals("quest", rs.getString("COLUMN_NAME")); assertEquals(3, rs.getInt("ORDINAL_POSITION")); rs.close(); rs = dbmd.getColumns(null, null, "metadatatest", "quest"); assertTrue(rs.next()); assertEquals("quest", rs.getString("COLUMN_NAME")); assertEquals(3, rs.getInt("ORDINAL_POSITION")); assertTrue(!rs.next()); rs.close(); rs = dbmd.getFunctionColumns(null, null, "f4", null); assertTrue(rs.next()); assertTrue(rs.next()); assertEquals("id", rs.getString(4)); assertTrue(rs.next()); assertEquals("updated", rs.getString(4)); rs.close(); }
Source:
<code>public SubTabNetworkHostView(SearchableDetailModelProvider<PairQueryable<VdsNetworkInterface, VDS>, NetworkListModel, NetworkHostListModel> modelProvider) { super(modelProvider); viewRadioGroup = new ViewRadioGroup<>(Arrays.asList(NetworkHostFilter.values())); viewRadioGroup.setSelectedValue(NetworkHostFilter.attached); <START> viewRadioGroup.addChangeHandler(selected -> { <END> onRadioButtonChange(selected); }); labelImage = SafeHtmlUtils.fromTrustedString(AbstractImagePrototype.create(resources.tagImage()).getHTML()); initTable(); initWidget(getTableContainer()); }</code><technical_language>change viewRadioGroup.addChangeHandler(selected -> onRadioButtonChange(selected));</technical_language>

Target:
public SubTabNetworkHostView(SearchableDetailModelProvider<PairQueryable<VdsNetworkInterface, VDS>, NetworkListModel, NetworkHostListModel> modelProvider) { super(modelProvider); viewRadioGroup = new ViewRadioGroup<>(Arrays.asList(NetworkHostFilter.values())); viewRadioGroup.setSelectedValue(NetworkHostFilter.attached); viewRadioGroup.addChangeHandler(selected -> onRadioButtonChange(selected)); labelImage = SafeHtmlUtils.fromTrustedString(AbstractImagePrototype.create(resources.tagImage()).getHTML()); initTable(); initWidget(getTableContainer()); }