auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
public void test() throws Exception { DesktopAgent desktop = connect(); desktop.query("button").click(); Assert.assertEquals("4", desktop.query("#result").as(Label.class).getValue()); desktop.query("button").click(); Assert.assertEquals("4", desktop.query("#result").as(Label.class).getValue()); desktop.query("button").click(); Assert.assertEquals("4", desktop.query("#result").as(Label.class).getValue()); }

Target:
public void test() throws Exception { DesktopAgent desktop = connect(); ComponentAgent saveBtn = desktop.query("#save"); saveBtn.click(); Assert.assertEquals("4", desktop.query("#result").as(Label.class).getValue()); saveBtn.click(); Assert.assertEquals("4", desktop.query("#result").as(Label.class).getValue()); saveBtn.click(); Assert.assertEquals("4", desktop.query("#result").as(Label.class).getValue()); desktop.query("#detach").click(); saveBtn.click(); Assert.assertEquals("1", desktop.query("#result").as(Label.class).getValue()); }
Source:
public void testOperationExtractAlltext() throws Exception { OperationChain chain = new OperationChain("testChain"); ctx.setInput(testDoc); chain.add(PDFExtractTextOperation.ID) .set("save", false) .set("targetxpath", "dc:description"); DocumentModel documentModified = (DocumentModel) automationService.run(ctx, chain); String text = (String) documentModified.getPropertyValue("dc:description"); assertNotNull(text); assertEquals(19045, text.length()); assertFalse(text.contains("Something that is not in the file")); assertTrue(text.contains("13.1")); chain = new OperationChain("testChain"); ctx.setInput(testDoc); chain.add(PDFExtractTextOperation.ID) .set("save", false) .set("targetxpath", "dc:description") .set("patterntofind", ""); documentModified = (DocumentModel) automationService.run(ctx, chain); text = (String) documentModified.getPropertyValue("dc:description"); assertNotNull(text); assertEquals(19045, text.length()); assertFalse(text.contains("Something that is not in the file")); assertTrue(text.contains("13.1")); }

Target:
public void testOperationExtractAlltext() throws Exception { doTestExtractAllText(false); doTestExtractAllText(true); }
Source:
public FindEventsRequestBuilder withDefaults() { this.eventLogCategory = DEFAULT_EVENT_LOG_CATEGORY; this.from = DateConverter.createXMLGregorianCalendar(DEFAULT_FROM.toDate()); this.until = DateConverter.createXMLGregorianCalendar(DEFAULT_UNTIL.toDate()); return this; }

Target:
public FindEventsRequestBuilder withDefaults() { return this.fromParameterMap(Collections.emptyMap()); }
Source:
private Timer getLoadTimer(final DSFSessionState sessionState, final int timeout) { final VisualizerModel model = fDataModel; Timer t = new Timer(timeout) { @Override public void run() { if (sessionState != null) { DsfSession session = DsfSession.getSession(sessionState.getSessionID()); if (session != null) { DsfExecutor executor = session.getExecutor(); if (executor != null) { executor.execute(new Runnable() { @Override public void run() { updateLoads(model); } }); } } } } }; return t; }

Target:
private Timer getLoadTimer(final DSFSessionState sessionState, final int timeout) { Timer t = new Timer(timeout) { @Override public void run() { if (sessionState != null) { DsfSession session = DsfSession.getSession(sessionState.getSessionID()); if (session != null) { DsfExecutor executor = session.getExecutor(); if (executor != null) { executor.execute(new Runnable() { @Override public void run() { final VisualizerModel model = fDataModel; updateLoads(model); } }); } } } } }; return t; }
Source:
public int complete(String buffer, int cursor, List<CharSequence> candidates) { int completionIndex = super.complete(buffer, cursor, candidates); int spaceIndex = buffer.indexOf(' '); String commandName = ((spaceIndex != -1) ? buffer.substring(0, spaceIndex) : ""); if (commandName != null && !commandName.isEmpty()) { for (Command command : this.commands) { if (command.getName().equals(commandName)) { if (cursor == buffer.length() && buffer.endsWith(" ")) { printUsage(command); break; } Completer completer = this.commandCompleters.get(command.getName()); if (completer != null) { completionIndex = completer.complete(buffer, cursor, candidates); break; } } } } return completionIndex; }

Target:
public int complete(String buffer, int cursor, List<CharSequence> candidates) { int completionIndex = super.complete(buffer, cursor, candidates); int spaceIndex = buffer.indexOf(' '); String commandName = ((spaceIndex != -1) ? buffer.substring(0, spaceIndex) : ""); if (StringUtils.hasText(commandName)) { for (Command command : this.commands) { if (command.getName().equals(commandName)) { if (cursor == buffer.length() && buffer.endsWith(" ")) { printUsage(command); break; } Completer completer = this.commandCompleters.get(command.getName()); if (completer != null) { completionIndex = completer.complete(buffer, cursor, candidates); break; } } } } return completionIndex; }
Source:
public boolean open(String path, SymmetricKey encryptionKey) throws SQLException { if (database != null && database.isOpen()) return true; boolean hasError = false; try { if (encryptionKey != null && !supportEncryption()) { Log.w(TAG, "Encryption not available (app not built with SQLCipher)"); throw new SQLException(SQLException.SQLITE_ENCRYPTION_NOTAVAILABLE, "Encryption not available"); } this.encryptionKey = encryptionKey; SQLiteDatabase.setDatabasePlatformSupport(getDatabasePlatformSupport()); database = SQLiteDatabase.openDatabase(path, null, SQLiteDatabase.CREATE_IF_NECESSARY | SQLiteDatabase.ENABLE_WRITE_AHEAD_LOGGING, getWALConnectionPoolSize(), null, new ConnectionListener()); Log.v(Log.TAG_DATABASE, "%s: Opened Android sqlite db", this); } catch (SQLiteDatabaseCorruptException e) { hasError = true; if (encryptionKey != null && supportEncryption()) { Log.e(Log.TAG_DATABASE, "Unauthorized to open the SQLite database", e); throw new SQLException(SQLException.SQLITE_ENCRYPTION_UNAUTHORIZED, "Cannot decrypt or access the database"); } else { Log.e(Log.TAG_DATABASE, "The SQLite database file has been corrupted", e); throw new SQLException(SQLException.SQLITE_CORRUPT, e); } } catch (com.couchbase.lite.internal.database.SQLException e) { hasError = true; Log.e(Log.TAG_DATABASE, "Unable to open the SQLite database", e); throw new SQLException(e); } finally { if (hasError && database != null) database.close(); } return database.isOpen(); }

