auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public boolean equals(Object obj) { if(this == obj) { return true; } <START> if(obj.getClass() != this.getClass()) { <END> return false; } ResolverConfiguration other = (ResolverConfiguration) obj; return this.resolveWorkspaceProjects == other.resolveWorkspaceProjects && Objects.equals(this.selectedProfiles, other.selectedProfiles) && Objects.equals(this.lifecycleMappingId, other.lifecycleMappingId) && Objects.equals(this.properties, other.properties); }</code><technical_language>null safe</technical_language>

Target:
public boolean equals(Object obj) { if(this == obj) { return true; } if(obj == null) { return false; } if(obj.getClass() != this.getClass()) { return false; } ResolverConfiguration other = (ResolverConfiguration) obj; return this.resolveWorkspaceProjects == other.resolveWorkspaceProjects && Objects.equals(this.selectedProfiles, other.selectedProfiles) && Objects.equals(this.lifecycleMappingId, other.lifecycleMappingId) && Objects.equals(this.properties, other.properties); }
Source:
<code><START> public SubQueryInfo getSubQueryInfo() { <END> return subQueryInfoStack.peekLast(); }</code><technical_language>getLastSubQueyInfo</technical_language>

Target:
public SubQueryInfo getSubQueryInfo() { return subQueryInfo; }
Source:
<code>private void processConfKey(Writer writer, String param) throws ParseException, IOException, ServiceException, SQLException { String value = tajoConf.get(param); if (value != null) { writer.write(value); } else { <START> writer.write("Configuration a is missing."); <END> } writer.write("\n"); }</code><technical_language>a typo</technical_language>

Target:
private void processConfKey(Writer writer, String param) throws ParseException, IOException, ServiceException, SQLException { String value = tajoClient.getConf().getTrimmed(param); if (value == null) { for(TajoConf.ConfVars vars : TajoConf.ConfVars.values()) { if (vars.varname.equalsIgnoreCase(param)) { value = tajoClient.getConf().getVar(vars); break; } } } if (value != null) { writer.write(value); } else { writer.write("Configuration " + param + " is missing."); } writer.write("\n"); }
Source:
<code><START> public Iterable<DoubleSegment> getParts() { <END> List<DoubleSegment> result = new ArrayList<>(); result.add(getTopEdge()); result.add(getLeftEdge()); result.add(getRightEdge()); result.add(getBottomEdge()); return result; }</code><technical_language>I List</technical_language>

Target:
public List<DoubleSegment> getParts() { return asList(getTopEdge(), getLeftEdge(), getRightEdge(), getBottomEdge()); }
Source:
<code>public void queryAllUsers() throws Exception { String query = "SELECT * from c"; FeedOptions options = new FeedOptions(); int maxItemCount = 2; String databaseLink = TestUtils.getDatabaseNameLink(databaseId); CosmosPagedFlux<CosmosUserProperties> queryObservable = createdDatabase.queryUsers(query, options); List<CosmosUserProperties> expectedUsers = createdUsers; assertThat(expectedUsers).isNotEmpty(); int expectedPageSize = (expectedUsers.size() + maxItemCount - 1) / maxItemCount; FeedResponseListValidator<CosmosUserProperties> validator = new FeedResponseListValidator.Builder<CosmosUserProperties>() .totalSize(expectedUsers.size()) <START> .exactlyContainsInAnyOrder(expectedUsers.stream().map(CosmosUserProperties::getId).collect(Collectors.toList())) <END> .numberOfPages(expectedPageSize) .pageSatisfy(0, new FeedResponseValidator.Builder<CosmosUserProperties>() .requestChargeGreaterThanOrEqualTo(1.0).build()) .build(); validateQuerySuccess(queryObservable.byPage(maxItemCount), validator, 10000); }</code><technical_language>replacing getResourceId() -> getId() please tests pass ? else in changes</technical_language>

Target:
public void queryAllUsers() throws Exception { String query = "SELECT * from c"; FeedOptions options = new FeedOptions(); int maxItemCount = 2; String databaseLink = TestUtils.getDatabaseNameLink(databaseId); CosmosPagedFlux<CosmosUserProperties> queryObservable = createdDatabase.queryUsers(query, options); List<CosmosUserProperties> expectedUsers = createdUsers; assertThat(expectedUsers).isNotEmpty(); int expectedPageSize = (expectedUsers.size() + maxItemCount - 1) / maxItemCount; FeedResponseListValidator<CosmosUserProperties> validator = new FeedResponseListValidator.Builder<CosmosUserProperties>() .totalSize(expectedUsers.size()) .exactlyContainsIdsInAnyOrder(expectedUsers.stream().map(CosmosUserProperties::getId).collect(Collectors.toList())) .numberOfPages(expectedPageSize) .pageSatisfy(0, new FeedResponseValidator.Builder<CosmosUserProperties>() .requestChargeGreaterThanOrEqualTo(1.0).build()) .build(); validateQuerySuccess(queryObservable.byPage(maxItemCount), validator, 10000); }
Source:
<code>public void init() { caseService = new CallerMock<>(caseManagementService); when(caseManagementService.getCaseInstances(any(CaseInstanceSearchRequest.class))).thenReturn(caseInstanceSummaryList); presenter.setCaseService(caseService); when(view.getCaseInstanceSearchRequest()).thenReturn(new CaseInstanceSearchRequest()); doAnswer((i) ->{ <START> presenter.refreshData(); <END> return null; }).when(actions).onRefreshCaseClick(any(MouseEvent.class)); }</code><technical_language>I gave a thought this test class I in mocking bit needs tested. if create a new test class for CaseInstanceListSearchViewImpl mock presenter verify called</technical_language>

Target:
public void init() { caseService = new CallerMock<>(caseManagementService); when(caseManagementService.getCaseInstances(any(CaseInstanceSearchRequest.class))).thenReturn(caseInstanceSummaryList); presenter.setCaseService(caseService); when(view.getCaseInstanceSearchRequest()).thenReturn(new CaseInstanceSearchRequest()); }
Source:
<code>public void start(BundleContext context) throws Exception { super.start(context); <START> Hashtable<String, String> properties = new Hashtable<String, String>(2); <END> properties.put(DebugOptions.LISTENER_SYMBOLICNAME, PLUGIN_ID); debugRegistration = context.registerService(DebugOptionsListener.class, Policy.DEBUG_OPTIONS_LISTENER, properties); ComparePlugin.getDefault().setCappingDisabled( getPreferenceStore().getBoolean( ComparePreferencePage.CAPPING_DISABLED)); }</code><technical_language>new Hashtable<></technical_language>

