auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
public boolean run() { final List<DataSegment> segments = IndexGeneratorJob.getPublishedSegments(config); for (final DataSegment segment : segments) { dbi.withHandle( new HandleCallback<Void>() { @Override public Void withHandle(Handle handle) throws Exception { handle.createStatement( String.format( "INSERT INTO %s (id, dataSource, created_date, start, end, partitioned, version, used, payload) " + "VALUES (:id, :dataSource, :created_date, :start, :end, :partitioned, :version, :used, :payload)", spec.getSegmentTable() ) ) .bind("id", segment.getIdentifier()) .bind("dataSource", segment.getDataSource()) .bind("created_date", new DateTime().toString()) .bind("start", segment.getInterval().getStart().toString()) .bind("end", segment.getInterval().getEnd().toString()) .bind("partitioned", segment.getShardSpec().getPartitionNum()) .bind("version", segment.getVersion()) .bind("used", true) .bind("payload", jsonMapper.writeValueAsString(segment)) .execute(); return null; } } ); log.info("Published %s", segment.getIdentifier()); } return true; }

Target:
public boolean run() { final List<DataSegment> segments = IndexGeneratorJob.getPublishedSegments(config); dbi.withHandle( new HandleCallback<Void>() { @Override public Void withHandle(Handle handle) throws Exception { final PreparedBatch batch = handle.prepareBatch( String.format( "INSERT INTO %s (id, dataSource, created_date, start, end, partitioned, version, used, payload) " + "VALUES (:id, :dataSource, :created_date, :start, :end, :partitioned, :version, :used, :payload)", spec.getSegmentTable() ) ); for (final DataSegment segment : segments) { batch.add( new ImmutableMap.Builder() .put("id", segment.getIdentifier()) .put("dataSource", segment.getDataSource()) .put("created_date", new DateTime().toString()) .put("start", segment.getInterval().getStart().toString()) .put("end", segment.getInterval().getEnd().toString()) .put("partitioned", segment.getShardSpec().getPartitionNum()) .put("version", segment.getVersion()) .put("used", true) .put("payload", jsonMapper.writeValueAsString(segment)) .build() ); log.info("Published %s", segment.getIdentifier()); } batch.execute(); return null; } } ); return true; }
Source:
public void testClearBranchTokenTypes() throws Exception { final DetailAST parent = new DetailAST(); final DetailAST child = new DetailAST(); parent.setFirstChild(child); final List<Consumer<DetailAST>> clearBranchTokenTypesMethods = Arrays.asList( ast -> child.setFirstChild(ast), ast -> child.setNextSibling(ast), ast -> child.addPreviousSibling(ast), ast -> child.addNextSibling(ast), ast -> child.addChild(ast), ast -> { try { Whitebox.invokeMethod(child, "setParent", ast); } catch (Exception exception) { throw new IllegalStateException(exception); } } ); for (Consumer<DetailAST> method : clearBranchTokenTypesMethods) { final BitSet branchTokenTypes = Whitebox.invokeMethod(parent, "getBranchTokenTypes"); method.accept(null); final BitSet branchTokenTypes2 = Whitebox.invokeMethod(parent, "getBranchTokenTypes"); assertNotSame(branchTokenTypes, branchTokenTypes2); } }

Target:
public void testClearBranchTokenTypes() throws Exception { final DetailAST parent = new DetailAST(); final DetailAST child = new DetailAST(); parent.setFirstChild(child); final List<Consumer<DetailAST>> clearBranchTokenTypesMethods = Arrays.asList( ast -> child.setFirstChild(ast), ast -> child.setNextSibling(ast), ast -> child.addPreviousSibling(ast), ast -> child.addNextSibling(ast), ast -> child.addChild(ast), ast -> { try { Whitebox.invokeMethod(child, "setParent", ast); } catch (Exception exception) { throw new IllegalStateException(exception); } } ); for (Consumer<DetailAST> method : clearBranchTokenTypesMethods) { final BitSet branchTokenTypes = Whitebox.invokeMethod(parent, "getBranchTokenTypes"); method.accept(null); final BitSet branchTokenTypes2 = Whitebox.invokeMethod(parent, "getBranchTokenTypes"); assertEquals(branchTokenTypes, branchTokenTypes2); assertNotSame(branchTokenTypes, branchTokenTypes2); } }
Source:
public void testExecuteSolver() throws Exception { SolverInstance instance = new SolverInstance(); instance.setSolverConfigFile( SOLVER_1_CONFIG ); assertSuccess( client.createContainer( CONTAINER_1_ID, new KieContainerResource( CONTAINER_1_ID, kjar1 ) ) ); ServiceResponse<SolverInstance> response = solverClient.createSolver( CONTAINER_1_ID, SOLVER_1_ID, instance ); assertSuccess( response ); assertEquals( SolverInstance.SolverStatus.NOT_SOLVING, response.getResult().getStatus() ); instance.setStatus( SolverInstance.SolverStatus.SOLVING ); instance.setPlanningProblem( loadPlanningProblem( 5, 10 ) ); response = solverClient.updateSolverState( CONTAINER_1_ID, SOLVER_1_ID, instance ); assertSuccess( response ); for( int i = 0; i < 5 && response.getResult().getStatus() == SolverInstance.SolverStatus.SOLVING; i++ ) { Thread.currentThread().sleep( 3000 ); response = solverClient.getSolverState( CONTAINER_1_ID, SOLVER_1_ID ); assertSuccess( response ); } assertEquals( SolverInstance.SolverStatus.NOT_SOLVING, response.getResult().getStatus() ); assertSuccess( solverClient.disposeSolver( CONTAINER_1_ID, SOLVER_1_ID ) ); }

Target:
public void testExecuteSolver() throws Exception { SolverInstance instance = new SolverInstance(); instance.setSolverConfigFile( SOLVER_1_CONFIG ); assertSuccess( client.createContainer( CONTAINER_1_ID, new KieContainerResource( CONTAINER_1_ID, kjar1 ) ) ); ServiceResponse<SolverInstance> response = solverClient.createSolver( CONTAINER_1_ID, SOLVER_1_ID, instance ); assertSuccess( response ); assertEquals( SolverInstance.SolverStatus.NOT_SOLVING, response.getResult().getStatus() ); instance.setStatus( SolverInstance.SolverStatus.SOLVING ); instance.setPlanningProblem( loadPlanningProblem( 5, 10 ) ); response = solverClient.updateSolverState( CONTAINER_1_ID, SOLVER_1_ID, instance ); assertSuccess( response ); for( int i = 0; i < 5 && response.getResult().getStatus() == SolverInstance.SolverStatus.SOLVING; i++ ) { Thread.sleep( 3000 ); response = solverClient.getSolverState( CONTAINER_1_ID, SOLVER_1_ID ); assertSuccess( response ); } assertEquals( SolverInstance.SolverStatus.NOT_SOLVING, response.getResult().getStatus() ); assertSuccess( solverClient.disposeSolver( CONTAINER_1_ID, SOLVER_1_ID ) ); }
Source:
public String getOS() { FormField field = getField("os"); if (field == null) { return null; } return field.getValuesAsString().get(0); }