Target:
public boolean open(String path, SymmetricKey encryptionKey) throws SQLException { if (database != null && database.isOpen()) return true; boolean hasError = false; try { if (encryptionKey != null && !supportEncryption()) { Log.w(TAG, "Encryption not available (app not built with SQLCipher)"); throw new SQLException(SQLException.SQLITE_ENCRYPTION_NOTAVAILABLE, "Encryption not available"); } this.encryptionKey = encryptionKey; SQLiteDatabase.setDatabasePlatformSupport(getDatabasePlatformSupport()); database = SQLiteDatabase.openDatabase(path, null, SQLiteDatabase.CREATE_IF_NECESSARY | SQLiteDatabase.ENABLE_WRITE_AHEAD_LOGGING, getWALConnectionPoolSize(), null, new ConnectionListener()); Log.v(Log.TAG_DATABASE, "%s: Opened Android sqlite db", this); } catch (SQLiteDatabaseCorruptException e) { hasError = true; if (encryptionKey != null && supportEncryption()) { Log.e(Log.TAG_DATABASE, "Unauthorized to open the SQLite database", e); throw new SQLException(SQLException.SQLITE_ENCRYPTION_UNAUTHORIZED, "Cannot decrypt or access the database"); } else { Log.e(Log.TAG_DATABASE, "Application might try to open the encrypted database " + "with the standard SQLite library or no password provided. " + "Otherwise, the SQLite database file has been corrupted. ", e); throw new SQLException(SQLException.SQLITE_CORRUPT, e); } } catch (com.couchbase.lite.internal.database.SQLException e) { hasError = true; Log.e(Log.TAG_DATABASE, "Unable to open the SQLite database", e); throw new SQLException(e); } finally { if (hasError && database != null) database.close(); } return database.isOpen(); }
Source:
public Traverser traverse( final Iterable<Node> startNodes, final Iterable<Node> endNodes ) { return new DefaultTraverser( () -> { Resource resource = statementFactory.get(); try { return new BidirectionalTraverserIterator( resource, start, end, sideSelector, collisionPolicy, collisionEvaluator, maxDepth, startNodes, endNodes ); } catch ( Exception e ) { resource.close(); throw e; } } ); }

Target:
public Traverser traverse( final Iterable<Node> startNodes, final Iterable<Node> endNodes ) { return new DefaultTraverser( () -> { Resource resource = statementFactory.get(); boolean success = false; try { BidirectionalTraverserIterator iterator = new BidirectionalTraverserIterator( resource, start, end, sideSelector, collisionPolicy, collisionEvaluator, maxDepth, startNodes, endNodes ); success = true; return iterator; } finally { if ( !success ) { resource.close(); } } } ); }
Source:
private OnHeapValueHolder<V> internalGet(final K key, final boolean updateAccess) throws CacheAccessException { getObserver.begin(); final StoreEventSink<K, V> eventSink = storeEventDispatcher.eventSink(); try { OnHeapValueHolder<V> mapping = map.get(key); if (mapping == null) { getObserver.end(StoreOperationOutcomes.GetOutcome.MISS); storeEventDispatcher.releaseEventSink(eventSink); return null; } if (mapping.isExpired(timeSource.getTimeMillis(), TimeUnit.MILLISECONDS)) { expireMapping(key, mapping); getObserver.end(StoreOperationOutcomes.GetOutcome.MISS); storeEventDispatcher.releaseEventSink(eventSink); return null; } if (updateAccess) { mapping = setAccessTimeAndExpiryThenReturnMapping(key, mapping, timeSource.getTimeMillis(), eventSink); } if (mapping != null) { getObserver.end(StoreOperationOutcomes.GetOutcome.HIT); } storeEventDispatcher.releaseEventSink(eventSink); return mapping; } catch (RuntimeException re) { storeEventDispatcher.releaseEventSinkAfterFailure(eventSink, re); handleRuntimeException(re); return null; } }

Target:
private OnHeapValueHolder<V> internalGet(final K key, final boolean updateAccess) throws CacheAccessException { getObserver.begin(); StoreEventSink<K, V> eventSink = null; try { OnHeapValueHolder<V> mapping = map.get(key); if (mapping == null) { getObserver.end(StoreOperationOutcomes.GetOutcome.MISS); return null; } if (mapping.isExpired(timeSource.getTimeMillis(), TimeUnit.MILLISECONDS)) { expireMapping(key, mapping); getObserver.end(StoreOperationOutcomes.GetOutcome.MISS); return null; } if (updateAccess) { eventSink = storeEventDispatcher.eventSink(); mapping = setAccessTimeAndExpiryThenReturnMapping(key, mapping, timeSource.getTimeMillis(), eventSink); storeEventDispatcher.releaseEventSink(eventSink); } if (mapping != null) { getObserver.end(StoreOperationOutcomes.GetOutcome.HIT); } else { getObserver.end(StoreOperationOutcomes.GetOutcome.MISS); } return mapping; } catch (RuntimeException re) { if (eventSink != null) { storeEventDispatcher.releaseEventSinkAfterFailure(eventSink, re); } handleRuntimeException(re); return null; } }
Source:
private void registerGlobalActions() { IActionBars actionBars = getViewSite().getActionBars(); actionBars.setGlobalActionHandler(ActionFactory.COPY.getId(), copyAction); }

Target:
private void registerGlobalActions() { IActionBars actionBars = getViewSite().getActionBars(); actionBars.setGlobalActionHandler(ActionFactory.COPY.getId(), fCopyAction); }
Source:
private void putBlob(MessageInfo messageInfo, ByteBuffer messageBuf, long size) throws CloudStorageException, IOException, GeneralSecurityException { if (shouldUpload(messageInfo)) { BlobId blobId = (BlobId) messageInfo.getStoreKey(); boolean isRouterEncrypted = isRouterEncrypted(blobId); String kmsContext = null; EncryptionOrigin encryptionOrigin = isRouterEncrypted ? EncryptionOrigin.ROUTER : EncryptionOrigin.NONE; if (cloudConfig.vcrRequireEncryption) { if (isRouterEncrypted) { } else { if (cryptoAgent != null) { Timer.Context encryptionTimer = vcrMetrics.blobEncryptionTime.time(); messageBuf = cryptoAgent.encrypt(messageBuf); encryptionTimer.stop(); vcrMetrics.blobEncryptionCount.inc(); encryptionOrigin = EncryptionOrigin.VCR; kmsContext = cryptoAgent.getEncryptionContext(); } else { vcrMetrics.skipUnencryptedBlobsCount.inc(); return; } } } else { } CloudBlobMetadata blobMetadata = new CloudBlobMetadata(blobId, messageInfo.getOperationTimeMs(), messageInfo.getExpirationTimeInMs(), messageInfo.getSize(), encryptionOrigin, kmsContext); cloudDestination.uploadBlob(blobId, size, blobMetadata, new ByteBufferInputStream(messageBuf)); } }