Target:
public void start(BundleContext context) throws Exception { super.start(context); Hashtable<String, String> properties = new Hashtable<>(2); properties.put(DebugOptions.LISTENER_SYMBOLICNAME, PLUGIN_ID); debugRegistration = context.registerService(DebugOptionsListener.class, Policy.DEBUG_OPTIONS_LISTENER, properties); ComparePlugin.getDefault().setCappingDisabled( getPreferenceStore().getBoolean( ComparePreferencePage.CAPPING_DISABLED)); }
Source:
<code>public HttpRequest filter(HttpRequest request) throws HttpException { String endpoint = request.getEndpoint().toString(); <START> Pattern pattern = Pattern.compile("/[^/]*$"); END> Matcher matcher = pattern.matcher(endpoint); matcher.find(); String encodable = matcher.group(); String encoded = encodable.replace(".", "%2e"); String newEndpoint = matcher.replaceFirst(encoded); return request.toBuilder().endpoint(newEndpoint).build(); }</code><technical_language>Extract a constant</technical_language>

Target:
public HttpRequest filter(HttpRequest request) throws HttpException { String endpoint = request.getEndpoint().toString(); Matcher matcher = pattern.matcher(endpoint); if(!matcher.find()) return request; String encodable = matcher.group(); String encoded = encodable.replace(".", "%2e"); String newEndpoint = matcher.replaceFirst(encoded); return request.toBuilder().endpoint(newEndpoint).build(); }
Source:
<code>public synchronized Collection<@Nullable V> values() { <START> final Collection<V> values = new LinkedList<>(); <END> for (final ExpiringCache<V> item : items.values()) { values.add(item.getValue()); } return values; }</code><technical_language>This a mismatch, include @Nullable here</technical_language>

Target:
public synchronized Collection<@Nullable V> values() { final Collection<@Nullable V> values = new LinkedList<>(); for (final ExpiringCache<@Nullable V> item : items.values()) { values.add(item.getValue()); } return values; }
Source:
<code>public boolean containsArgument(final String requestName, final String argName) { <START> if(typeMapper.containsKey(requestName) && typeMapper.get(requestName).containsKey(argName)) { <END> return true; } return false; }</code><technical_language>This conditional expression returned</technical_language>