Target:
public String getOS() { return readFirstValue(OS); }
Source:
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { CloudbreakUser cbUser = authenticatedUserService.getCbUser(); Long workspaceId = UNINITIALIZED_WORKSPACE_ID; if (cbUser != null) { ClusterPertain cbSyncedUser = clusterPertainService.getOrCreateUser(cbUser.getUserId(), cbUser.getUserCrn(), cbUser.getTenant()); workspaceId = cbSyncedUser.getWorkspaceId(); } restRequestThreadLocalService.setCloudbreakUser(cbUser, workspaceId); filterChain.doFilter(request, response); restRequestThreadLocalService.removeCloudbreakUser(); }

Target:
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { CloudbreakUser cloudbreakUser = authenticatedUserService.getCbUser(); restRequestThreadLocalService.setCloudbreakUser(cloudbreakUser); filterChain.doFilter(request, response); restRequestThreadLocalService.removeCloudbreakUser(); }
Source:
protected File findManagedResourcesFolder( Bundle blueprintBundle ) { File root = blueprintBundle.getDataFile( "" ); while ( root != null && !root.getAbsolutePath().endsWith( ROOT_SYSTEM_DIR ) ) { root = root.getParentFile(); } return new File( root.getAbsolutePath() + MANAGED_RESOURCES_DIR ); }

Target:
protected File findManagedResourcesFolder( Bundle blueprintBundle ) { File root = blueprintBundle.getDataFile( "" ); while ( root != null && !root.getAbsolutePath().endsWith( ROOT_SYSTEM_DIR ) ) { root = root.getParentFile(); } return Paths.get( root.getAbsolutePath(), MANAGED_RESOURCES_DIR ).toFile(); }
Source:
public Mail(Email from, String subject, Email to, Content content) { this.setFrom(from); this.setSubject(subject); Personalization personalization = new Personalization(); personalization.addTo(to); this.addPersonalization(personalization); this.addPersonalization(content); }

Target:
public Mail(Email from, String subject, Email to, Content content) { this.setFrom(from); this.setSubject(subject); Personalization personalization = new Personalization(); personalization.addTo(to); this.addPersonalization(personalization); this.addContent(content); }
Source:
protected void onCloseStream() { super.onCloseStream(); if (LAT_LON.size() > 0 && latLonChanged) { ObjectOutputStream oos = null; try { oos = new ObjectOutputStream(new FileOutputStream(LAT_LON_FILENAME)); oos.writeObject(LAT_LON); } catch (IOException e) { LOG.error(e.getMessage(), e); } finally { IOUtils.closeQuietly(oos); } } }

Target:
protected void onCloseStream() { super.onCloseStream(); if (LAT_LON.size() > 0 && latLonChanged) { ObjectOutputStream oos = null; try { oos = new ObjectOutputStream(new FileOutputStream(LAT_LON_FILENAME)); oos.writeObject(LAT_LON); } catch (IOException e) { LOG.error(e.getMessage(), e); } finally { Closeables.closeQuietly(oos); } } }
Source:
public void testCreateFail() { PluginDescriptor pluginDescriptor = mock(DefaultPluginDescriptor.class); when(pluginDescriptor.getPluginClass()).thenReturn(FailTestPlugin.class.getName()); PluginWrapper pluginWrapper = mock(PluginWrapper.class); when(pluginWrapper.getDescriptor()).thenReturn(pluginDescriptor); when(pluginWrapper.getPluginClassLoader()).thenReturn(getClass().getClassLoader()); DefaultPluginFactory instance = new DefaultPluginFactory(); Plugin result = instance.create(pluginWrapper); assertNull(result); }

Target:
public void testCreateFail() { PluginDescriptor pluginDescriptor = mock(PluginDescriptor.class); when(pluginDescriptor.getPluginClass()).thenReturn(FailTestPlugin.class.getName()); PluginWrapper pluginWrapper = mock(PluginWrapper.class); when(pluginWrapper.getDescriptor()).thenReturn(pluginDescriptor); when(pluginWrapper.getPluginClassLoader()).thenReturn(getClass().getClassLoader()); DefaultPluginFactory instance = new DefaultPluginFactory(); Plugin result = instance.create(pluginWrapper); assertNull(result); }
Source:
public void testVisibilityForCreatorInPublisher() throws Exception { apiIdentifier = new APIIdentifier(providerName, API_NAME, API_VERSION_1_0_0); APICreationRequestBean apiCreationRequestBean = new APICreationRequestBean(API_NAME, API_CONTEXT, API_VERSION_1_0_0, providerName, new URL(apiEndPointUrl)); apiCreationRequestBean.setTags(API_TAGS); apiCreationRequestBean.setDescription(API_DESCRIPTION); apiCreationRequestBean.setVisibility(APIDTO.VisibilityEnum.PUBLIC.getValue()); APIDTO apidto = apiPublisherClientUser2.addAPI(apiCreationRequestBean); apiID = apidto.getId(); publishAPI(apiID, apiPublisherClientUser2, false); int retry = 0; while (retry < 15) { List<APIIdentifier> apiStoreAPIIdentifierList = APIMTestCaseUtils.getAPIIdentifierListFromHttpResponse(apiStoreClientUser2.getAllAPIs()); if (APIMTestCaseUtils.isAPIAvailable(apiIdentifier, apiStoreAPIIdentifierList)) { log.info("API '" + API_NAME + "' is available on store."); break; } log.info("Waiting for API '" + API_NAME + "' is available on store."); Thread.sleep(3000); retry++; } List<APIIdentifier> apiPublisherAPIIdentifierList = APIMTestCaseUtils.getAPIIdentifierListFromHttpResponse(apiPublisherClientUser2.getAllAPIs()); assertTrue(APIMTestCaseUtils.isAPIAvailable(this.apiIdentifier, apiPublisherAPIIdentifierList), "API is not visible to creator in APi Publisher. When Visibility is public. " + getAPIIdentifierString( this.apiIdentifier)); }