Target:
private void putBlob(MessageInfo messageInfo, ByteBuffer messageBuf, long size) throws CloudStorageException, IOException, GeneralSecurityException { if (shouldUpload(messageInfo)) { BlobId blobId = (BlobId) messageInfo.getStoreKey(); boolean isRouterEncrypted = isRouterEncrypted(blobId); String kmsContext = null; String cryptoAgentFactoryClass = null; EncryptionOrigin encryptionOrigin = isRouterEncrypted ? EncryptionOrigin.ROUTER : EncryptionOrigin.NONE; if (requireEncryption) { if (isRouterEncrypted) { } else { Timer.Context encryptionTimer = vcrMetrics.blobEncryptionTime.time(); messageBuf = cryptoAgent.encrypt(messageBuf); encryptionTimer.stop(); vcrMetrics.blobEncryptionCount.inc(); encryptionOrigin = EncryptionOrigin.VCR; kmsContext = cryptoAgent.getEncryptionContext(); cryptoAgentFactoryClass = this.cryptoAgentFactory.getClass().getName(); } } else { } CloudBlobMetadata blobMetadata = new CloudBlobMetadata(blobId, messageInfo.getOperationTimeMs(), messageInfo.getExpirationTimeInMs(), messageInfo.getSize(), encryptionOrigin, kmsContext, cryptoAgentFactoryClass); cloudDestination.uploadBlob(blobId, size, blobMetadata, new ByteBufferInputStream(messageBuf)); } }
Source:
public void init(List<TransformFunction> arguments, Map<String, DataSource> dataSourceMap) { if (arguments.size() != 2) { throw new IllegalArgumentException("Exact 2 arguments are required for greater transform function"); } _leftTransformFunction = arguments.get(0); _rightTransformFunction = arguments.get(1); }

Target:
public void init(List<TransformFunction> arguments, Map<String, DataSource> dataSourceMap) { Preconditions .checkArgument(arguments.size() == 2, "Exact 2 arguments are required for binary operator transform function"); _leftTransformFunction = arguments.get(0); _rightTransformFunction = arguments.get(1); _leftDataType = _leftTransformFunction.getResultMetadata().getDataType(); _rightDataType = _rightTransformFunction.getResultMetadata().getDataType(); if (_leftDataType == FieldSpec.DataType.BYTES || _rightDataType == FieldSpec.DataType.BYTES) { Preconditions.checkState(_leftDataType == FieldSpec.DataType.BYTES && _rightDataType == FieldSpec.DataType.BYTES, String.format( "Unsupported data type for comparison: [Left Transform Function [%s] result type is [%s], Right Transform Function [%s] result type is [%s]]", _leftTransformFunction.getName(), _leftDataType, _rightTransformFunction.getName(), _rightDataType)); } }
Source:
protected URI rewriteURI(HttpServletRequest request, String host) { final StringBuilder uri = new StringBuilder("http://"); uri.append(host); uri.append(request.getRequestURI()); final String queryString = request.getQueryString(); if (queryString != null) { uri.append("?").append(queryString); } return URI.create(uri.toString()); }

Target:
protected URI rewriteURI(HttpServletRequest request, String host) { return makeURI(host, request.getRequestURI(), request.getQueryString()); }
Source:
public CleanupServer(final DimensionDataCloudControlApi api, final Timeouts timeouts) { this.api = api; this.timeouts = timeouts; }

Target:
CleanupServer(final DimensionDataCloudControlApi api, final Timeouts timeouts) { this.api = api; this.timeouts = timeouts; }
Source:
private void checkFacadeJmxNotifications(List<Pair<String, String>> configurationStateTransitions, List<Pair<String, String>> runningStateTransitions) throws IOException, InterruptedException { final long end = System.currentTimeMillis() + TimeoutUtil.adjust(20000); while (true) { try { readAndCheckFile(JMX_FACADE_RUNTIME, list -> { Assert.assertEquals(Arrays.toString(list.toArray(new String[list.size()])), configurationStateTransitions.size(), list.size()); for (int i = 0; i < configurationStateTransitions.size(); i++) { Pair<String, String> transition = configurationStateTransitions.get(i); errorCollector.checkThat("Line " + list.get(i), list.get(i), containsString( "jboss.root:type=state The attribute 'RuntimeConfigurationState' has changed from '" + transition.getLeft() + "' to '" + transition.getRight() + "'")); } }); readAndCheckFile(JMX_FACADE_RUNNING, list -> { Assert.assertEquals(Arrays.toString(list.toArray(new String[list.size()])), runningStateTransitions.size(), list.size()); for (int i = 0; i < runningStateTransitions.size(); i++) { Pair<String, String> transition = runningStateTransitions.get(i); errorCollector.checkThat("Line " + list.get(i), list.get(i), containsString( "jboss.root:type=state The attribute 'RunningState' has changed from '" + transition.getLeft() + "' to '" + transition.getRight() + "'")); } }); break; } catch (AssertionError e) { if (System.currentTimeMillis() > end) { throw e; } Thread.sleep(1000); } } }