Target:
public boolean containsArgument(final String requestName, final String argName) { return typeMapper.containsKey(requestName) && typeMapper.get(requestName).containsKey(argName); }
Source:
<code>public void testAbortAndRestartTwice() throws Exception { FreeStyleProject testproject = j.createFreeStyleProject(); AbsoluteTimeOutStrategy strategy = new AbsoluteTimeOutStrategy(Integer.toString(3)); AbortAndRestartOperation operation = new AbortAndRestartOperation(2); LinkedList<BuildTimeOutOperation> list = new LinkedList<BuildTimeOutOperation>(); list.add(operation); BuildTimeoutWrapper wrapper = new BuildTimeoutWrapper(strategy,list,""); testproject.getBuildWrappersList().add(wrapper); if(System.getProperty("os.name").contains("Windows")){ BatchFile builder = new BatchFile("ping -n 500 127.0.0.1 &amp;gt;nul"); testproject.getBuildersList().add(builder); }else{ Shell builder = new Shell("sleep 500"); testproject.getBuildersList().add(builder); } <START> <END> assertTrue(testproject.getBuilds().size()==0); testproject.scheduleBuild(new Cause.UserIdCause()); try{ Thread.sleep((3*60*1000)+20000); }catch(InterruptedException e){ } assertTrue(testproject.getFirstBuild() != null); assertTrue(testproject.getFirstBuild().equals(testproject.getLastBuild())); assertEquals(testproject.getBuilds().size(), 1); try{ Thread.sleep((3*60*1000)+20000); }catch(InterruptedException e){ } try{ Thread.sleep((3*60*1000)+20000); }catch(InterruptedException e){ } assertTrue(testproject.getFirstBuild() != null); assertFalse(testproject.getFirstBuild().equals(testproject.getLastBuild())); assertEquals(testproject.getBuilds().size(), 3); Thread.sleep(5000); assertEquals(testproject.getBuilds().size(), 3); assertEquals(Result.ABORTED, testproject.getBuildByNumber(1).getResult()); assertEquals(Result.ABORTED, testproject.getBuildByNumber(2).getResult()); assertEquals(Result.ABORTED, testproject.getBuildByNumber(3).getResult()); }</code><technical_language>[SleepBuilder](<LINK_1> instead. <LINK_0></technical_language>

Target:
public void testAbortAndRestartTwice() throws Exception { FreeStyleProject testproject = j.createFreeStyleProject(); QuickBuildTimeOutStrategy strategy = new QuickBuildTimeOutStrategy(5000); AbortAndRestartOperation operation = new AbortAndRestartOperation("2"); LinkedList<BuildTimeOutOperation> list = new LinkedList<BuildTimeOutOperation>(); list.add(operation); BuildTimeoutWrapper wrapper = new BuildTimeoutWrapper(strategy,list,""); testproject.getBuildWrappersList().add(wrapper); testproject.getBuildersList().add(new SleepBuilder(5*60*1000)); assertTrue(testproject.getBuilds().size()==0); testproject.scheduleBuild(new Cause.UserIdCause()); j.waitUntilNoActivityUpTo(25000); assertNotNull(testproject.getFirstBuild()); assertFalse(testproject.getFirstBuild().equals(testproject.getLastBuild())); assertEquals(testproject.getBuilds().size(), 3); assertEquals(Result.ABORTED, testproject.getBuildByNumber(1).getResult()); assertEquals(Result.ABORTED, testproject.getBuildByNumber(2).getResult()); assertEquals(Result.ABORTED, testproject.getBuildByNumber(3).getResult()); }
Source:
<code>static void scheduleCMClearer(Configuration conf) { if (MetastoreConf.getBoolVar(conf, ConfVars.REPLCMENABLED)) { ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor( new BasicThreadFactory.Builder() .namingPattern(CM_THREAD_NAME_PREFIX + "%d") .daemon(true) .build()); <START> for (Path cmroot : cmRootMapping.values()) { <END> executor.scheduleAtFixedRate(new CMClearer(cmroot.toString(), MetastoreConf.getTimeVar(conf, ConfVars.REPLCMRETIAN, TimeUnit.SECONDS), conf), 0, MetastoreConf.getTimeVar(conf, ConfVars.REPLCMINTERVAL, TimeUnit.SECONDS), TimeUnit.SECONDS); } } }</code><technical_language>map is populated run time..so init time entry added map. I send map scheduler iterate cleanup cm root for EZ in map</technical_language>

Target:
static void scheduleCMClearer(Configuration conf) { if (MetastoreConf.getBoolVar(conf, ConfVars.REPLCMENABLED)) { ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor( new BasicThreadFactory.Builder() .namingPattern(CM_THREAD_NAME_PREFIX + "%d") .daemon(true) .build()); executor.scheduleAtFixedRate(new CMClearer(encryptionZones, MetastoreConf.getTimeVar(conf, ConfVars.REPLCMRETIAN, TimeUnit.SECONDS), conf), 0, MetastoreConf.getTimeVar(conf, ConfVars.REPLCMINTERVAL, TimeUnit.SECONDS), TimeUnit.SECONDS); } }
Source:
<code>public void tearDown() throws Exception { ofNullable(service).ifPresent(AppiumDriverLocalService::stop); if (stream != null) { stream.close(); } ofNullable(file).ifPresent(fileArg -> { <START> if (file.exists()) { <END> file.delete(); } }); System.clearProperty(APPIUM_PATH); ofNullable(pathToAppiumNodeInProperties).ifPresent(s -> System.setProperty(APPIUM_PATH, s)); }</code><technical_language>file fileArg</technical_language>

Target:
public void tearDown() throws Exception { ofNullable(service).ifPresent(AppiumDriverLocalService::stop); if (stream != null) { stream.close(); } ofNullable(testLogFile).ifPresent(savedTestLogFile -> { if (savedTestLogFile.exists()) { savedTestLogFile.delete(); } }); System.clearProperty(APPIUM_PATH); ofNullable(PATH_TO_APPIUM_NODE_IN_PROPERTIES).ifPresent(s -> setProperty(APPIUM_PATH, s)); }
Source:
<code>protected Object decode( ChannelHandlerContext ctx, Channel channel, ChannelBuffer buf) throws Exception { if (buf.readableBytes() == 0) { return null; } <START> byte[] bytes = new byte[buf.readableBytes()]; <END> buf.getBytes(0, bytes); if (bytes[0] == HEADER_START_SIGN && bytes.length == HEADER_LENGTH && (bytes[1] == HEADER_VERSION_1 || bytes[1] == HEADER_VERSION_2)) { return buf.readBytes(HEADER_LENGTH); } int parcelNumber = bytes[1] & 0xFF; if (bytes[0] == PACKAGE_START_SIGN && bytes[bytes.length - 1] == PACKAGE_END_SIGN && parcelNumber >= PACKAGE_MIN_PARCEL_NUMBER && parcelNumber <= PACKAGE_MAX_PARCEL_NUMBER) { return buf.readBytes(bytes.length); } return null; }</code><technical_language>do need copy array? I unnecessary</technical_language>

Target:
protected Object decode( ChannelHandlerContext ctx, Channel channel, ChannelBuffer buf) throws Exception { if (buf.readableBytes() < MIN_LENGTH) { return null; } int length; if (firstPacket) { firstPacket = false; length = HEADER_LENGTH; } else { int index = buf.getUnsignedByte(1); if (index == COMMAND_ANSWER_PARCEL_NUMBER) { length = COMMAND_ANSWER_PACKET_LENGTH; } else { int pos = 2; while (pos + PACKET_WRAPPER_LENGTH < buf.readableBytes() && buf.getByte(pos) != PACKAGE_END_SIGN) { int dataLength = buf.getUnsignedShort(pos + 1); pos += PACKET_WRAPPER_LENGTH + dataLength; } if (buf.getByte(pos) != PACKAGE_END_SIGN) { return null; } length = pos + 1; } } if (buf.readableBytes() >= length) { return buf.readBytes(length); } return null; }
Source:
<code>public List<Response> listAll() { List<Sample> listSample = findAll(); List<Response> listRetorno = new ArrayList<Response>(); for (Sample sample : listSample) { SampleResponse sr = new SampleResponse(); sr.setName(sample.getName()); listRetorno.add(sr); } <START> return listRetorno; <END> }</code><technical_language>Please English</technical_language>

Target:
public List<Response> listAll() { List<Sample> listSample = findAll(); List<Response> listReturn = new ArrayList<Response>(); for (Sample sample : listSample) { SampleResponse sr = new SampleResponse(); sr.setName(sample.getName()); listReturn.add(sr); } return listReturn; }
Source:
<code>public OpenTxnsResponse open_txns(OpenTxnRequest rqst) throws TException { OpenTxnsResponse response = getTxnHandler().openTxns(rqst); if (!listeners.isEmpty()) { List<Long> txnIds = response.getTxn_ids(); for (Long id : txnIds) { <START> MetaStoreListenerNotifier.notifyEvent(transactionalListeners, <END> EventType.OPEN_TXN, new OpenTxnEvent(id, true, this)); } } return response; }</code><technical_language>check is for listeners passed transactionalListeners. Need check for need notify both</technical_language>

Target:
public OpenTxnsResponse open_txns(OpenTxnRequest rqst) throws TException { OpenTxnsResponse response = getTxnHandler().openTxns(rqst); List<Long> txnIds = response.getTxn_ids(); if (!listeners.isEmpty()) { MetaStoreListenerNotifier.notifyEvent(listeners,EventType.OPEN_TXN, new OpenTxnEvent(txnIds.iterator(),this)); } if (!transactionalListeners.isEmpty()) { MetaStoreListenerNotifier.notifyEvent(transactionalListeners, EventType.OPEN_TXN, new OpenTxnEvent(txnIds.iterator(),this)); } return response; }
Source:
<code>public boolean assignVMToBackupOffering(final VirtualMachine vm, final BackupOffering backupOffering) { final VeeamClient client = getClient(vm.getDataCenterId()); final Job parentJob = client.listJob(backupOffering.getExternalId()); final String clonedJobName = getGuestBackupName(vm.getInstanceName(), vm.getUuid()); if (client.cloneVeeamJob(parentJob, clonedJobName)) { for (BackupOffering job : client.listJobs()) { if (job.getName().equals(clonedJobName)) { final Job clonedJob = client.listJob(job.getExternalId()); if (clonedJob.getScheduleConfigured() && !clonedJob.getScheduleEnabled()) { client.toggleJobSchedule(clonedJob.getId()); } final VmwareDatacenter vmwareDC = findVmwareDatacenterForVM(vm); if (client.addVMToVeeamJob(job.getExternalId(), vm.getInstanceName(), vmwareDC.getVcenterHost())) { <START> ((VMInstanceVO) vm).setBackupExternalId(job.getExternalId()); <END> return true; } } } } else { LOG.error("Failed to clone pre-defined Veeam job (backup offering) for backup offering ID: " + backupOffering.getExternalId()); } return false; }</code><technical_language>move this BackupManager set external ID if operation successful</technical_language>

Target:
public boolean assignVMToBackupOffering(final VirtualMachine vm, final BackupOffering backupOffering) { final VeeamClient client = getClient(vm.getDataCenterId()); final Job parentJob = client.listJob(backupOffering.getExternalId()); final String clonedJobName = getGuestBackupName(vm.getInstanceName(), vm.getUuid()); if (!client.cloneVeeamJob(parentJob, clonedJobName)) { LOG.error("Failed to clone pre-defined Veeam job (backup offering) for backup offering ID: " + backupOffering.getExternalId() + " but will check the list of jobs again if it was eventually succeeded."); } for (final BackupOffering job : client.listJobs()) { if (job.getName().equals(clonedJobName)) { final Job clonedJob = client.listJob(job.getExternalId()); if (clonedJob.getScheduleConfigured() && !clonedJob.getScheduleEnabled()) { client.toggleJobSchedule(clonedJob.getId()); } LOG.debug("Veeam job (backup offering) for backup offering ID: " + backupOffering.getExternalId() + " found, now trying to assign the VM to the job."); final VmwareDatacenter vmwareDC = findVmwareDatacenterForVM(vm); if (client.addVMToVeeamJob(job.getExternalId(), vm.getInstanceName(), vmwareDC.getVcenterHost())) { ((VMInstanceVO) vm).setBackupExternalId(job.getExternalId()); return true; } } } return false; }
Source:
<code>private WorkerCountResponse createResponse(){ WorkerCountResponse.Builder builder = WorkerCountResponse.newBuilder(); if (workerCountProvider == null) { return builder <START> .setValue(1) <END> .setCanSetWorkerCount(false) .build(); } return builder .setValue(workerCountProvider.get()) .setCanSetWorkerCount(true) .build(); }</code><technical_language>magic number</technical_language>

Target:
private WorkerCountResponse createResponse(){ WorkerCountResponse.Builder builder = WorkerCountResponse.newBuilder(); if (workerCountProvider == null) { return builder .setValue(DEFAULT_WORKER_COUNT) .setCanSetWorkerCount(false) .build(); } return builder .setValue(workerCountProvider.get()) .setCanSetWorkerCount(true) .build(); }
Source:
<code>private String executeDeleteRequest(String urlString, ParamsMap params) throws MalformedURLException, IOException, MambuApiException { String response = ""; Integer errorCode = null; if (params != null && params.size() > 0) { urlString = new String((urlHelper.createUrlWithParams(urlString, params))); } LOGGER.info("DELETE with URL with params=" + urlString); HttpParams httpParameters = new BasicHttpParams(); HttpClient httpClient = new DefaultHttpClient(httpParameters); HttpDelete httpDelete = new HttpDelete(urlString); httpDelete.setHeader("Authorization", "Basic " + encodedAuthorization); HttpResponse httpResponse = httpClient.execute(httpDelete); int status = httpResponse.getStatusLine().getStatusCode(); InputStream content = null; HttpEntity entity = httpResponse.getEntity(); if (entity != null) { content = entity.getContent(); if (content != null) response = readStream(content); } if (status != HttpURLConnection.HTTP_OK) { errorCode = status; LOGGER.info("Error status=" + status + " Error response=" + response); } if (errorCode == null) <START> LOGGER.info("Status=" + status + "\nResponse=" + response); <END> if (errorCode != null) { LOGGER.warning("Creating exception, error code=" + errorCode + " response=" + response); throw new MambuApiException(errorCode, response); } return response; }</code><technical_language>Please add {..}</technical_language>

Target:
private String executeDeleteRequest(String urlString, ParamsMap params) throws MalformedURLException, IOException, MambuApiException { String response = ""; Integer errorCode = null; if (params != null && params.size() > 0) { urlString = new String((urlHelper.createUrlWithParams(urlString, params))); } LOGGER.info("DELETE with URL with params=" + urlString); HttpParams httpParameters = new BasicHttpParams(); HttpClient httpClient = new DefaultHttpClient(httpParameters); HttpDelete httpDelete = new HttpDelete(urlString); httpDelete.setHeader("Authorization", "Basic " + encodedAuthorization); HttpResponse httpResponse = httpClient.execute(httpDelete); int status = httpResponse.getStatusLine().getStatusCode(); InputStream content = null; HttpEntity entity = httpResponse.getEntity(); if (entity != null) { content = entity.getContent(); if (content != null) response = readStream(content); } if (status != HttpURLConnection.HTTP_OK) { errorCode = status; LOGGER.info("Error status=" + status + " Error response=" + response); } if (errorCode == null) LOGGER.info("Status=" + status + "\nResponse=" + response); if (errorCode != null) { LOGGER.warning("Creating exception, error code=" + errorCode + " response=" + response + " for url=" + urlString); throw new MambuApiException(errorCode, response); } return response; }
Source:
<code>public Fare lookup (Stop from, Stop to) { return this.ignoreAgencyId <START> ? lookup(from.stopId.split(":")[1], to.stopId.split(":")[1]) <END> : lookup(from.stopId, to.stopId); }</code><technical_language>wondering if a regex catch colon, in case a stop ID contains a colon (so a feed-qualified stop id of, say, WMATA:GalleryPlace:LowerLevel), stopId is GalleryPlace:LowerLevel</technical_language>

Target:
public Fare lookup (Stop from, Stop to) { if (this.ignoreAgencyId) { String fromWithoutFeedId = from.stopId.split(":", 2)[1]; String toWithoutFeedId = to.stopId.split(":", 2)[1]; return lookup(fromWithoutFeedId, toWithoutFeedId); } else { return lookup(from.stopId, to.stopId); } }
Source:
<code>public void test_write() throws Exception { final SilentServer ss = new SilentServer(); Socket s = new Socket(); int sendBufferSize = 1024; s.setSendBufferSize(sendBufferSize); s.connect(ss.getLocalSocketAddress()); new Killer(s).start(); try { System.err.println("write..."); <START> byte[] buf = new byte[256*1024]; <END> s.getOutputStream().write(buf); fail(); } catch (SocketException expected) { } ss.close(); }</code><technical_language>this buffer size is working exceeds send buffer recv buffer of other side</technical_language>

Target:
public void test_write() throws Exception { final SilentServer ss = new SilentServer(128); Socket s = new Socket(); int sendBufferSize = 1024; s.setSendBufferSize(sendBufferSize); sendBufferSize = s.getSendBufferSize(); sendBufferSize *= 2; s.connect(ss.getLocalSocketAddress()); new Killer(s).start(); try { System.err.println("write..."); byte[] buf = new byte[sendBufferSize]; s.getOutputStream().write(buf); fail(); } catch (SocketException expected) { } ss.close(); }
Source:
<code>public final boolean equals(Object o) { if (this == o) { return true; } if (!(o instanceof QueueConfig)) { return false; } QueueConfig that = (QueueConfig) o; return backupCount == that.backupCount && asyncBackupCount == that.asyncBackupCount && getMaxSize() == that.getMaxSize() && emptyQueueTtl == that.emptyQueueTtl && statisticsEnabled == that.statisticsEnabled <START> && name.equals(that.name) <END> && getItemListenerConfigs().equals(that.getItemListenerConfigs()) && Objects.equals(queueStoreConfig, that.queueStoreConfig) && Objects.equals(splitBrainProtectionName, that.splitBrainProtectionName) && Objects.equals(mergePolicyConfig, that.mergePolicyConfig); }</code><technical_language>This line appears prone NPE in case name is null (initial objects state). Objects.equals</technical_language>

Target:
public final boolean equals(Object o) { if (this == o) { return true; } if (!(o instanceof QueueConfig)) { return false; } QueueConfig that = (QueueConfig) o; return backupCount == that.backupCount && asyncBackupCount == that.asyncBackupCount && getMaxSize() == that.getMaxSize() && emptyQueueTtl == that.emptyQueueTtl && statisticsEnabled == that.statisticsEnabled && Objects.equals(name, that.name) && getItemListenerConfigs().equals(that.getItemListenerConfigs()) && Objects.equals(queueStoreConfig, that.queueStoreConfig) && Objects.equals(splitBrainProtectionName, that.splitBrainProtectionName) && Objects.equals(mergePolicyConfig, that.mergePolicyConfig); }
Source:
<code>private ModelNode processResponseHeaders(ModelNode responseHeaders) { if (!responseHeaders.hasDefined(ACCESS_CONTROL) || !forServer) { return responseHeaders; } else { ModelNode result = responseHeaders.clone(); for (ModelNode accItem : result.get(ACCESS_CONTROL).asList()) { <START> ModelNode itemAddrNode = accItem.get("absolute-address"); <END> PathAddress itemAddr = PathAddress.pathAddress(itemAddrNode); itemAddrNode.set(proxyController.getProxyNodeAddress().append(itemAddr).toModelNode()); } return result; } }</code><technical_language>I this is a blocker, "absolute-address" a constant well? I a big deal way</technical_language>

Target:
private ModelNode processResponseHeaders(ModelNode responseHeaders) { if (!responseHeaders.hasDefined(ACCESS_CONTROL) || !forServer) { return responseHeaders; } else { ModelNode result = responseHeaders.clone(); for (ModelNode accItem : result.get(ACCESS_CONTROL).asList()) { ModelNode itemAddrNode = accItem.get(ABSOLUTE_ADDRESS); PathAddress itemAddr = PathAddress.pathAddress(itemAddrNode); itemAddrNode.set(proxyController.getProxyNodeAddress().append(itemAddr).toModelNode()); } return result; } }
Source:
<code>private Class loadClass(URLClassLoader classLoader, String className) { try { return classLoader.loadClass(className); } catch (ClassNotFoundException e) { <START> LOG.error("Failed to load Task class " + className + " for new task in instance " + _manager .getInstanceName() + " in cluster " + _manager.getClusterName() + "."); throw new IllegalStateException("Class not found for task"); <END> } }</code><technical_language>error messages consistent</technical_language>

Target:
private Class loadClass(URLClassLoader classLoader, String className) { try { return classLoader.loadClass(className); } catch (ClassNotFoundException e) { String errorMessage = "Failed to load Task class " + className + " for new task in instance " + _manager .getInstanceName() + " in cluster " + _manager.getClusterName() + "."; LOG.error(errorMessage); throw new IllegalStateException(errorMessage); } }
Source:
<code><START> private void afterVMsRefreshTreatment() { <END> for (Guid vm_guid : _vmsToRerun) { log.errorFormat("Rerun vm {0}. Called from vds {1}", vm_guid, _vds.getName()); ResourceManager.getInstance().RerunFailedCommand(vm_guid, _vds.getId()); } for (Guid vm_guid : _succededToRunVms) { _vdsManager.succededToRunVm(vm_guid); } _autoVmsToRun.removeAll(_vmsToRerun); getVdsEventListener().runFailedAutoStartVMs(_autoVmsToRun); for (Entry<VM, VmDynamic> pair : _vmsClientIpChanged.entrySet()) { getVdsEventListener().processOnClientIpChange(_vds, pair.getValue().getId()); } for (VmDynamic runningVm : _poweringUpVms) { ResourceManager .getInstance() .getEventListener() .processOnVmPoweringUp(_vds.getId(), runningVm.getId(), runningVm.getDisplayIp(), runningVm.getDisplay()); } getVdsEventListener().processOnVmStop(_vmsMovedToDown); for (Guid vm_guid : _vmsToRemoveFromAsync) { ResourceManager.getInstance().RemoveAsyncRunningVm(vm_guid); } }</code><technical_language>need call this somewhere, right</technical_language>

Target:
private void afterVMsRefreshTreatment() { for (Guid vm_guid : _vmsToRerun) { log.errorFormat("Rerun vm {0}. Called from vds {1}", vm_guid, _vds.getName()); ResourceManager.getInstance().RerunFailedCommand(vm_guid, _vds.getId()); } for (Guid vm_guid : _succededToRunVms) { _vdsManager.succededToRunVm(vm_guid); } getVdsEventListener().updateSlaPolicies(_succededToRunVms, _vds.getId()); _autoVmsToRun.removeAll(_vmsToRerun); getVdsEventListener().runFailedAutoStartVMs(_autoVmsToRun); for (Entry<VM, VmDynamic> pair : _vmsClientIpChanged.entrySet()) { getVdsEventListener().processOnClientIpChange(_vds, pair.getValue().getId()); } for (VmDynamic runningVm : _poweringUpVms) { getVdsEventListener().processOnVmPoweringUp(runningVm.getId()); } getVdsEventListener().processOnVmStop(_vmsMovedToDown); for (Guid vm_guid : _vmsToRemoveFromAsync) { ResourceManager.getInstance().RemoveAsyncRunningVm(vm_guid); } }
Source:
<code>public Entry<Key,Value> next() { try { Entry<Key,Value> result = new KeyValue(new Key(inner.getTopKey()), new Value(inner.getTopValue()).get()); inner.next(); return result; } catch (IOException ex) { <START> throw new UncheckedIOException(ex); <END> } }</code><technical_language>NSEE a more sense here, matches Iterator interface's behavior calling next more elements</technical_language>

Target:
public Entry<Key,Value> next() { try { Entry<Key,Value> result = new KeyValue(new Key(inner.getTopKey()), new Value(inner.getTopValue()).get()); inner.next(); return result; } catch (IOException ex) { throw new NoSuchElementException(); } }
Source:
<code>private OrganizationalUnit createDefaultOrganizationalUnit() { if (!authorizationManager.authorize(OrganizationalUnit.RESOURCE_TYPE, OrganizationalUnitAction.CREATE, sessionInfo.getIdentity())) { return null; } final LibraryPreferences preferences = getPreferences(); final List<String> contributors = new ArrayList<>(); contributors.add(preferences.getOrganizationalUnitPreferences().getOwner()); return ouService.createOrganizationalUnit(preferences.getOrganizationalUnitPreferences().getName(), preferences.getOrganizationalUnitPreferences().getOwner(), preferences.getOrganizationalUnitPreferences().getGroupId(), <START> new ArrayList<>(), <END> contributors); }</code><technical_language>If this list parameter is read-only sense Collections.emptyList() save a byte :)</technical_language>