Target:
public void testVisibilityForCreatorInPublisher() throws Exception { apiIdentifier = new APIIdentifier(providerName, API_NAME, API_VERSION_1_0_0); APICreationRequestBean apiCreationRequestBean = new APICreationRequestBean(API_NAME, API_CONTEXT, API_VERSION_1_0_0, providerName, new URL(apiEndPointUrl)); apiCreationRequestBean.setTags(API_TAGS); apiCreationRequestBean.setDescription(API_DESCRIPTION); apiCreationRequestBean.setVisibility(APIDTO.VisibilityEnum.PUBLIC.getValue()); APIDTO apidto = apiPublisherClientUser2.addAPI(apiCreationRequestBean); apiID = apidto.getId(); publishAPI(apiID, apiPublisherClientUser2, false); int retry = 0; while (retry < 15) { List<APIIdentifier> apiStoreAPIIdentifierList = APIMTestCaseUtils.getAPIIdentifierListFromHttpResponse(apiStoreClientUser2.getAllAPIs()); if (APIMTestCaseUtils.isAPIAvailable(apiIdentifier, apiStoreAPIIdentifierList)) { log.info("API '" + API_NAME + "' is available on store."); break; } log.info("Waiting for API '" + API_NAME + "' is available on store."); Thread.sleep(1000); retry++; } List<APIIdentifier> apiPublisherAPIIdentifierList = APIMTestCaseUtils.getAPIIdentifierListFromHttpResponse(apiPublisherClientUser2.getAllAPIs()); assertTrue(APIMTestCaseUtils.isAPIAvailable(this.apiIdentifier, apiPublisherAPIIdentifierList), "API is not visible to creator in APi Publisher. When Visibility is public. " + getAPIIdentifierString( this.apiIdentifier)); }
Source:
public Supplier<ManagedTimestampService> createTimestampService(String client, LeaderConfig unused) { PaxosAcceptor ourAcceptor = paxosResource.getPaxosAcceptor(client); Map<PaxosAcceptor, ExecutorService> acceptors = ImmutableMap.<PaxosAcceptor, ExecutorService>builder() .put(ourAcceptor, executorService) .putAll(paxosAcceptorsForClient.apply(client)) .build(); PaxosLearner ourLearner = paxosResource.getPaxosLearner(client); Map<PaxosLearner, ExecutorService> learners = ImmutableMap.<PaxosLearner, ExecutorService>builder() .put(ourLearner, executorService) .putAll(paxosLearnersForClient.apply(client)) .build(); PaxosProposer proposer = instrument(PaxosProposer.class, PaxosProposerImpl.newProposer( ourLearner, acceptors, learners, PaxosRemotingUtils.getQuorumSize(acceptors.keySet()), uuid), client); return () -> createManagedPaxosTimestampService(proposer, client, acceptors, learners); }

Target:
public Supplier<ManagedTimestampService> createTimestampService(String client, LeaderConfig unused) { PaxosAcceptor ourAcceptor = paxosResource.getPaxosAcceptor(client); List<PaxosAcceptor> acceptors = Stream.concat( paxosAcceptorsForClient.apply(client).stream(), Stream.of(ourAcceptor)) .collect(Collectors.toList()); PaxosLearner ourLearner = paxosResource.getPaxosLearner(client); List<PaxosLearner> learners = Stream.concat( paxosLearnersForClient.apply(client).stream(), Stream.of(ourLearner)) .collect(Collectors.toList()); PaxosProposer proposer = instrument(PaxosProposer.class, PaxosProposerImpl.newProposer( ourLearner, acceptors, learners, PaxosRemotingUtils.getQuorumSize(acceptors), UUID.randomUUID(), executor), client); return () -> createManagedPaxosTimestampService(proposer, client, acceptors, learners); }
Source:
public static io.sphere.sdk.shoppinglists.commands.updateactions.ChangeName of(final LocalizedString name) { return new io.sphere.sdk.shoppinglists.commands.updateactions.ChangeName(name); }

Target:
public static ChangeName of(final LocalizedString name) { return new ChangeName(name); }
Source:
public static String generateValueFileName(String fileNameBase, int fileNum) { return StringUtils.safeFormat("%s_value_%d", fileNameBase, fileNum); }

Target:
public static String generateValueFileName(String fileNameBase, int fileNum) { return StringUtils.format("%s_value_%d", fileNameBase, fileNum); }
Source:
protected boolean isSubtypeWithElements( AnnotationMirror subAnno, QualifierKind subKind, AnnotationMirror superAnno, QualifierKind superKind) { if (REGEX_KIND == subKind && REGEX_KIND == superKind) { int rhsValue = getRegexValue(subAnno); int lhsValue = getRegexValue(superAnno); return lhsValue <= rhsValue; } else if (PARTIALREGEX_KIND == subKind && PARTIALREGEX_KIND == superKind) { return AnnotationUtils.areSame(subAnno, superAnno); } throw new BugInCF("Unexpected qualifiers: %s %s", subAnno, superAnno); }

Target:
protected boolean isSubtypeWithElements( AnnotationMirror subAnno, QualifierKind subKind, AnnotationMirror superAnno, QualifierKind superKind) { if (subKind == REGEX_KIND && superKind == REGEX_KIND) { int rhsValue = getRegexValue(subAnno); int lhsValue = getRegexValue(superAnno); return lhsValue <= rhsValue; } else if (subKind == PARTIALREGEX_KIND && superKind == PARTIALREGEX_KIND) { return AnnotationUtils.areSame(subAnno, superAnno); } throw new BugInCF("Unexpected qualifiers: %s %s", subAnno, superAnno); }
Source:
public void closeBodyEvenWhenExceptionHappens() throws IOException { final IOException exception = new IOException("Smth went wrong"); final FailOutputStream output = new FailOutputStream(exception); final FakeInput input = new FakeInput(new InputStreamOf("abc")); try { new RsPrint(new RsText(input)) .printBody(output); } catch (final IOException ex) { if (!ex.equals(exception)) { throw ex; } } MatcherAssert.assertThat( input.haveClosed(), new IsEqual<>(true) ); }

Target:
public void closeBodyEvenWhenExceptionHappens() throws IOException { final IOException exception = new IOException("Smth went wrong"); final FailOutputStream output = new FailOutputStream(exception); final FakeInput input = new FakeInput(new InputStreamOf("abc")); try { new RsPrint(new RsText(input)) .printBody(output); } catch (final IOException ex) { if (!ex.equals(exception)) { throw ex; } } MatcherAssert.assertThat( "Input body was not closed", input.isClosed(), new IsEqual<>(true) ); }
Source:
public static NameMetadataDescription create(List<NameComponentDescription> components, int numberOfComponentsHashed) { if (numberOfComponentsHashed == 0) { return new NameMetadataDescription(components, numberOfComponentsHashed); } else { List<NameComponentDescription> withHashRowComponent = Lists.newArrayListWithCapacity(components.size() + 1); withHashRowComponent.add(new NameComponentDescription.Builder() .componentName(HASH_ROW_COMPONENT_NAME) .type(ValueType.FIXED_LONG) .build()); withHashRowComponent.addAll(components); return new NameMetadataDescription(withHashRowComponent, numberOfComponentsHashed); } }