Target:
private void checkFacadeJmxNotifications(List<Pair<String, String>> configurationStateTransitions, List<Pair<String, String>> runningStateTransitions) throws IOException, InterruptedException { final long end = System.currentTimeMillis() + TimeoutUtil.adjust(20000); while (true) { try { readAndCheckFile(JMX_FACADE_RUNTIME, list -> { Assert.assertEquals(String.join(", ", list), configurationStateTransitions.size(), list.size()); for (int i = 0; i < configurationStateTransitions.size(); i++) { Pair<String, String> transition = configurationStateTransitions.get(i); errorCollector.checkThat("Transition " + i + ": " + list.get(i), list.get(i), containsString( "jboss.root:type=state The attribute 'RuntimeConfigurationState' has changed from '" + transition.getLeft() + "' to '" + transition.getRight() + "'")); } }); readAndCheckFile(JMX_FACADE_RUNNING, list -> { Assert.assertEquals(String.join(", ", list), runningStateTransitions.size(), list.size()); for (int i = 0; i < runningStateTransitions.size(); i++) { Pair<String, String> transition = runningStateTransitions.get(i); errorCollector.checkThat("Transition " + i + ": " + list.get(i), list.get(i), containsString( "jboss.root:type=state The attribute 'RunningState' has changed from '" + transition.getLeft() + "' to '" + transition.getRight() + "'")); } }); break; } catch (AssertionError e) { if (System.currentTimeMillis() > end) { throw e; } Thread.sleep(1000); } } }
Source:
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { HttpServletRequest req = (HttpServletRequest) request; HttpServletResponse resp = (HttpServletResponse) response; if (FiltersHelper.isAuthenticated(req) && FiltersHelper.isSessionValid((HttpServletRequest) request, (HttpServletResponse) response)) { chain.doFilter(request, response); } else { try { req.setAttribute(FiltersHelper.Constants.REQUEST_SCHEMES_KEY, schemes); HttpSession session = req.getSession(false); Deque<AuthenticationProfile> stack = null; if (session != null) { stack = (Deque<AuthenticationProfile>) session.getAttribute(STACK_ATTR); } if (stack == null) { stack = new ArrayDeque<>(); stack.addAll(profiles); } String username = doAuth(req, resp, stack); if (!stack.isEmpty()) { req.getSession(true).setAttribute(STACK_ATTR, stack); } else { if (session != null) { session.removeAttribute(STACK_ATTR); } if (StringUtils.isNotEmpty(username)) { Map<String, Object> jsonResponse = SSOOAuthServiceUtils.loginOnBehalf(resp, username, scope); FiltersHelper.isStatusOk(jsonResponse); SSOUtils.createUserSession(req, FiltersHelper.getPayloadForToken(resp, (String) jsonResponse.get("access_token")), false); } chain.doFilter(req, resp); } } catch (Exception e) { log.error("Cannot authenticate using External Authentication: {}", e.getMessage()); log.debug("Cannot authenticate using External Authentication", e); } } }

Target:
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { HttpServletRequest req = (HttpServletRequest) request; HttpServletResponse resp = (HttpServletResponse) response; if (FiltersHelper.isAuthenticated(req) && FiltersHelper.isSessionValid((HttpServletRequest) request, (HttpServletResponse) response)) { chain.doFilter(request, response); } else { try { req.setAttribute(FiltersHelper.Constants.REQUEST_SCHEMES_KEY, schemes); HttpSession session = req.getSession(false); Deque<AuthenticationProfile> stack = null; if (session != null) { stack = (Deque<AuthenticationProfile>) session.getAttribute(STACK_ATTR); } if (stack == null) { stack = new ArrayDeque<>(); stack.addAll(profiles); } String username = doAuth(req, resp, stack); if (!stack.isEmpty()) { req.getSession(true).setAttribute(STACK_ATTR, stack); } else { if (session != null) { session.removeAttribute(STACK_ATTR); } if (username != null) { Map<String, Object> jsonResponse = SSOOAuthServiceUtils.loginOnBehalf(resp, username, scope); FiltersHelper.isStatusOk(jsonResponse); SSOUtils.createUserSession(req, FiltersHelper.getPayloadForToken(resp, (String) jsonResponse.get("access_token")), false); } chain.doFilter(req, resp); } } catch (Exception e) { log.error("Cannot authenticate using External Authentication: {}", e.getMessage()); log.debug("Cannot authenticate using External Authentication", e); } } }
Source:
public void actionPerformed(ActionEvent actionEvent) { int result = chooser.showOpenDialog(FittingMainView.this); if (result == JFileChooser.APPROVE_OPTION) { try { controller.saveJson(new FileOutputStream(chooser.getSelectedFile())); } catch(IOException ex) { NarrowOptionPane.showMessageDialog(FittingMainView.this, ex.getMessage(), "Error", NarrowOptionPane.ERROR_MESSAGE); } } }

Target:
public void actionPerformed(ActionEvent actionEvent) { int result = chooser.showSaveDialog(FittingMainView.this); if (result == JFileChooser.APPROVE_OPTION) { try { controller.saveJson(new FileOutputStream(chooser.getSelectedFile())); } catch(IOException ex) { NarrowOptionPane.showMessageDialog(FittingMainView.this, ex.getMessage(), "Error", NarrowOptionPane.ERROR_MESSAGE); } } }
Source:
public void readFully(long position, byte[] buffer, int offset, int length) throws IOException { FileCacheKey key = new FileCacheKey(path, position, length); if (!cacheManager.get(key, buffer, offset)) { inputStream.readFully(position, buffer, offset, length); cacheManager.put(key, wrappedBuffer(buffer, offset, length)); } if (cacheValidationEnabled) { byte[] validationBuffer = new byte[length]; inputStream.readFully(position, validationBuffer, 0, length); for (int i = 0; i < length; i++) { verify(buffer[offset + i] == validationBuffer[i], "corrupted buffer at position " + i); } } }

Target:
public void readFully(long position, byte[] buffer, int offset, int length) throws IOException { FileReadRequest key = new FileReadRequest(path, position, length); if (!cacheManager.get(key, buffer, offset)) { inputStream.readFully(position, buffer, offset, length); cacheManager.put(key, wrappedBuffer(buffer, offset, length)); return; } if (cacheValidationEnabled) { byte[] validationBuffer = new byte[length]; inputStream.readFully(position, validationBuffer, 0, length); for (int i = 0; i < length; i++) { verify(buffer[offset + i] == validationBuffer[i], "corrupted buffer at position " + i); } } }
Source:
protected ImmutableList<String> getShellCommandInternal(ExecutionContext context) { return ImmutableList.<String>builder() .addAll(cgoCommandPrefix) .add("-importpath", context.getBuildCellRootPath().toString()) .add("-srcdir", context.getBuildCellRootPath().toString()) .add("-objdir", outputDir.toString()) .add("--") .add("-I" + getBuildTarget().get().getBasePath().toString()) .addAll(cgoCompilerFlags) .addAll(srcs.stream().map(Object::toString).iterator()) .build(); }

Target:
protected ImmutableList<String> getShellCommandInternal(ExecutionContext context) { return ImmutableList.<String>builder() .addAll(cgoCommandPrefix) .add("-importpath", context.getBuildCellRootPath().toString()) .add("-srcdir", context.getBuildCellRootPath().toString()) .add("-objdir", outputDir.toString()) .addAll(cgoCompilerFlags) .add("--") .add("-I" + getBuildTarget().get().getBasePath().toString()) .addAll(srcs.stream().map(Object::toString).iterator()) .build(); }
Source:
private boolean ensureValidKeyAvailable() { boolean keyAvailableLocally = true; if (this.key == null) { try { this.key = getKey().block().getKey(); keyAvailableLocally = this.key.isValid(); initializeCryptoClients(); } catch (HttpResponseException | NullPointerException e) { logger.info("Failed to retrieve key from key vault"); keyAvailableLocally = false; } } return keyAvailableLocally; }