Target:
private OrganizationalUnit createDefaultOrganizationalUnit() { if (!authorizationManager.authorize(OrganizationalUnit.RESOURCE_TYPE, OrganizationalUnitAction.CREATE, sessionInfo.getIdentity())) { return null; } final LibraryPreferences preferences = getPreferences(); final List<String> contributors = new ArrayList<>(); contributors.add(preferences.getOrganizationalUnitPreferences().getOwner()); return ouService.createOrganizationalUnit(preferences.getOrganizationalUnitPreferences().getName(), preferences.getOrganizationalUnitPreferences().getOwner(), preferences.getOrganizationalUnitPreferences().getGroupId(), Collections.emptyList(), contributors); }
Source:
<code>void setDiceRollForBombing(final List<Die> dice, final int cost) { removeAll(); add(new JLabel("Cost: " + cost, SwingConstants.LEFT)); add(create(dice)); <START> addBottomLabel(new JLabel()); <END> }</code><technical_language>objection bottom label returned function? is, method addBottomLabel relies side effects. understand is happening, dive method, lacks abstraction. some inconsistency other methods add returned values compared this adds a component a side-effect</technical_language>

Target:
void setDiceRollForBombing(final List<Die> dice, final int cost) { removeAll(); add(new JLabel("Cost: " + cost, SwingConstants.LEFT)); add(create(dice)); addBottomSpacing(); }
Source:
<code>public static IServer findServerForService(String serviceName) { final IServerType serverType = getServerType(); final Optional<IServer> match = Stream.of(ServerCore.getServers()) .filter(server -> server.getServerType() .equals(serverType) && server.getAttribute(OpenShiftServerUtils.ATTR_SERVICE, "").equals(serviceName)) <START> .findAny(); <END> if (match.isPresent()) { return match.get(); } else { return null; } }</code><technical_language>write .findFirst().orElse(null) retrieve avoid if/else block below</technical_language>