Target:
public static NameMetadataDescription create(List<NameComponentDescription> components, int numberOfComponentsHashed) { Preconditions.checkArgument(numberOfComponentsHashed <= components.size(), "Number of hashed components can't exceed total number of row components."); if (numberOfComponentsHashed == 0) { return new NameMetadataDescription(components, numberOfComponentsHashed); } else { List<NameComponentDescription> withHashRowComponent = Lists.newArrayListWithCapacity(components.size() + 1); withHashRowComponent.add(new NameComponentDescription.Builder() .componentName(HASH_ROW_COMPONENT_NAME) .type(ValueType.FIXED_LONG) .build()); withHashRowComponent.addAll(components); return new NameMetadataDescription(withHashRowComponent, numberOfComponentsHashed); } }
Source:
public void deserializes(@Observes ReadyToExecuteMethod event, HttpServletRequest request, MethodInfo methodInfo, Status status) throws IOException { ControllerMethod method = event.getControllerMethod(); if (!method.containsAnnotation(Consumes.class)) return; List<String> supported = asList(method.getMethod().getAnnotation(Consumes.class).value()); String contentType = mime(request.getContentType()); if (!supported.isEmpty() && !supported.contains(contentType)) { unsupported("Request with media type [%s]. Expecting one of %s.", status, contentType, supported); return; } Deserializer deserializer = deserializers.deserializerFor(contentType, container); if (deserializer == null) { unsupported("Unable to handle media type [%s]: no deserializer found.", status, contentType); return; } Object[] deserialized = deserializer.deserialize(request.getInputStream(), method); ValuedParameter[] parameters = methodInfo.getValuedParameters(); logger.debug("Deserialized parameters for are ", method, deserialized); for (int i = 0; i < deserialized.length; i++) { if (deserialized[i] != null) { parameters[i].setValue(deserialized[i]); } } }

Target:
public void deserializes(@Observes ReadyToExecuteMethod event, HttpServletRequest request, MethodInfo methodInfo, Status status) throws IOException { ControllerMethod method = event.getControllerMethod(); if (!method.containsAnnotation(Consumes.class)) return; List<String> supported = asList(method.getMethod().getAnnotation(Consumes.class).value()); String contentType = mime(request.getContentType()); if (!supported.isEmpty() && !supported.contains(contentType)) { unsupported("Request with media type [%s]. Expecting one of %s.", status, contentType, supported); return; } Deserializer deserializer = deserializers.deserializerFor(contentType, container); if (deserializer == null) { unsupported("Unable to handle media type [%s]: no deserializer found.", status, contentType); return; } Object[] deserialized = deserializer.deserialize(request.getInputStream(), method); logger.debug("Deserialized parameters for are ", method, deserialized); for (int i = 0; i < deserialized.length; i++) { if (deserialized[i] != null) { methodInfo.setParameter(i, deserialized[i]); } } }
Source:
public void testClasspathConfiguration() throws Exception { ClasspathPropertiesConfiguration.initialize(); assertEquals("10", ConfigurationManager.getConfigInstance().getString("standaloneConfigProperty")); assertEquals("11", ConfigurationManager.getConfigInstance().getString("jarConfigProperty")); ClasspathPropertiesConfiguration.setPropertiesResourceRelativePath("non-existent/conf/bluh"); try { ClasspathPropertiesConfiguration.initialize(); } catch (Exception e) { assertEquals("Cannot locate non-existent/conf/bluh as a classpath resource.", e.getCause().getMessage()); } }

Target:
public void testClasspathConfiguration() throws Exception { ClasspathPropertiesConfiguration.initialize(); assertEquals("10", ConfigurationManager.getConfigInstance().getString("standaloneConfigProperty")); assertEquals("11", ConfigurationManager.getConfigInstance().getString("jarConfigProperty")); ClasspathPropertiesConfiguration.setPropertiesResourceRelativePath("non-existent/conf/bluh"); try { ClasspathPropertiesConfiguration.initialize(); fail("exception expected"); } catch (Exception e) { assertEquals("Cannot locate non-existent/conf/bluh as a classpath resource.", e.getCause().getMessage()); } }
Source:
public void multiIndex_incompatibleAnalyzer_overrideAnalyzer() { StubMappingSearchScope scope = indexManager.createSearchScope( incompatibleAnalyzerIndexManager ); String absoluteFieldPath = indexMapping.analyzedStringField1.relativeFieldName; IndexSearchQuery<DocumentReference> query = scope.query().asReference() .predicate( f -> f.simpleQueryString().onField( absoluteFieldPath ).matching( TERM_5 ) .analyzer( OverrideAnalysisDefinitions.ANALYZER_WHITESPACE_LOWERCASE.name ) ) .toQuery(); assertThat( query ).assertThat( query ).hasDocRefHitsAnyOrder( b -> { b.doc( INDEX_NAME, DOCUMENT_1 ); b.doc( INCOMPATIBLE_ANALYZER_INDEX_NAME, INCOMPATIBLE_ANALYZER_INDEX_DOCUMENT_1 ); } ); }

Target:
public void multiIndex_incompatibleAnalyzer_overrideAnalyzer() { StubMappingSearchScope scope = indexManager.createSearchScope( incompatibleAnalyzerIndexManager ); String absoluteFieldPath = indexMapping.analyzedStringField1.relativeFieldName; IndexSearchQuery<DocumentReference> query = scope.query().asReference() .predicate( f -> f.simpleQueryString().onField( absoluteFieldPath ).matching( TERM_5 ) .analyzer( OverrideAnalysisDefinitions.ANALYZER_WHITESPACE_LOWERCASE.name ) ) .toQuery(); assertThat( query ).hasDocRefHitsAnyOrder( b -> { b.doc( INDEX_NAME, DOCUMENT_1 ); b.doc( INCOMPATIBLE_ANALYZER_INDEX_NAME, INCOMPATIBLE_ANALYZER_INDEX_DOCUMENT_1 ); } ); }
Source:
private void handleException(Thread thread, Throwable exception) { if (exception instanceof Error) { LOG.log(Level.SEVERE, "Error caught in thread: " + thread.getName() + " with thread id: " + thread.getId() + ". Process halting..."); Runtime.getRuntime().halt(1); } LOG.log(Level.SEVERE, String.format("Exception caught in thread: %s with id: %d", thread.getName(), thread.getId()), exception); final CountDownLatch exited = new CountDownLatch(1); final ExecutorService exitExecutor = Executors.newSingleThreadExecutor(); exitExecutor.execute(new ForceExitTask(exited, systemConfig.getInstanceForceExitTimeout())); if (thread.getName().equals(ThreadNames.THREAD_SLAVE_NAME)) { new SlaveExitTask().run(); gatewayLooper.exitLoop(); } else { new GatewayExitTask().run(); } exited.countDown(); }