Target:
private boolean ensureValidKeyAvailable() { boolean keyAvailableLocally = true; if (this.key == null) { try { KeyVaultKey keyVaultKey = getKey().block(); this.key = keyVaultKey.getKey(); keyAvailableLocally = this.key.isValid(); initializeCryptoClients(); } catch (HttpResponseException | NullPointerException e) { logger.warning("Failed to retrieve key from key vault"); logger.logExceptionAsWarning(e); keyAvailableLocally = false; } } return keyAvailableLocally; }
Source:
public AbsolutePositionProgressMonitorPart(Composite parent) { super(parent, null); setLayout(null); this.setData(CSS_ID_KEY, SPLASH_PROGRESS_PART_ID); fProgressIndicator.setData(CSS_ID_KEY, SPLASH_PROGRESS_INDICATOR_ID); fLabel.setData(CSS_ID_KEY, SPLASH_PROGRESS_TEXT_ID); }

Target:
public AbsolutePositionProgressMonitorPart(Composite parent) { super(parent, null); setLayout(null); setCSSData(); }
Source:
public static ModelNode validateOperation(ModelNode operation) { ModelNode responseNode = new ModelNode(); StringBuilder errors = new StringBuilder(); if (!operation.hasDefined(OP) || operation.get(OP).asString() == null || operation.get(OP).asString().isEmpty()) { errors.append(ControllerLogger.ROOT_LOGGER.noOperationDefined(operation)); } if (operation.hasDefined(OP_ADDR)) { try { operation.get(OP_ADDR).asList(); } catch (IllegalArgumentException ex) { try { ModelNode address = parseAddress(operation.get(OP_ADDR).asString()); operation.get(OP_ADDR).set(address); } catch (IllegalArgumentException iaex) { if (errors.length() > 0) { errors.append(System.lineSeparator()); } errors.append(ControllerLogger.ROOT_LOGGER.attributeIsWrongType(OP_ADDR, ModelType.LIST, operation.get(OP_ADDR).getType()).getMessage()); } } } if (errors.length() > 0) { responseNode.get(OUTCOME).set(FAILED); responseNode.get(FAILURE_DESCRIPTION).set(errors.toString()); } return responseNode; }

Target:
public static ModelNode validateOperation(ModelNode operation) { ModelNode responseNode = new ModelNode(); StringBuilder errors = new StringBuilder(); if (!operation.hasDefined(OP) || operation.get(OP).asString() == null || operation.get(OP).asString().isEmpty()) { errors.append(ControllerLogger.ROOT_LOGGER.noOperationDefined(operation)); } if (operation.hasDefined(OP_ADDR)) { try { if(operation.get(OP_ADDR).getType() == ModelType.STRING) { ModelNode address = PathAddress.parseCLIStyleAddress(operation.get(OP_ADDR).asString()).toModelNode(); operation.get(OP_ADDR).set(address); } else { operation.get(OP_ADDR).asList(); } } catch (IllegalArgumentException ex) { if (errors.length() > 0) { errors.append(System.lineSeparator()); } if(ex.getMessage() != null) { errors.append(ex.getMessage()); } else { errors.append(ControllerLogger.ROOT_LOGGER.attributeIsWrongType(OP_ADDR, ModelType.LIST, operation.get(OP_ADDR).getType()).getMessage()); } } } if (errors.length() > 0) { responseNode.get(OUTCOME).set(FAILED); responseNode.get(FAILURE_DESCRIPTION).set(errors.toString()); } return responseNode; }
Source:
private void deleteButtons() { if (this.getButton(BUTTON_REPLY_ID) != null) { Button button = (this.getButton(BUTTON_REPLY_ID)); button.dispose(); } if (this.getButton(BUTTON_REPLY_DONE_ID) != null) { Button button = (this.getButton(BUTTON_REPLY_DONE_ID)); button.dispose(); } if (this.getButton(BUTTON_DISCARD_ID) != null) { Button button = (this.getButton(BUTTON_DISCARD_ID)); button.dispose(); } if (this.getButton(BUTTON_EDIT_ID) != null) { Button button = (this.getButton(BUTTON_EDIT_ID)); button.dispose(); } if (this.getButton(BUTTON_SAVE_ID) != null) { Button button = (this.getButton(BUTTON_SAVE_ID)); button.dispose(); } fCommentInputTextField.setEnabled(false); }

Target:
private void deleteButtons() { for (int buttonId : new int[] { BUTTON_REPLY_ID, BUTTON_REPLY_DONE_ID, BUTTON_DISCARD_ID, BUTTON_EDIT_ID, BUTTON_SAVE_ID }) { Button button = getButton(buttonId); if (button != null) { button.dispose(); } } fCommentInputTextField.setEnabled(false); }
Source:
public WagedRebalancer(AssignmentMetadataStore assignmentMetadataStore, RebalanceAlgorithm algorithm, MetricCollector metricCollector) throws JMException { this(assignmentMetadataStore, algorithm, new DelayedAutoRebalancer(), metricCollector); }

Target:
protected WagedRebalancer(AssignmentMetadataStore assignmentMetadataStore, RebalanceAlgorithm algorithm, MetricCollector metricCollector) { this(assignmentMetadataStore, algorithm, new DelayedAutoRebalancer(), null, metricCollector); }
Source:
public void accumulateSerializedRowSizes(int[] serializedRowSizes) { for (int i = 0; i < positionCount; i++) { serializedRowSizes[i] += POSITION_SIZE; } offsetsCopy = ensureCapacityWithAllocator(offsetsCopy, positionCount + 1, SMALL, NONE, allocator); System.arraycopy(offsets, 0, offsetsCopy, 0, positionCount + 1); ((AbstractBlockEncodingBuffer) valuesBuffers).accumulateSerializedRowSizes(offsetsCopy, positionCount, serializedRowSizes); allocator.returnArray(offsetsCopy); offsetsCopy = null; }