Target:
public static IServer findServerForService(String serviceName) { final IServerType serverType = getServerType(); return Stream.of(ServerCore.getServers()) .filter(server -> server.getServerType() .equals(serverType) && server.getAttribute(OpenShiftServerUtils.ATTR_SERVICE, "").equals(serviceName)) .findFirst().orElse(null); }
Source:
<code>protected void run() throws Failure { IoAcceptor acceptor = daemon.getIoAcceptor(); if (acceptor == null) { throw new Failure(1, "fatal: sshd no longer running"); } if (acceptor instanceof MinaAcceptor) { stdout.print("mina\n"); } else if (acceptor instanceof Nio2Acceptor) { stdout.print("nio2\n"); } else { <START> throw new Failure(1, "fatal: unknown ssh backend"); <END> } }</code><technical_language>this need fatal</technical_language>

Target:
protected void run() throws Failure { IoAcceptor acceptor = daemon.getIoAcceptor(); if (acceptor == null) { throw new Failure(1, "fatal: sshd no longer running"); } if (acceptor instanceof MinaAcceptor) { stdout.print("mina\n"); } else if (acceptor instanceof Nio2Acceptor) { stdout.print("nio2\n"); } else { stdout.print("unknown ssh backend\n"); } }
Source:
<code>public BigDecimal convertPressure(BigDecimal value) { if (this == DEFAULT_PRESSURE_UNIT) { return value; } else if (this == INHG) { <START> return value.multiply(new BigDecimal(0.02952998751)); <END> } else { return value.multiply(new BigDecimal(0.750061683)); } }</code><technical_language>If BigDecimal multiplier values static final class variables, "new" conversion, more efficient</technical_language>