Target:
private void handleException(Thread thread, Throwable exception) { if (exception instanceof Error) { try { LOG.log(Level.SEVERE, "Error caught in thread: " + thread.getName() + " with thread id: " + thread.getId() + ". Process halting...", exception); } finally { Runtime.getRuntime().halt(1); } } LOG.log(Level.SEVERE, String.format("Exception caught in thread: %s with id: %d", thread.getName(), thread.getId()), exception); final CountDownLatch exited = new CountDownLatch(1); final ExecutorService exitExecutor = Executors.newSingleThreadExecutor(); exitExecutor.execute(new ForceExitTask(exited, systemConfig.getInstanceForceExitTimeout())); if (thread.getName().equals(ThreadNames.THREAD_SLAVE_NAME)) { new SlaveExitTask().run(); gatewayLooper.exitLoop(); } else { new GatewayExitTask().run(); } exited.countDown(); }
Source:
public void addVirtioScsiController(VmBase vm, Version version) { boolean hasIoThreads = vm.getNumOfIoThreads() > 0 && FeatureSupported.virtioScsiIoThread(version); int scsiControllers = hasIoThreads ? vm.getNumOfIoThreads() : 1; for (int i = 0; i < scsiControllers; i++) { Map<String, Object> specParams = new HashMap<>(); if (hasIoThreads) { specParams.put(VdsProperties.ioThreadId, i); } VmDevice device = addManagedDevice( new VmDeviceId(Guid.newGuid(), vm.getId()), VmDeviceGeneralType.CONTROLLER, VmDeviceType.VIRTIOSCSI, specParams, true, false); } }

Target:
public void addVirtioScsiController(VmBase vm, Version version) { boolean hasIoThreads = vm.getNumOfIoThreads() > 0 && FeatureSupported.virtioScsiIoThread(version); int numOfScsiControllers = hasIoThreads ? vm.getNumOfIoThreads() : 1; for (int i = 0; i < numOfScsiControllers; i++) { Map<String, Object> specParams = new HashMap<>(); if (hasIoThreads) { specParams.put(VdsProperties.ioThreadId, i); } VmDevice device = addManagedDevice( new VmDeviceId(Guid.newGuid(), vm.getId()), VmDeviceGeneralType.CONTROLLER, VmDeviceType.VIRTIOSCSI, specParams, true, false); } }
Source:
protected boolean hasDataAvailable() { return mFollowersWPCOM != null && mFollowersEmail != null; }

Target:
protected boolean hasDataAvailable() { return mFollowersWPCOM != null || mFollowersEmail != null; }
Source:
private MethodHandle findBuilderSetter(final Class<?> builderClass, String name, Type type) throws IllegalAccessException, NoSuchMethodException { final NoSuchMethodException failure; try { return MethodHandles.lookup().unreflect(builderClass.getMethod(name, GenericTypes.getErasedType(type))); } catch (NoSuchMethodException e) { failure = e; } for (Method m : builderClass.getMethods()) { if (m.getName().equals(name) && m.getParameterCount() == 1) { return MethodHandles.lookup().unreflect(m); } } throw failure; }

Target:
private MethodHandle findBuilderSetter(final Class<?> builderClass, String name, Type type) throws IllegalAccessException, NoSuchMethodException { final List<NoSuchMethodException> failures = new ArrayList<>(); final String setName = "set" + name.substring(0, 1).toUpperCase() + name.substring(1); final Set<String> names = new HashSet<>(Arrays.asList(setName, name)); for (String tryName : names) { try { return MethodHandles.lookup().unreflect(builderClass.getMethod(tryName, GenericTypes.getErasedType(type))); } catch (NoSuchMethodException e) { failures.add(e); } } for (Method m : builderClass.getMethods()) { if (names.contains(m.getName()) && m.getParameterCount() == 1) { return MethodHandles.lookup().unreflect(m); } } final IllegalArgumentException iae = new IllegalArgumentException("Failed to find builder setter for property " + name + " of " + type); failures.forEach(iae::addSuppressed); throw iae; }
Source:
public SolenoidSubsystem( DoubleSolenoid... solenoids) { this(false, solenoids); }

Target:
public SolenoidSubsystem(DoubleSolenoid... solenoids) { this("SolenoidSubsystem", solenoids); }
Source:
public boolean deleteEndpointForTenant(String endpointName, String tenantDomain) throws EndpointAdminException { try { PrivilegedCarbonContext.startTenantFlow(); PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(tenantDomain, true); boolean status = deleteEndpoint(endpointName); return status; } finally { PrivilegedCarbonContext.endTenantFlow(); } }

Target:
public boolean deleteEndpointForTenant(String endpointName, String tenantDomain) throws EndpointAdminException { try { PrivilegedCarbonContext.startTenantFlow(); PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(tenantDomain, true); return deleteEndpoint(endpointName); } finally { PrivilegedCarbonContext.endTenantFlow(); } }
Source:
public void onTestStart(ITestResult result) { super.onTestStart(result); if (!isLocal) { if (result.getInstance() instanceof SauceOnDemandSessionIdProvider) { this.sessionIdProvider = (SauceOnDemandSessionIdProvider) result.getInstance(); if (sessionIdProvider.getSessionId() != null) { System.out.println(String.format("SauceOnDemandSessionID=%1$s job-name=%2$s", sessionIdProvider.getSessionId(), result.getMethod().getMethodName())); } } SauceOnDemandAuthentication sauceOnDemandAuthentication; if (result.getInstance() instanceof SauceOnDemandAuthenticationProvider) { SauceOnDemandAuthenticationProvider provider = (SauceOnDemandAuthenticationProvider) result.getInstance(); sauceOnDemandAuthentication = provider.getAuthentication(); } else { sauceOnDemandAuthentication = new SauceOnDemandAuthentication(); } this.sauceREST = new SauceREST(sauceOnDemandAuthentication.getUsername(), sauceOnDemandAuthentication.getAccessKey()); } }