Target:
public void accumulateSerializedRowSizes(int[] serializedRowSizes) { for (int i = 0; i < positionCount; i++) { serializedRowSizes[i] += POSITION_SIZE; } int[] offsetsCopy = ensureCapacity(null, positionCount + 1, SMALL, NONE, bufferAllocator); try { System.arraycopy(offsets, 0, offsetsCopy, 0, positionCount + 1); ((AbstractBlockEncodingBuffer) valuesBuffers).accumulateSerializedRowSizes(offsetsCopy, positionCount, serializedRowSizes); } finally { bufferAllocator.returnArray(offsetsCopy); } }
Source:
private int smcReadKey(String key, SMCVal val, int retries) { SMCKeyData inputStructure = new SMCKeyData(); SMCKeyData outputStructure = new SMCKeyData(); inputStructure.key = strtoul16(key, 4); int result; do { Util.sleep(8); result = smcGetKeyInfo(inputStructure, outputStructure); if (result != 0) { continue; } val.dataSize = outputStructure.keyInfo.dataSize; val.dataType = new byte[5]; for (int i = 3; i >= 0; i--) { val.dataType[i] = (byte) (outputStructure.keyInfo.dataType >> (8 * (3 - i))); } inputStructure.keyInfo.dataSize = val.dataSize; inputStructure.data8 = IOKit.SMC_CMD_READ_BYTES; result = smcCall(IOKit.KERNEL_INDEX_SMC, inputStructure, outputStructure); if (result != 0) { continue; } } while (retries-- > 0); if (result != 0) { return result; } System.arraycopy(outputStructure.bytes, 0, val.bytes, 0, val.bytes.length); return 0; }

Target:
private int smcReadKey(String key, SMCVal val, int retries) { SMCKeyData inputStructure = new SMCKeyData(); SMCKeyData outputStructure = new SMCKeyData(); inputStructure.key = strtoul16(key, 4); int result; do { result = smcGetKeyInfo(inputStructure, outputStructure); if (result != 0) { continue; } val.dataSize = outputStructure.keyInfo.dataSize; val.dataType = new byte[5]; for (int i = 3; i >= 0; i--) { val.dataType[i] = (byte) (outputStructure.keyInfo.dataType >> (8 * (3 - i))); } inputStructure.keyInfo.dataSize = val.dataSize; inputStructure.data8 = IOKit.SMC_CMD_READ_BYTES; Util.sleep(4); result = smcCall(IOKit.KERNEL_INDEX_SMC, inputStructure, outputStructure); if (result != 0) { continue; } break; } while (--retries > 0); if (result != 0) { return result; } System.arraycopy(outputStructure.bytes, 0, val.bytes, 0, val.bytes.length); return 0; }
Source:
public void run() { while (true) { updateTraceEntry(fTimeAnalysisEntry, Long.MAX_VALUE, fRange.getStartTime().toNanos(), fRange.getEndTime().toNanos()); synchronized (fProcessTraceThreads) { if (fRestart) { fRestart = false; } else { fProcessTraceThreads.remove(fTimeAnalysisEntry.getTrace()); break; } } } }

Target:
public void run() { while (true) { updateTraceEntry(fTimeAnalysisEntry, Long.MAX_VALUE, fRange.getStartTime().toNanos(), fRange.getEndTime().toNanos()); synchronized (fProcessTraceThreads) { if (fRestart) { fRestart = false; } else { fProcessTraceThreads.remove(fTimeAnalysisEntry.getTrace()); return; } } } }
Source:
public Response getFieldTypes(@Context final HttpServletRequest req) throws DotDataException, DotSecurityException { final InitDataObject initData = this.webResource.init(null, true, req, true, null); User user = initData.getUser(); return Response.ok( new ResponseEntityView( fieldTypeFactory.getFieldTypes(user) ) ).build(); }

Target:
public Response getFieldTypes(@Context final HttpServletRequest req) { final InitDataObject initData = this.webResource.init(null, true, req, true, null); User user = initData.getUser(); return Response.ok( new ResponseEntityView( fieldTypeAPI.getFieldTypes(user) ) ).build(); }
Source:
protected void updateBricksWithTaskID(GlusterAsyncTask asyncTask) { for (GlusterBrickEntity brickEntity : getParameters().getBricks()) { getGlusterBrickDao().updateBrickTask(brickEntity.getId(), asyncTask.getTaskId()); } getGlusterVolumeDao().updateVolumeTask(getGlusterVolumeId(), asyncTask.getTaskId()); }

Target:
protected void updateBricksWithTaskID(GlusterAsyncTask asyncTask) { for (GlusterBrickEntity brickEntity : getParameters().getBricks()) { brickEntity.getAsyncTask().setTaskId(asyncTask.getTaskId()); } getGlusterBrickDao().updateBrickTasksInBatch(getParameters().getBricks()); getGlusterVolumeDao().updateVolumeTask(getGlusterVolumeId(), asyncTask.getTaskId()); }
Source:
private HiveDruidSplit[] getInputSplits(Configuration conf) throws IOException { String address = conf.get(Constants.DRUID_ADDRESS); if (StringUtils.isEmpty(address)) { address = HiveConf.getVar(conf, HiveConf.ConfVars.HIVE_DRUID_DEFAULT_ADDRESS); if (StringUtils.isEmpty(address)) { throw new IOException("Druid address not specified; use " + Constants.DRUID_ADDRESS + " in table properties or specify a default address" + " in your configuration files"); } } String druidQuery = StringEscapeUtils.unescapeJava(conf.get(Constants.DRUID_QUERY_JSON)); String druidQueryType; if (StringUtils.isEmpty(druidQuery)) { if (LOG.isWarnEnabled()) { LOG.warn("Druid query is empty; creating Select query"); } String dataSource = conf.get(Constants.DRUID_DATA_SOURCE); if (dataSource == null) { throw new IOException("Druid data source cannot be empty"); } druidQuery = createSelectStarQuery(address, dataSource); druidQueryType = Query.SELECT; } else { druidQueryType = conf.get(Constants.DRUID_QUERY_TYPE); if (druidQueryType == null) { throw new IOException("Druid query type not recognized"); } } Job job = new Job(conf); JobContext jobContext = ShimLoader.getHadoopShims().newJobContext(job); Path paths = FileInputFormat.getInputPaths(jobContext); switch (druidQueryType) { case Query.TIMESERIES: case Query.TOPN: case Query.GROUP_BY: return new HiveDruidSplit[] { new HiveDruidSplit(address, druidQuery, paths[0]) }; case Query.SELECT: return splitSelectQuery(conf, address, druidQuery, paths[0]); default: throw new IOException("Druid query type not recognized"); } }