Target:
public BigDecimal convertPressure(BigDecimal value) { if (this == DEFAULT_PRESSURE_UNIT) { return value; } else if (this == INHG) { return value.multiply(MBAR_TO_INHG); } else { return value.multiply(MBAR_TO_MMHG); } }
Source:
<code>public Fragment getItem(int position) { switch (position) { case 0: <START> return new RepositoryReadmeFragment(); <END> case 1: return new RepositoryNewsFragment(); case 2: codeFragment = new RepositoryCodeFragment(); return codeFragment; case 3: commitsFragment = new CommitListFragment(); return commitsFragment; case 4: return new IssuesFragment(); default: return null; } }</code><technical_language>if is README</technical_language>

Target:
public Fragment getItem(int position) { position = hasReadme ? position : position + 1; switch (position) { case 0: return new RepositoryReadmeFragment(); case 1: return new RepositoryNewsFragment(); case 2: codeFragment = new RepositoryCodeFragment(); return codeFragment; case 3: commitsFragment = new CommitListFragment(); return commitsFragment; case 4: return new IssuesFragment(); default: return null; } }
Source:
<code>public boolean isRelevant() { <START> if (!jenkins.hasPermission(Jenkins.RUN_SCRIPTS))) { <END> return false; } if (rule.getMasterKillSwitch()) { return true; } return jenkins.isUseSecurity() && (jenkins.getComputers().length>1 || !jenkins.clouds.isEmpty() || Relevance.fromExtension() ) ; }</code><technical_language>bug: uncompilable extra )</technical_language>