Target:
public void onTestStart(ITestResult result) { super.onTestStart(result); if (isLocal) { return; } if (result.getInstance() instanceof SauceOnDemandSessionIdProvider) { this.sessionIdProvider = (SauceOnDemandSessionIdProvider) result.getInstance(); if (sessionIdProvider.getSessionId() != null) { System.out.println(String.format("SauceOnDemandSessionID=%1$s job-name=%2$s", sessionIdProvider.getSessionId(), result.getMethod().getMethodName())); } } SauceOnDemandAuthentication sauceOnDemandAuthentication; if (result.getInstance() instanceof SauceOnDemandAuthenticationProvider) { SauceOnDemandAuthenticationProvider provider = (SauceOnDemandAuthenticationProvider) result.getInstance(); sauceOnDemandAuthentication = provider.getAuthentication(); } else { sauceOnDemandAuthentication = new SauceOnDemandAuthentication(); } this.sauceREST = new SauceREST(sauceOnDemandAuthentication.getUsername(), sauceOnDemandAuthentication.getAccessKey()); }
Source:
public void setUp() throws IOException { final Registry registry = Mockito.mock(Registry.class); this.initialSetupTask = new InitialSetupTask(registry); this.temporaryTestDirectory = Files.createTempDirectory(InitialSetupTaskUnitTest.class.getSimpleName() + "-"); }

Target:
public void setUp() throws IOException { final Registry registry = Mockito.mock(Registry.class); this.initialSetupTask = new InitialSetupTask(registry); }
Source:
public void testParsePointSymbolizerRelativeURL() throws Exception { PointSymbolizer sym = (PointSymbolizer) parse("example-pointsymbolizer6.xml"); assertEquals("MyPointSymbolizer", sym.getName()); assertEquals("Example Pointsymbolizer", sym.getDescription().getTitle().toString()); assertEquals( "This is just a simple example of a point symbolizer.", sym.getDescription().getAbstract().toString()); Graphic g = sym.getGraphic(); assertEquals(15.0, g.getSize().evaluate(null, Double.class)); assertEquals(1, g.getExternalGraphics().length); ExternalGraphic eg = g.getExternalGraphics()[0]; assertEquals("inlineContent-image.png", eg.getURI().toString()); assertEquals("image/png", eg.getFormat()); }

Target:
public void testParsePointSymbolizerRelativeURL() throws Exception { SEConfiguration se = new SEConfiguration() { @Override protected void configureContext(MutablePicoContainer container) { super.configureContext(container); DefaultResourceLocator locator = (DefaultResourceLocator) container.getComponentInstance(ResourceLocator.class); try { locator.setSourceUrl(new URL("<LINK_4>")); } catch (MalformedURLException e) { } } }; Parser p = new Parser(se); PointSymbolizer sym = (PointSymbolizer) p.parse(getClass().getResourceAsStream("example-pointsymbolizer6.xml")); assertEquals("MyPointSymbolizer", sym.getName()); assertEquals("Example Pointsymbolizer", sym.getDescription().getTitle().toString()); assertEquals( "This is just a simple example of a point symbolizer.", sym.getDescription().getAbstract().toString()); Graphic g = sym.getGraphic(); assertEquals(15.0, g.getSize().evaluate(null, Double.class)); assertEquals(1, g.graphicalSymbols().size()); ExternalGraphic eg = (ExternalGraphic) g.graphicalSymbols().get(0); assertEquals("<LINK_4>inlineContent-image.png", eg.getURI().toString()); assertEquals("image/png", eg.getFormat()); }
Source:
public void testCreationalAndDisposalMethods() { Bean<Skeleton> skeletonBean = getUniqueBean(Skeleton.class, Undead.UndeadLiteral.INSTANCE); CreationalContext<Skeleton> skeletonCreationalContext = getCurrentManager().createCreationalContext(skeletonBean); Skeleton skeleton = skeletonBean.create(skeletonCreationalContext); Bean<Zombie> zombieBean = getUniqueBean(Zombie.class, Undead.UndeadLiteral.INSTANCE, Dangerous.DangerousLiteral.INSTANCE); CreationalContext<Zombie> zombieCreationalContext = getCurrentManager().createCreationalContext(zombieBean); Zombie zombie = zombieBean.create(zombieCreationalContext); Bean<Ghost> ghostBean = getUniqueBean(Ghost.class, Undead.UndeadLiteral.INSTANCE); CreationalContext<Ghost> ghostCreationalContext = getCurrentManager().createCreationalContext(ghostBean); Ghost ghost = ghostBean.create(ghostCreationalContext); Bean<Vampire> vampireBean = getUniqueBean(Vampire.class, Undead.UndeadLiteral.INSTANCE); CreationalContext<Vampire> vampireCreationalContext = getCurrentManager().createCreationalContext(vampireBean); Vampire vampire = vampireBean.create(vampireCreationalContext); assertTrue(MonsterController.skeletonProducerCalled); assertTrue(MonsterController.zombieProducerCalled); assertTrue(MonsterController.ghostInstanceObtained); assertTrue(MonsterController.vampireInstanceCreated); skeletonBean.destroy(skeleton, skeletonCreationalContext); zombieBean.destroy(zombie, zombieCreationalContext); assertTrue(MonsterController.zombieKilled); assertTrue(MonsterController.skeletonKilled); }

Target:
public void testCreationalAndDisposalMethods() { Bean<Skeleton> skeletonBean = getUniqueBean(Skeleton.class, Undead.UndeadLiteral.INSTANCE); CreationalContext<Skeleton> skeletonCreationalContext = getCurrentManager().createCreationalContext(skeletonBean); Skeleton skeleton = skeletonBean.create(skeletonCreationalContext); Bean<Zombie> zombieBean = getUniqueBean(Zombie.class, Undead.UndeadLiteral.INSTANCE, Dangerous.DangerousLiteral.INSTANCE); CreationalContext<Zombie> zombieCreationalContext = getCurrentManager().createCreationalContext(zombieBean); Zombie zombie = zombieBean.create(zombieCreationalContext); spawnMonster(Ghost.class, Undead.UndeadLiteral.INSTANCE); spawnMonster(Vampire.class, Undead.UndeadLiteral.INSTANCE); assertTrue(MonsterController.skeletonProducerCalled); assertTrue(MonsterController.zombieProducerCalled); assertTrue(MonsterController.ghostInstanceObtained); assertTrue(MonsterController.vampireInstanceCreated); skeletonBean.destroy(skeleton, skeletonCreationalContext); zombieBean.destroy(zombie, zombieCreationalContext); assertTrue(MonsterController.zombieKilled); assertTrue(MonsterController.skeletonKilled); }
Source:
protected String getBuildAuthorName() { try { return runGitCommand(canonical, "config --get user.name"); } catch (NativeCommandException e) { if (e.getExitCode() == 1) { return ""; } throw Throwables.propagate(e); } }