Target:
private HiveDruidSplit[] getInputSplits(Configuration conf) throws IOException { String address = HiveConf.getVar(conf, HiveConf.ConfVars.HIVE_DRUID_BROKER_DEFAULT_ADDRESS); if (StringUtils.isEmpty(address)) { throw new IOException("Druid broker address not specified in configuration"); } String druidQuery = StringEscapeUtils.unescapeJava(conf.get(Constants.DRUID_QUERY_JSON)); String druidQueryType; if (StringUtils.isEmpty(druidQuery)) { if (LOG.isWarnEnabled()) { LOG.warn("Druid query is empty; creating Select query"); } String dataSource = conf.get(Constants.DRUID_DATA_SOURCE); if (dataSource == null) { throw new IOException("Druid data source cannot be empty"); } druidQuery = createSelectStarQuery(address, dataSource); druidQueryType = Query.SELECT; } else { druidQueryType = conf.get(Constants.DRUID_QUERY_TYPE); if (druidQueryType == null) { throw new IOException("Druid query type not recognized"); } } Job job = new Job(conf); JobContext jobContext = ShimLoader.getHadoopShims().newJobContext(job); Path paths = FileInputFormat.getInputPaths(jobContext); switch (druidQueryType) { case Query.TIMESERIES: case Query.TOPN: case Query.GROUP_BY: return new HiveDruidSplit[] { new HiveDruidSplit(address, druidQuery, paths[0]) }; case Query.SELECT: return splitSelectQuery(conf, address, druidQuery, paths[0]); default: throw new IOException("Druid query type not recognized"); } }
Source:
public Map<String, String> getLanguages(@QueryParam("token") String authToken, @Context ServletContext servletContext) throws GuacamoleException { Set<String> resourcePaths = servletContext.getResourcePaths(TRANSLATION_PATHS); if (resourcePaths == null) return Collections.EMPTY_MAP; Map<String, String> languageMap = new HashMap<String, String>(); for(String resourcePath : resourcePaths) { InputStream languageFileStream = servletContext.getResourceAsStream(resourcePath); if (languageFileStream == null) { logger.warn("Unable to read language resource \"{}\"", resourcePath); continue; } try { String languageKey; Matcher languageKeyMatcher = LANGUAGE_KEY_PATTERN.matcher(resourcePath); if (!languageKeyMatcher.matches() || (languageKey = languageKeyMatcher.group(1)) == null) { logger.warn("Invalid language file name: \"{}\"", resourcePath); continue; } JsonNode tree = mapper.readTree(languageFileStream); JsonNode nameNode = tree.get(LANGUAGE_DISPLAY_NAME_KEY); String languageName; if (nameNode == null || (languageName = nameNode.getTextValue()) == null) { logger.warn("Root-level \"" + LANGUAGE_DISPLAY_NAME_KEY + "\" string missing or invalid in language file \"{}\"", resourcePath); languageName = languageKey; } languageMap.put(languageKey, languageName); } catch (IOException e) { logger.warn("Unable to read language resource \"{}\": {}", resourcePath, e.getMessage()); logger.debug("Error while reading language resource.", e); } } return languageMap; }

Target:
public Map<String, String> getLanguages(@QueryParam("token") String authToken, @Context ServletContext servletContext) throws GuacamoleException { Set<String> resourcePaths = servletContext.getResourcePaths(TRANSLATION_PATH); if (resourcePaths == null) return Collections.EMPTY_MAP; Map<String, String> languageMap = new HashMap<String, String>(); for (String resourcePath : resourcePaths) { InputStream languageFileStream = servletContext.getResourceAsStream(resourcePath); if (languageFileStream == null) { logger.warn("Unable to read language resource \"{}\"", resourcePath); continue; } try { String languageKey; Matcher languageKeyMatcher = LANGUAGE_KEY_PATTERN.matcher(resourcePath); if (!languageKeyMatcher.matches() || (languageKey = languageKeyMatcher.group(1)) == null) { logger.warn("Invalid language file name: \"{}\"", resourcePath); continue; } JsonNode tree = mapper.readTree(languageFileStream); JsonNode nameNode = tree.get(LANGUAGE_DISPLAY_NAME_KEY); String languageName; if (nameNode == null || (languageName = nameNode.getTextValue()) == null) { logger.warn("Root-level \"" + LANGUAGE_DISPLAY_NAME_KEY + "\" string missing or invalid in language file \"{}\"", resourcePath); languageName = languageKey; } languageMap.put(languageKey, languageName); } catch (IOException e) { logger.warn("Unable to read language resource \"{}\": {}", resourcePath, e.getMessage()); logger.debug("Error while reading language resource.", e); } } return languageMap; }
Source:
public List<String> getExecuteBeforeIDs() { Rules ann = this.getClass().getAnnotation(Rules.class); if(ann != null) return Arrays.asList(ann.beforeIDs()); else return Collections.emptyList(); }

Target:
public List<String> getExecuteBeforeIDs() { Rules rulesAnnotation = this.getClass().getAnnotation(Rules.class); if(rulesAnnotation != null) return Arrays.asList(rulesAnnotation.beforeIDs()); else return Collections.emptyList(); }
Source:
public JobExecutionListener loggingListener() { return new LoggingListener(); }

Target:
public LoggingListener loggingListener() { return new LoggingListener(); }
Source:
public final XmlStringBuilder toXML() { XmlStringBuilder buf = new XmlStringBuilder(); buf.halfOpenElement(IQ_ELEMENT); addCommonAttributes(buf); addCustomAttributes(buf); if (type == null) { buf.attribute("type", "get"); } else { buf.attribute("type", type.toString()); } buf.rightAngleBracket(); buf.append(getChildElementXML()); buf.closeElement(IQ_ELEMENT); return buf; }

Target:
public final XmlStringBuilder toXML() { XmlStringBuilder buf = new XmlStringBuilder(); buf.halfOpenElement(IQ_ELEMENT); addAttributes(buf); if (type == null) { buf.attribute("type", "get"); } else { buf.attribute("type", type.toString()); } buf.rightAngleBracket(); buf.append(getChildElementXML()); buf.closeElement(IQ_ELEMENT); return buf; }
Source:
void performSubmit(Action action, boolean dismissFailed) { if (pausedTags.contains(action.getTag())) { pausedActions.put(action.getTarget(), action); if (action.picasso.loggingEnabled) { log(OWNER_DISPATCHER, VERB_PAUSED, action.request.logId(), "because tag '" + action.getTag() + "' is paused"); } return; } BitmapHunter hunter = hunterMap.get(action.request.key); if (hunter != null) { hunter.attach(action); return; } if (service.isShutdown()) { if (action.picasso.loggingEnabled) { log(OWNER_DISPATCHER, VERB_IGNORED, action.request.logId(), "because shut down"); } return; } hunter = BitmapHunter.Companion.forRequest(action.picasso, this, cache, action); hunter.setFuture(service.submit(hunter)); hunterMap.put(action.request.key, hunter); if (dismissFailed) { failedActions.remove(action.getTarget()); } if (action.picasso.loggingEnabled) { log(OWNER_DISPATCHER, VERB_ENQUEUED, action.request.logId()); } }