Target:
public boolean isRelevant() { return jenkins.hasPermission(Jenkins.RUN_SCRIPTS) && jenkins.isUseSecurity(); }
Source:
<code>public void smokes() throws Exception { AtomicReference<Proc> proc = new AtomicReference<>(); try { JNLPLauncher launcher = new JNLPLauncher(true); launcher.setWebSocket(true); DumbSlave s = new DumbSlave("remote", tmp.newFolder("agent").getAbsolutePath(), launcher); r.jenkins.addNode(s); String secret = ((SlaveComputer) s.toComputer()).getJnlpMac(); File slaveJar = tmp.newFile(); FileUtils.copyURLToFile(new Slave.JnlpJar("slave.jar").getURL(), slaveJar); proc.set(r.createLocalLauncher().launch().cmds( JavaEnvUtils.getJreExecutable("java"), "-jar", slaveJar.getAbsolutePath(), "-jnlpUrl", r.getURL() + "computer/remote/slave-agent.jnlp", "-secret", secret ).stdout(System.out).start()); r.waitOnline(s); assertEquals("response", s.getChannel().call(new DummyTask())); assertNotNull(s.getChannel().call(new FatTask())); FreeStyleProject p = r.createFreeStyleProject(); p.setAssignedNode(s); <START> p.getBuildersList().add(Functions.isWindows() ? new BatchFile("echo hello") : new Shell("dd if=/dev/random count=1024 bs=200")); <END> r.buildAndAssertSuccess(p); s.toComputer().getLogText().writeLogTo(0, System.out); } finally { if (proc.get() != null) { proc.get().kill(); while (r.jenkins.getComputer("remote").isOnline()) { LOGGER.info("waiting for computer to go offline"); Thread.sleep(250); } } } }</code><technical_language>include of #4635, specifically: <LINK_0></technical_language>

Target:
public void smokes() throws Exception { AtomicReference<Proc> proc = new AtomicReference<>(); try { JNLPLauncher launcher = new JNLPLauncher(true); launcher.setWebSocket(true); DumbSlave s = new DumbSlave("remote", tmp.newFolder("agent").getAbsolutePath(), launcher); r.jenkins.addNode(s); String secret = ((SlaveComputer) s.toComputer()).getJnlpMac(); File slaveJar = tmp.newFile(); FileUtils.copyURLToFile(new Slave.JnlpJar("slave.jar").getURL(), slaveJar); proc.set(r.createLocalLauncher().launch().cmds( JavaEnvUtils.getJreExecutable("java"), "-jar", slaveJar.getAbsolutePath(), "-jnlpUrl", r.getURL() + "computer/remote/slave-agent.jnlp", "-secret", secret ).stdout(System.out).start()); r.waitOnline(s); assertEquals("response", s.getChannel().call(new DummyTask())); assertNotNull(s.getChannel().call(new FatTask())); FreeStyleProject p = r.createFreeStyleProject(); p.setAssignedNode(s); p.getBuildersList().add(Functions.isWindows() ? new BatchFile("echo hello") : new Shell("echo hello")); r.buildAndAssertSuccess(p); s.toComputer().getLogText().writeLogTo(0, System.out); } finally { if (proc.get() != null) { proc.get().kill(); while (r.jenkins.getComputer("remote").isOnline()) { LOGGER.info("waiting for computer to go offline"); Thread.sleep(250); } } } }
Source:
<code>public void testElapsedTimeAndSessionOverlapping() throws InterruptedException, SipException, ParseException, InvalidArgumentException { deployApplication(ConcurrencyControlMode.SipSession); String fromName = "sender"; String fromSipAddress = "sip-servlets.com"; SipURI fromAddress = senderProtocolObjects.addressFactory.createSipURI( fromName, fromSipAddress); <START> String toUser = "receiverWithTag"; <END> String toSipAddress = "sip-servlets.com"; SipURI toAddress = senderProtocolObjects.addressFactory.createSipURI( toUser, toSipAddress); sender.setSendBye(false); sender.sendSipRequest("INVITE", fromAddress, toAddress, null, null, false); Thread.sleep(2000); sender.sendInDialogSipRequest("INFO", "1", "text", "plain", null, null); Thread.sleep(100); sender.sendInDialogSipRequest("INFO", "2", "text", "plain", null, null); Thread.sleep(100); sender.sendInDialogSipRequest("INFO", "3", "text", "plain", null, null); Thread.sleep(100); sender.sendBye(); Thread.sleep(20000); assertTrue(!sender.isServerErrorReceived()); assertTrue(sender.isAckSent()); assertTrue(sender.getOkToByeReceived()); }</code><technical_language>do neeed modify this existing test</technical_language>

Target:
public void testElapsedTimeAndSessionOverlapping() throws InterruptedException, SipException, ParseException, InvalidArgumentException { deployApplication(ConcurrencyControlMode.SipSession); String fromName = "sender"; String fromSipAddress = "sip-servlets.com"; SipURI fromAddress = senderProtocolObjects.addressFactory.createSipURI( fromName, fromSipAddress); String toUser = "receiver"; String toSipAddress = "sip-servlets.com"; SipURI toAddress = senderProtocolObjects.addressFactory.createSipURI( toUser, toSipAddress); sender.setSendBye(false); sender.sendSipRequest("INVITE", fromAddress, toAddress, null, null, false); Thread.sleep(2000); sender.sendInDialogSipRequest("INFO", "1", "text", "plain", null, null); Thread.sleep(100); sender.sendInDialogSipRequest("INFO", "2", "text", "plain", null, null); Thread.sleep(100); sender.sendInDialogSipRequest("INFO", "3", "text", "plain", null, null); Thread.sleep(100); sender.sendBye(); Thread.sleep(20000); assertTrue(!sender.isServerErrorReceived()); assertTrue(sender.isAckSent()); assertTrue(sender.getOkToByeReceived()); }
Source:
<code>private boolean isMethodFiltered(final String className, final String superClassName, final int access, final String name, final String desc) { if ("java/lang/Enum".equals(superClassName)) { <START> if ("values".equals(name) <END> && desc.equals("()[L" + className + ";")) { return true; } if ("valueOf".equals(name) && desc.equals("(Ljava/lang/String;)L" + className + ";")) { return true; } } return (access & Opcodes.ACC_SYNTHETIC) != 0 && !name.startsWith("lambda$"); }</code><technical_language>mix comparisons styles here: "expected".equals(actual) vs. actual.equals("expected"). I prefer is NPE safe</technical_language>