Target:
protected String getBuildAuthorName() throws GitCommitIdExecutionException { try { return runGitCommand(canonical, "config --get user.name"); } catch (NativeCommandException e) { if (e.getExitCode() == 1) { return ""; } throw Throwables.propagate(e); } }
Source:
public void should_run_eslint_based_rules() throws Exception { String sourceCode = "function foo() { try {" + " doSomething();" + "} catch (ex) {" + " throw ex;" + "}}"; List<Issue> issues = analyze(FILE_PATH, sourceCode); assertThat(issues).extracting(Issue::getRuleKey).containsExactly("javascript:S2737"); issues = analyze(FILE_PATH, sourceCode); assertThat(issues).extracting(Issue::getRuleKey).containsExactly("javascript:S2737"); assertThat(logs).contains("Node.js process is already started, no need to start."); }

Target:
public void should_run_eslint_based_rules() throws Exception { String sourceCode = "function foo() { try {" + " doSomething();" + "} catch (ex) {" + " throw ex;" + "}}"; List<Issue> issues = analyze(FILE_PATH, sourceCode); assertThat(issues).extracting(Issue::getRuleKey).containsExactly("javascript:S2737"); issues = analyze(FILE_PATH, sourceCode); assertThat(issues).extracting(Issue::getRuleKey).containsExactly("javascript:S2737"); assertThat(logs).contains("SonarJS eslint-bridge server is up, no need to start."); }
Source:
public boolean visitTree(VisitContext context, VisitCallback callback) { if (!isVisitable(context)) return false; FacesContext facesContext = context.getFacesContext(); pushComponentToEL(facesContext, null); try { VisitResult result = context.invokeVisitCallback(this, callback); if (result == VisitResult.COMPLETE) return true; if (result == VisitResult.ACCEPT) { Iterator<UIComponent> kids = this.getKids(context); while(kids.hasNext()) { boolean done = kids.next().visitTree(context, callback); if (done) return true; } } } finally { popComponentFromEL(facesContext); } return false; }

Target:
public boolean visitTree(VisitContext context, VisitCallback callback) { if (!isVisitable(context)) return false; FacesContext facesContext = context.getFacesContext(); pushComponentToEL(facesContext, null); try { VisitResult result = context.invokeVisitCallback(this, callback); if (result == VisitResult.COMPLETE) return true; if (result == VisitResult.ACCEPT) { Iterator<UIComponent> kids = AbstractTab.getVisitableChildren(this, context); while(kids.hasNext()) { boolean done = kids.next().visitTree(context, callback); if (done) return true; } } } finally { popComponentFromEL(facesContext); } return false; }
Source:
public void addressesInHeadersAddedWithoutSlashes() throws IOException { final Socket socket = BkBasicTest.createMockSocket(); final AtomicReference<Request> ref = new AtomicReference<Request>(); new BkBasic( new Take() { @Override public Response act(final Request req) { ref.set(req); return new RsEmpty(); } } ).accept(socket); final Request request = ref.get(); MatcherAssert.assertThat( request, Matchers.is( Matchers.notNullValue() ) ); MatcherAssert.assertThat( request, Matchers.is( Matchers.instanceOf( RqWithHeaders.class ) ) ); final Collection<String> head = Lists.newArrayList(request.head()); MatcherAssert.assertThat(head, Matchers.not(Matchers.<String>empty())); final Collection<String> found = Collections2.filter( head, new Predicate<String>() { @Override public boolean apply(final String header) { return header.contains("X-Takes") && header.contains("Address"); } } ); for (final String header : found) { MatcherAssert.assertThat( header, Matchers.not( Matchers.containsString("/") ) ); } MatcherAssert.assertThat( new RqSocket(request).getLocalAddress(), Matchers.notNullValue() ); MatcherAssert.assertThat( new RqSocket(request).getRemoteAddress(), Matchers.notNullValue() ); }

Target:
public void addressesInHeadersAddedWithoutSlashes() throws IOException { final Socket socket = BkBasicTest.createMockSocket(); final AtomicReference<Request> ref = new AtomicReference<Request>(); new BkBasic( new Take() { @Override public Response act(final Request req) { ref.set(req); return new RsEmpty(); } } ).accept(socket); final Request request = ref.get(); final RqHeaders.Smart smart = new RqHeaders.Smart( new RqHeaders.Base(request) ); MatcherAssert.assertThat( smart.single( "X-Takes-LocalAddress", "" ), Matchers.not( Matchers.containsString("/") ) ); MatcherAssert.assertThat( smart.single( "X-Takes-RemoteAddress", "" ), Matchers.not( Matchers.containsString("/") ) ); MatcherAssert.assertThat( new RqSocket(request).getLocalAddress(), Matchers.notNullValue() ); MatcherAssert.assertThat( new RqSocket(request).getRemoteAddress(), Matchers.notNullValue() ); }
Source:
public void checkCanSetUser(Principal principal, String userName) { if (principal == null) { return; } String principalName = principal.getName(); if (usernameExtractionRules.isEmpty()) { return; } for (Pattern pattern : usernameExtractionRules) { Matcher matcher = pattern.matcher(principalName); while (matcher.find()) { for (int i = 1; i <= matcher.groupCount(); i++) { String extractedUsername = matcher.group(i); if (userName.equals(extractedUsername)) { return; } } } } denySetUser(principal, userName); }