Target:
void performSubmit(Action action, boolean dismissFailed) { if (pausedTags.contains(action.getTag())) { pausedActions.put(action.getTarget(), action); if (action.picasso.loggingEnabled) { log(OWNER_DISPATCHER, VERB_PAUSED, action.request.logId(), "because tag '" + action.getTag() + "' is paused"); } return; } BitmapHunter hunter = hunterMap.get(action.request.key); if (hunter != null) { hunter.attach(action); return; } if (service.isShutdown()) { if (action.picasso.loggingEnabled) { log(OWNER_DISPATCHER, VERB_IGNORED, action.request.logId(), "because shut down"); } return; } hunter = forRequest(action.picasso, this, cache, action); hunter.future = service.submit(hunter); hunterMap.put(action.request.key, hunter); if (dismissFailed) { failedActions.remove(action.getTarget()); } if (action.picasso.loggingEnabled) { log(OWNER_DISPATCHER, VERB_ENQUEUED, action.request.logId()); } }
Source:
private static BlockInStream createGrpcBlockInStream(FileSystemContext context, WorkerNetAddress address, BlockInStreamSource blockSource, ReadRequest readRequestPartial, long blockSize, InStreamOptions options) { ReadRequest.Builder readRequestBuilder = readRequestPartial.toBuilder(); long chunkSize = context.getClusterConf().getBytes( PropertyKey.USER_STREAMING_READER_CHUNK_SIZE_BYTES); readRequestBuilder.setChunkSize(chunkSize); DataReader.Factory factory; if (context.getClusterConf().getBoolean(PropertyKey.FUSE_SHARED_CACHING_READER_ENABLED) && (blockSize > (chunkSize * 4))) { factory = new SharedGrpcDataReader .Factory(context, address, readRequestBuilder.build(), blockSize); } else { factory = new GrpcDataReader.Factory(context, address, readRequestBuilder.build()); } return new BlockInStream(context, factory, address, blockSource, readRequestPartial.getBlockId(), blockSize); }

Target:
private static BlockInStream createGrpcBlockInStream(FileSystemContext context, WorkerNetAddress address, BlockInStreamSource blockSource, ReadRequest readRequestPartial, long blockSize, InStreamOptions options) { ReadRequest.Builder readRequestBuilder = readRequestPartial.toBuilder(); long chunkSize = context.getClusterConf().getBytes( PropertyKey.USER_STREAMING_READER_CHUNK_SIZE_BYTES); readRequestBuilder.setChunkSize(chunkSize); DataReader.Factory factory; if (context.getClusterConf().getBoolean(PropertyKey.FUSE_SHARED_CACHING_READER_ENABLED) && blockSize > chunkSize * 4) { factory = new SharedGrpcDataReader .Factory(context, address, readRequestBuilder.build(), blockSize); } else { factory = new GrpcDataReader.Factory(context, address, readRequestBuilder.build()); } return new BlockInStream(factory, address, blockSource, readRequestPartial.getBlockId(), blockSize); }
Source:
public void should_fail_if_peer_does_not_support_v3() { thrown.expect(IllegalArgumentException.class); thrown.expectMessage( "reports Cassandra version 2.0.9, but the driver only supports 2.1.0 and above"); try (BoundCluster simulacron = mixedVersions("3.0.0", "2.0.9", "3.11"); BoundNode contactPoint = simulacron.node(0); Cluster ignored = Cluster.builder() .addContactPoint(contactPoint.inetSocketAddress()) .withConfigLoader(new TestConfigLoader()) .build()) { fail("Cluster init should have failed"); } }

Target:
public void should_fail_if_peer_does_not_support_v3() { thrown.expect(UnsupportedProtocolVersionException.class); thrown.expectMessage( "reports Cassandra version 2.0.9, but the driver only supports 2.1.0 and above"); try (BoundCluster simulacron = mixedVersions("3.0.0", "2.0.9", "3.11"); BoundNode contactPoint = simulacron.node(0); Cluster ignored = Cluster.builder() .addContactPoint(contactPoint.inetSocketAddress()) .withConfigLoader(new TestConfigLoader()) .build()) { fail("Cluster init should have failed"); } }
Source:
private void createTable(int style) { fTable = new Table(this, style | SWT.NO_SCROLL); fTable.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { handleTableSelection(event); } }); fTable.addKeyListener(new KeyListener() { @Override public void keyPressed(KeyEvent event) { handleTableKeyEvent(event); } @Override public void keyReleased(KeyEvent event) { } }); fTable.addListener( SWT.MouseDoubleClick, new Listener() { @Override public void handleEvent(Event event) { if (doubleClickListener != null) { TableItem item = fTable.getItem (new Point (event.x, event.y)); if (item != null) { for(int i=0;i<fTable.getColumnCount();i++){ Rectangle bounds = item.getBounds(i); if (bounds.contains(event.x,event.y)){ doubleClickListener.handleDoubleClick(TmfVirtualTable.this, item, i); break; } } } } } } ); fTable.addPaintListener(new PaintListener() { @Override public void paintControl(PaintEvent e) { if (fTable.getTopIndex() != 0 || fResetTopIndex) { fTable.setTopIndex(0); } fResetTopIndex = false; } }); }

Target:
private void createTable(int style) { fTable = new Table(this, style | SWT.NO_SCROLL); fTable.addMouseListener(new MouseAdapter() { @Override public void mouseDown(MouseEvent e) { handleTableMouseEvent(e); } }); fTable.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent event) { handleTableKeyEvent(event); } }); fTable.addListener( SWT.MouseDoubleClick, new Listener() { @Override public void handleEvent(Event event) { if (doubleClickListener != null) { TableItem item = fTable.getItem (new Point (event.x, event.y)); if (item != null) { for(int i=0;i<fTable.getColumnCount();i++){ Rectangle bounds = item.getBounds(i); if (bounds.contains(event.x,event.y)){ doubleClickListener.handleDoubleClick(TmfVirtualTable.this, item, i); break; } } } } } } ); fTable.addPaintListener(new PaintListener() { @Override public void paintControl(PaintEvent e) { if (fTable.getTopIndex() != 0 || fResetTopIndex) { fTable.setTopIndex(0); } fResetTopIndex = false; } }); }