Target:
private boolean isMethodFiltered(final String className, final String superClassName, final int access, final String name, final String desc) { if ("java/lang/Enum".equals(superClassName)) { if ("values".equals(name) && ("()[L" + className + ";").equals(desc)) { return true; } if ("valueOf".equals(name) && ("(Ljava/lang/String;)L" + className + ";") .equals(desc)) { return true; } } return (access & Opcodes.ACC_SYNTHETIC) != 0 && !name.startsWith("lambda$"); }
Source:
<code>static boolean isSystemLevelClass(ASTUserClass node) { List<TypeRef> interfaces = node.getNode().getDefiningType().getCodeUnitDetails().getInterfaceTypeRefs(); boolean hasWhitelistedInterfaces = false; for (TypeRef intObject : interfaces) { if (isWhitelisted(intObject.getNames())) { <START> hasWhitelistedInterfaces = true; <END> break; } } return hasWhitelistedInterfaces; }</code><technical_language>return true cleaner... I missing point of rule</technical_language>

Target:
static boolean isSystemLevelClass(ASTUserClass node) { List<TypeRef> interfaces = node.getNode().getDefiningType().getCodeUnitDetails().getInterfaceTypeRefs(); for (TypeRef intObject : interfaces) { if (isWhitelisted(intObject.getNames())) { return true; } } return false; }
Source:
<code>private void assertNicAvailable(Nic nic) { assertPredicate(new Predicate<String>() { @Override public boolean apply(String args) { String[] params = args.split(","); Nic nic = nicApi().getNic(params[0], params[1], params[2]); if (nic == null || nic.metadata() == null) return false; return nic.metadata().state() == State.AVAILABLE; } <START> }, complexId(nic.dataCenterId(), testServer.id(), nic.id())); <END> }</code><technical_language>assembling this a String split immediately? passing Nic object predicate</technical_language>

Target:
private void assertNicAvailable(Nic nic) { assertPredicate(new Predicate<Nic>() { @Override public boolean apply(Nic testNic) { Nic nic = nicApi().get(testNic.dataCenterId(), testNic.serverId(), testNic.id()); if (nic == null || nic.metadata() == null) return false; return nic.metadata().state() == State.AVAILABLE; } }, nic); }
Source:
<code>private static void executePost(HttpUrl url, byte[] data) throws IOException { RequestBody requestBody = data == null ? RequestBody.create(MediaType.parse("text/plain"), "") : RequestBody.create(MediaType.parse("application/octet-stream"), data); ; Request request = new Request.Builder() .url(url) .post(requestBody) .build(); <START> Response response = httpClient.newCall(request).execute(); <END> if (!response.isSuccessful()) { String responseBody = response.body() != null ? response.body().string() : ""; throw new SolrClientUtilsException(response.code(), "Unable to upload binary\n" + responseBody); } }</code><technical_language>Response need closed avoid a resource leak. Try-with-resources block, perhaps</technical_language>

Target:
private static void executePost(HttpUrl url, byte[] data) throws IOException { RequestBody requestBody = data == null ? RequestBody.create(MediaType.parse("text/plain"), "") : RequestBody.create(MediaType.parse("application/octet-stream"), data); ; Request request = new Request.Builder() .url(url) .post(requestBody) .build(); Response response = httpClient.newCall(request).execute(); if (!response.isSuccessful()) { String responseBody = ""; if (response.body() != null) { responseBody = response.body().string(); response.close(); } throw new SolrClientUtilsException(response.code(), "Unable to upload binary\n" + responseBody); } if (response.body() != null) { response.close(); } }
Source:
<code>public DefaultStatisticsServiceConfiguration withLatencyHistorySize(int size) { if (size <= 0) { throw new IllegalArgumentException("Latency history size must be a positive integer."); } this.latencyHistorySize = size; <START> return this; <END> }</code><technical_language>some point, a requireTrue(boolean predicate, Supplier<String> errorMessage) in some util class</technical_language>

Target:
public DefaultStatisticsServiceConfiguration withLatencyHistorySize(int size) { if (size <= 0) { throw new IllegalArgumentException("Latency history size must be a positive integer"); } this.latencyHistorySize = size; return this; }
Source:
<code>public void testExceptionConfirmPattern() { DispatchCallback callback = new DispatchCallback(); SqlLine line = new SqlLine(); assertEquals(Boolean.FALSE, line.getOpts().getConfirm()); thrown.expect(IllegalArgumentException.class); thrown.expectMessage(containsString("invalid regex")); line.runCommands( Collections.singletonList("!set confirmPattern " <START> + "\"^(?i*:(TRUNCATE|ALTER))\""), callback); <END> thrown.expect(IllegalArgumentException.class); thrown.expectMessage(containsString("null")); line.runCommands( Collections.singletonList("!set confirmPattern "), callback); }</code><technical_language>please custom output stream here, e.g. sqlline.SqlLineArgsTest#testSetWrongColorScheme output clearer in case of success tests</technical_language>

Target:
public void testExceptionConfirmPattern() { try { SqlLine line = new SqlLine(); ByteArrayOutputStream os = new ByteArrayOutputStream(); assertEquals(Boolean.FALSE, line.getOpts().getConfirm()); SqlLine.Status status = begin(line, os, false, "-e", "!set confirmPattern \"^(?i*:(TRUNCATE|ALTER))\""); assertThat(status, equalTo(SqlLine.Status.OK)); assertThat(os.toString("UTF8"), containsString("invalid regex")); os.reset(); } catch (Throwable e) { throw new RuntimeException(e); } }