Target:
public void checkCanSetUser(Principal principal, String userName) { if (userPatterns.isEmpty()) { return; } if (principal == null) { denySetUser(principal, userName); } String principalName = principal.getName(); for (Pattern pattern : userPatterns) { Matcher matcher = pattern.matcher(principalName); if (matcher.matches()) { for (int i = 1; i <= matcher.groupCount(); i++) { String extractedUsername = matcher.group(i); if (userName.equals(extractedUsername)) { return; } } } } denySetUser(principal, userName); }
Source:
private Label getHostJavaToolchain() { if (useRemoteHostJavaToolchain) { return Label.parseAbsoluteUnchecked("@bazel_tools } return hostJavaToolchain; }

Target:
private Label getHostJavaToolchain() { if (hostJavaToolchain == null) { if (useRemoteHostJavaToolchain) { return Label.parseAbsoluteUnchecked("@bazel_tools } else { return Label.parseAbsoluteUnchecked("@bazel_tools } } return hostJavaToolchain; }
Source:
public void test() throws Exception { connect(); sleep(1000); Assert.assertEquals("au working", getZKLog()); }

Target:
public void test() throws Exception { connect(); sleep(1000); Assert.assertEquals("onPageSize", getZKLog()); }
Source:
protected RevisionListViewImpl(GitResources resources, GitLocalizationConstant locale, DateTimeFormatter dateTimeFormatter, org.eclipse.che.ide.Resources coreRes) { this.res = resources; this.locale = locale; this.dateTimeFormatter = dateTimeFormatter; this.ensureDebugId("git-compare-revision-window"); Widget widget = ourUiBinder.createAndBindUi(this); this.setTitle(locale.compareWithRevisionTitle()); this.setWidget(widget); description.setReadOnly(true); createRevisionsTable(coreRes); createButtons(); }

Target:
protected RevisionListViewImpl(GitResources resources, GitLocalizationConstant locale, DateTimeFormatter dateTimeFormatter, org.eclipse.che.ide.Resources coreRes) { this.res = resources; this.locale = locale; this.dateTimeFormatter = dateTimeFormatter; this.ensureDebugId("git-compare-revision-window"); Widget widget = uiBinder.createAndBindUi(this); this.setTitle(locale.compareWithRevisionTitle()); this.setWidget(widget); description.setReadOnly(true); createRevisionsTable(coreRes); createButtons(); }
Source:
private static Optional<Page> extractStatisticsRows(Page page) { int statisticsPositionCount = 0; for (int position = 0; position < page.getPositionCount(); position++) { if (isStatisticsPosition(page, position)) { statisticsPositionCount++; } } if (statisticsPositionCount == 0) { return Optional.empty(); } if (statisticsPositionCount == page.getPositionCount()) { return Optional.of(page); } int selectedPositionsIndex = 0; int[] selectedPositions = new int[statisticsPositionCount]; for (int position = 0; position < page.getPositionCount(); position++) { if (isStatisticsPosition(page, position)) { selectedPositions[selectedPositionsIndex] = position; selectedPositionsIndex++; } } Block[] blocks = new Block[page.getChannelCount()]; for (int channel = 0; channel < page.getChannelCount(); channel++) { blocks[channel] = page.getBlock(channel).copyPositions(selectedPositions, 0, statisticsPositionCount); } return Optional.of(new Page(statisticsPositionCount, blocks)); }

Target:
private static Optional<Page> extractStatisticsRows(Page page) { int statisticsPositionCount = 0; for (int position = 0; position < page.getPositionCount(); position++) { if (isStatisticsPosition(page, position)) { statisticsPositionCount++; } } if (statisticsPositionCount == 0) { return Optional.empty(); } if (statisticsPositionCount == page.getPositionCount()) { return Optional.of(page); } int selectedPositionsIndex = 0; int[] selectedPositions = new int[statisticsPositionCount]; for (int position = 0; position < page.getPositionCount(); position++) { if (isStatisticsPosition(page, position)) { selectedPositions[selectedPositionsIndex] = position; selectedPositionsIndex++; } } Block[] blocks = new Block[page.getChannelCount()]; for (int channel = 0; channel < page.getChannelCount(); channel++) { blocks[channel] = page.getBlock(channel).getPositions(selectedPositions, 0, statisticsPositionCount); } return Optional.of(new Page(statisticsPositionCount, blocks)); }
Source:
boolean sendMouseEvent (int type, int button, int count, int detail, boolean send, int time, double x, double y, boolean is_hint, int state) { if (!hooks (type) && !filters (type)) return true; Event event = new Event (); event.time = time; event.button = button; event.detail = detail; event.count = count; if (is_hint) { Rectangle eventRect = new Rectangle ((int)x, (int)y, 0, 0); event.setBounds (DPIUtil.autoScaleDown (eventRect)); } else { long window = eventWindow (); int origin_x = new int [1], origin_y = new int [1]; OS.gdk_window_get_origin (window, origin_x, origin_y); Rectangle eventRect = new Rectangle ((int)x - origin_x [0], (int)y - origin_y [0], 0, 0); event.setBounds (DPIUtil.autoScaleDown (eventRect)); } if ((style & SWT.MIRRORED) != 0) event.x = DPIUtil.autoScaleDown (getClientWidth ()) - event.x; setInputState (event, state); if (!OS.isX11()) { if (type == SWT.MouseDown) { dragDetectionQueue = new Event [4]; postDragEventQueue(type, event); return event.doit; } else { if (dragDetectionQueue != null) { if (type == SWT.MouseMove) { postDragEventQueue(type, event); if (dragDetect (event.x, event.y, false, true, null)) { sendEvent(dragDetectionQueue[0].type, dragDetectionQueue[0]); dragDetectionQueue = null; } } else if (type == SWT.MouseUp) { postDragEventQueue(type, event); runDeferredDragEvents(); } return event.doit; } } } if (send) { sendEvent (type, event); if (isDisposed ()) return false; } else { postEvent (type, event); } return event.doit; }

Target:
boolean sendMouseEvent (int type, int button, int count, int detail, boolean send, int time, double x, double y, boolean is_hint, int state) { if (!hooks (type) && !filters (type)) return true; Event event = new Event (); event.time = time; event.button = button; event.detail = detail; event.count = count; if (is_hint) { Rectangle eventRect = new Rectangle ((int)x, (int)y, 0, 0); event.setBounds (DPIUtil.autoScaleDown (eventRect)); } else { long window = eventWindow (); int origin_x = new int [1], origin_y = new int [1]; OS.gdk_window_get_origin (window, origin_x, origin_y); Rectangle eventRect = new Rectangle ((int)x - origin_x [0], (int)y - origin_y [0], 0, 0); event.setBounds (DPIUtil.autoScaleDown (eventRect)); } if ((style & SWT.MIRRORED) != 0) event.x = DPIUtil.autoScaleDown (getClientWidth ()) - event.x; setInputState (event, state); if (!OS.isX11()) { if (type == SWT.MouseDown) { dragDetectionQueue = new LinkedList<>(); postDragEventQueue(type, event); return event.doit; } else { if (dragDetectionQueue != null) { if (type == SWT.MouseMove) { postDragEventQueue(type, event); if (dragDetect (event.x, event.y, false, true, null)) { sendEvent(dragDetectionQueue.getFirst().type, dragDetectionQueue.getFirst()); dragDetectionQueue = null; } } else if (type == SWT.MouseUp) { postDragEventQueue(type, event); runDeferredDragEvents(); } return event.doit; } } } if (send) { sendEvent (type, event); if (isDisposed ()) return false; } else { postEvent (type, event); } return event.doit; }