auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
public void commit() throws DockerException, InterruptedException { assumeNotSwarm("", dockerRule); CreateContainerResponse container = dockerRule.getClient().createContainerCmd(DEFAULT_IMAGE) .withCmd("touch", "/test") .exec(); LOG.info("Created container: {}", container.toString()); assertThat(container.getId(), not(isEmptyString())); dockerRule.getClient().startContainerCmd(container.getId()).exec(); LOG.info("Committing container: {}", container.toString()); String imageId = dockerRule.getClient().commitCmd(container.getId()).exec(); wait(5000); InspectImageResponse inspectImageResponse = dockerRule.getClient().inspectImageCmd(imageId).exec(); LOG.info("Image Inspect: {}", inspectImageResponse.toString()); assertThat(inspectImageResponse, hasField("container", startsWith(container.getId()))); assertThat(inspectImageResponse.getContainerConfig().getImage(), equalTo(DEFAULT_IMAGE)); InspectImageResponse busyboxImg = dockerRule.getClient().inspectImageCmd("busybox").exec(); assertThat(inspectImageResponse.getParent(), equalTo(busyboxImg.getId())); }

Target:
public void commit() throws DockerException, InterruptedException { CreateContainerResponse container = dockerRule.getClient().createContainerCmd(DEFAULT_IMAGE) .withCmd("touch", "/test") .exec(); LOG.info("Created container: {}", container.toString()); assertThat(container.getId(), not(isEmptyString())); dockerRule.getClient().startContainerCmd(container.getId()).exec(); LOG.info("Committing container: {}", container.toString()); String imageId = dockerRule.getClient().commitCmd(container.getId()).exec(); synchronized (this) { wait(5000); } InspectImageResponse inspectImageResponse = dockerRule.getClient().inspectImageCmd(imageId).exec(); LOG.info("Image Inspect: {}", inspectImageResponse.toString()); assertThat(inspectImageResponse, hasField("container", startsWith(container.getId()))); assertThat(inspectImageResponse.getContainerConfig().getImage(), equalTo(DEFAULT_IMAGE)); InspectImageResponse busyboxImg = dockerRule.getClient().inspectImageCmd("busybox").exec(); assertThat(inspectImageResponse.getParent(), equalTo(busyboxImg.getId())); }
Source:
public static <M extends Message> M getMessage(Failure failure) { checkNotNull(failure); final M result = AnyPacker.unpack(failure.getMessage()); return result; }

Target:
public static <M extends Message> M getMessage(Failure failure) { checkNotNull(failure); final M result = unpack(failure.getMessage()); return result; }
Source:
protected View inflate(LayoutInflater layoutInflater, ViewGroup viewGroup) { View inflatedView = layoutInflater.inflate(R.layout.item_notification, viewGroup, false); ButterKnife.bind(this, inflatedView); if (NotificationActivity.isarchivedvisible) { swipeLayout.setSwipeEnabled(false); }else { swipeLayout.setSwipeEnabled(true); } swipeLayout.addDrag(SwipeLayout.DragEdge.Top, bottomLayout); swipeLayout.addRevealListener(R.id.bottom_wrapper_child1, (child, edge, fraction, distance) -> { View star = child.findViewById(R.id.star); float d = child.getHeight() / 2 - star.getHeight() / 2; ViewHelper.setTranslationY(star, d * fraction); ViewHelper.setScaleX(star, fraction + 0.6f); ViewHelper.setScaleY(star, fraction + 0.6f); int c = (Integer) evaluate(fraction, Color.parseColor("#dddddd"), Color.parseColor("#90960a0a")); child.setBackgroundColor(c); }); return inflatedView; }

Target:
protected View inflate(LayoutInflater layoutInflater, ViewGroup viewGroup) { View inflatedView = layoutInflater.inflate(R.layout.item_notification, viewGroup, false); ButterKnife.bind(this, inflatedView); if (isarchivedvisible) { swipeLayout.setSwipeEnabled(false); }else { swipeLayout.setSwipeEnabled(true); } swipeLayout.addDrag(SwipeLayout.DragEdge.Top, bottomLayout); swipeLayout.addRevealListener(R.id.bottom_wrapper_child1, (child, edge, fraction, distance) -> { View star = child.findViewById(R.id.star); float d = child.getHeight() / 2 - star.getHeight() / 2; ViewHelper.setTranslationY(star, d * fraction); ViewHelper.setScaleX(star, fraction + 0.6f); ViewHelper.setScaleY(star, fraction + 0.6f); int c = (Integer) evaluate(fraction, Color.parseColor("#dddddd"), Color.parseColor("#90960a0a")); child.setBackgroundColor(c); }); return inflatedView; }
Source:
public void endTask() { assert lastWork == totalWork : "Recorded " + lastWork + " units of work where "+totalWork+" were planned"; }

Target:
public void endTask() { assertEquals("Units of work recorded", totalWork, lastWork); }
Source:
public CouchClient(CouchConfig config) { this.jsonHelper = new JSONHelper(); this.uriHelper = new CouchURIHelper(config.getRootUri()); this.customHeaders = config.getCustomHeaders(); this.requestFilters = config.getRequestFilters(); this.responseFilters = config.getResponseFilters(); }

Target:
public CouchClient(CouchConfig config) { this.jsonHelper = new JSONHelper(); this.uriHelper = new CouchURIHelper(config.getRootUri()); this.customHeaders = config.getCustomHeaders(); this.requestFilters = new ArrayList<HttpConnectionRequestFilter>(); this.responseFilters = new ArrayList<HttpConnectionResponseFilter>(); if(config.getRequestFilters() != null) { this.requestFilters.addAll(config.getRequestFilters()); } if(config.getResponseFilters() != null) { this.responseFilters.addAll(config.getResponseFilters()); } }
Source:
public static void main(String[] args) { assertEquals(0, $noinline$div(1)); assertEquals(1, $noinline$rem(1)); assertEquals(0, $noinline$div(-1)); assertEquals(-1, $noinline$rem(-1)); assertEquals(0, $noinline$div(0)); assertEquals(0, $noinline$rem(0)); assertEquals(1, $noinline$div(Integer.MIN_VALUE)); assertEquals(0, $noinline$rem(Integer.MIN_VALUE)); assertEquals(0, $noinline$div(Integer.MAX_VALUE)); assertEquals(Integer.MAX_VALUE, $noinline$rem(Integer.MAX_VALUE)); assertEquals(0, $noinline$div(Integer.MAX_VALUE - 1)); assertEquals(Integer.MAX_VALUE - 1, $noinline$rem(Integer.MAX_VALUE - 1)); assertEquals(0, $noinline$div(Integer.MIN_VALUE + 1)); assertEquals(Integer.MIN_VALUE + 1, $noinline$rem(Integer.MIN_VALUE + 1)); assertEquals(0L, $noinline$div(1)); assertEquals(1L, $noinline$rem(1)); assertEquals(0L, $noinline$div(-1)); assertEquals(-1L, $noinline$rem(-1)); assertEquals(0L, $noinline$div(0)); assertEquals(0L, $noinline$rem(0)); assertEquals(1L, $noinline$div(Long.MIN_VALUE)); assertEquals(0L, $noinline$rem(Long.MIN_VALUE)); assertEquals(0L, $noinline$div(Long.MAX_VALUE)); assertEquals(Long.MAX_VALUE, $noinline$rem(Long.MAX_VALUE)); assertEquals(0L, $noinline$div(Long.MAX_VALUE - 1)); assertEquals(Long.MAX_VALUE - 1, $noinline$rem(Long.MAX_VALUE - 1)); assertEquals(0L, $noinline$div(Integer.MIN_VALUE + 1)); assertEquals(Long.MIN_VALUE + 1, $noinline$rem(Long.MIN_VALUE + 1)); }

Target:
public static void main(String[] args) { assertEquals(0, $noinline$divInt(1)); assertEquals(1, $noinline$remInt(1)); assertEquals(0, $noinline$divInt(-1)); assertEquals(-1, $noinline$remInt(-1)); assertEquals(0, $noinline$divInt(0)); assertEquals(0, $noinline$remInt(0)); assertEquals(1, $noinline$divInt(Integer.MIN_VALUE)); assertEquals(0, $noinline$remInt(Integer.MIN_VALUE)); assertEquals(0, $noinline$divInt(Integer.MAX_VALUE)); assertEquals(Integer.MAX_VALUE, $noinline$remInt(Integer.MAX_VALUE)); assertEquals(0, $noinline$divInt(Integer.MAX_VALUE - 1)); assertEquals(Integer.MAX_VALUE - 1, $noinline$remInt(Integer.MAX_VALUE - 1)); assertEquals(0, $noinline$divInt(Integer.MIN_VALUE + 1)); assertEquals(Integer.MIN_VALUE + 1, $noinline$remInt(Integer.MIN_VALUE + 1)); assertEquals(0L, $noinline$divLong(1L)); assertEquals(1L, $noinline$remLong(1L)); assertEquals(0L, $noinline$divLong(-1L)); assertEquals(-1L, $noinline$remLong(-1L)); assertEquals(0L, $noinline$divLong(0L)); assertEquals(0L, $noinline$remLong(0L)); assertEquals(1L, $noinline$divLong(Long.MIN_VALUE)); assertEquals(0L, $noinline$remLong(Long.MIN_VALUE)); assertEquals(0L, $noinline$divLong(Long.MAX_VALUE)); assertEquals(Long.MAX_VALUE, $noinline$remLong(Long.MAX_VALUE)); assertEquals(0L, $noinline$divLong(Long.MAX_VALUE - 1)); assertEquals(Long.MAX_VALUE - 1, $noinline$remLong(Long.MAX_VALUE - 1)); assertEquals(0L, $noinline$divLong(Integer.MIN_VALUE + 1)); assertEquals(Long.MIN_VALUE + 1, $noinline$remLong(Long.MIN_VALUE + 1)); }
Source:
public ConnectorSplitSource getSplits(ConnectorTransactionHandle transactionHandle, ConnectorSession session, ConnectorTableLayoutHandle layout, SplitSchedulingStrategy splitSchedulingStrategy) { SystemTableLayoutHandle layoutHandle = (SystemTableLayoutHandle) layout; SystemTableHandle tableHandle = layoutHandle.getTable(); TupleDomain<ColumnHandle> constraint = layoutHandle.getConstraint(); SystemTable systemTable = tables.getSystemTable(session, tableHandle.getSchemaTableName()).orElseThrow(() -> new IllegalArgumentException("no table found for " + tableHandle)); Distribution tableDistributionMode = systemTable.getDistribution(); if (tableDistributionMode == SINGLE_COORDINATOR) { HostAddress address = nodeManager.getCurrentNode().getHostAndPort(); ConnectorSplit split = new SystemSplit(tableHandle.getConnectorId(), tableHandle, address, constraint); return new FixedSplitSource(ImmutableList.of(split)); } ImmutableList.Builder<ConnectorSplit> splits = ImmutableList.builder(); ImmutableSet.Builder<Node> nodes = ImmutableSet.builder(); if (tableDistributionMode == ALL_COORDINATORS) { nodes.addAll(nodeManager.getCoordinators()); } else if (tableDistributionMode == ALL_NODES) { nodes.addAll(nodeManager.getNodes(ACTIVE)); } Set<Node> nodeSet = nodes.build(); for (Node node : nodeSet) { splits.add(new SystemSplit(tableHandle.getConnectorId(), tableHandle, node.getHostAndPort(), constraint)); } return new FixedSplitSource(splits.build()); }

Target:
public ConnectorSplitSource getSplits(ConnectorTransactionHandle transactionHandle, ConnectorSession session, ConnectorTableLayoutHandle layout, SplitSchedulingStrategy splitSchedulingStrategy) { SystemTableLayoutHandle layoutHandle = (SystemTableLayoutHandle) layout; SystemTableHandle tableHandle = layoutHandle.getTable(); TupleDomain<ColumnHandle> constraint = layoutHandle.getConstraint(); SystemTable systemTable = tables.getSystemTable(session, tableHandle.getSchemaTableName()) .orElseThrow(() -> new PrestoException(NOT_FOUND, format("Table %s not found", tableHandle.getSchemaTableName()))); Distribution tableDistributionMode = systemTable.getDistribution(); if (tableDistributionMode == SINGLE_COORDINATOR) { HostAddress address = nodeManager.getCurrentNode().getHostAndPort(); ConnectorSplit split = new SystemSplit(tableHandle.getConnectorId(), tableHandle, address, constraint); return new FixedSplitSource(ImmutableList.of(split)); } ImmutableList.Builder<ConnectorSplit> splits = ImmutableList.builder(); ImmutableSet.Builder<Node> nodes = ImmutableSet.builder(); if (tableDistributionMode == ALL_COORDINATORS) { nodes.addAll(nodeManager.getCoordinators()); } else if (tableDistributionMode == ALL_NODES) { nodes.addAll(nodeManager.getNodes(ACTIVE)); } Set<Node> nodeSet = nodes.build(); for (Node node : nodeSet) { splits.add(new SystemSplit(tableHandle.getConnectorId(), tableHandle, node.getHostAndPort(), constraint)); } return new FixedSplitSource(splits.build()); }
Source:
public void incrementCount() { this.count++; }

Target:
private void incrementCount() { this.count++; }
Source:
private void upgradeTo8Dot2() { LayoutSyncManager.getInstance().getSmartStore().dropAllSoups(); LayoutSyncManager.reset(); }

Target:
private void upgradeTo8Dot2() { LayoutSyncManager.getInstance().getSmartStore().dropSoup("sfdcLayouts"); LayoutSyncManager.reset(); }
Source:
private static void setBool(ListBox box, InheritedBoolean val) { if (box != null) { for (int i = 0; i < box.getItemCount(); i++) { if (val.name().equals(box.getValue(i))) { box.setSelectedIndex(i); break; } } } }

Target:
private static void setBool(ListBox box, InheritedBoolean val) { for (int i = 0; i < box.getItemCount(); i++) { if (val.name().equals(box.getValue(i))) { box.setSelectedIndex(i); break; } } }
Source:
private Map<String, TopologyIracVersion> generateNewVectorFunction(Integer s, Map<String, TopologyIracVersion> versions) { if (versions == null) { return Collections.singletonMap(localSite, TopologyIracVersion.newVersion(topologyId)); } else { Map<String, TopologyIracVersion> copy = new HashMap<>(versions); copy.compute(localSite, this::incrementVersionFunction); return Collections.unmodifiableMap(copy); } }

Target:
private Map<String, TopologyIracVersion> generateNewVectorFunction(Integer s, Map<String, TopologyIracVersion> versions) { if (versions == null) { return Collections.singletonMap(localSite, TopologyIracVersion.newVersion(topologyId)); } else { Map<String, TopologyIracVersion> copy = new HashMap<>(versions); copy.compute(localSite, this::incrementVersionFunction); return copy; } }
Source:
public void testRouterClosingOnRequestResponseHandlerThreadException() throws Exception { router = getNonBlockingRouter(); int blobSize = chunkSize * random.nextInt(10) + 1; for (int i = 0; i < 2; i++) { RequestAndResult requestAndResult = new RequestAndResult(blobSize); requestAndResultsList.add(requestAndResult); MockReadableStreamChannel putChannel = new MockReadableStreamChannel(blobSize); requestAndResult.result = (FutureResult<String>) router .putBlob(requestAndResult.putBlobProperties, requestAndResult.putUserMetadata, putChannel, null); } mockSelectorState.set(MockSelectorState.SleepOnPoll); Thread requestResponseHandlerThread = TestUtils.getThreadByThisName("RequestResponseHandlerThread"); requestResponseHandlerThread.interrupt(); while (TestUtils.numThreadsByThisName("RequestResponseHandlerThread") > 0) { Thread.yield(); } for (RequestAndResult requestAndResult : requestAndResultsList) { requestAndResult.result.await(); } Exception expectedException = new RouterException("", RouterErrorCode.RouterClosed); assertFailure(expectedException); Assert.assertEquals("No ChunkFiller Thread should be running after the router is closed", 0, TestUtils.numThreadsByThisName("ChunkFillerThread")); Assert.assertEquals("No RequestResponseHandler should be running after the router is closed", 0, TestUtils.numThreadsByThisName("RequestResponseHandlerThread")); Assert.assertEquals("All operations should have completed", 0, router.getOperationsCount()); }

Target:
public void testRouterClosingOnRequestResponseHandlerThreadException() throws Exception { router = getNonBlockingRouter(); int blobSize = chunkSize * random.nextInt(10) + 1; for (int i = 0; i < 2; i++) { RequestAndResult requestAndResult = new RequestAndResult(blobSize); requestAndResultsList.add(requestAndResult); MockReadableStreamChannel putChannel = new MockReadableStreamChannel(blobSize); requestAndResult.result = (FutureResult<String>) router .putBlob(requestAndResult.putBlobProperties, requestAndResult.putUserMetadata, putChannel, null); } mockSelectorState.set(MockSelectorState.ThrowExceptionOnAllPoll); while (TestUtils.numThreadsByThisName("RequestResponseHandlerThread") > 0) { Thread.yield(); } for (RequestAndResult requestAndResult : requestAndResultsList) { requestAndResult.result.await(); } Exception expectedException = new RouterException("", RouterErrorCode.RouterClosed); assertFailure(expectedException); Assert.assertEquals("No ChunkFiller Thread should be running after the router is closed", 0, TestUtils.numThreadsByThisName("ChunkFillerThread")); Assert.assertEquals("No RequestResponseHandler should be running after the router is closed", 0, TestUtils.numThreadsByThisName("RequestResponseHandlerThread")); Assert.assertEquals("All operations should have completed", 0, router.getOperationsCount()); }
Source:
public Book book() { for(Book b : Book.values()) { if((ctx.varpbits.varpbit(Constants.SPELLBOOK_VARPBIT) & 0x3) == b.varp) return b; } return Book.NIL; }

Target:
public Book book() { int varp = ctx.varpbits.varpbit(Constants.SPELLBOOK_VARPBIT) & 0x3; for(Book b : Book.values()) { if(varp == b.varp) return b; } return Book.NIL; }
Source:
private static boolean isQuotedType(HiveType type) { return QUOTED_TYPES.contains(type.getTypeInfo().getTypeName()); }

Target:
private static boolean isQuotedType(HiveType type) { return QUOTED_TYPES.contains(type.getTypeSignature().getBase()); }
Source:
public void setUp() { context = InstrumentationRegistry.getInstrumentation().getContext(); UserPreferences.init(context); PodDBAdapter.init(context); PodDBAdapter.deleteDatabase(); PodDBAdapter adapter = PodDBAdapter.getInstance(); adapter.open(); adapter.close(); SharedPreferences spref = mock(SharedPreferences.class); when(spref.getString(eq("prefGpodnetHostname"), anyString())).thenReturn("gpodder.net"); Application app = mock(Application.class); when(app.getSharedPreferences(anyString(), anyInt())).thenReturn(spref); ClientConfig.applicationCallbacks = mock(ApplicationCallbacks.class); when(ClientConfig.applicationCallbacks.getApplicationInstance()).thenReturn(app); localFeedDir1 = new File("sampledata/local-feed1"); localFeedDir2 = new File("sampledata/local-feed2"); List<File> files = new ArrayList<>(); Collections.addAll(files, localFeedDir1.listFiles()); Collections.addAll(files, localFeedDir2.listFiles()); for (File file : files) { DataSource ds = DataSource.toDataSource(context, Uri.fromFile(file)); ShadowMediaMetadataRetriever.addMetadata(ds, MediaMetadataRetriever.METADATA_KEY_DURATION, "10"); ShadowMediaMetadataRetriever.addMetadata(ds, MediaMetadataRetriever.METADATA_KEY_TITLE, file.getName()); } shadowOf(MimeTypeMap.getSingleton()).addExtensionMimeTypMapping("mp3", "audio/mp3"); }

Target:
public void setUp() throws Exception { context = InstrumentationRegistry.getInstrumentation().getContext(); UserPreferences.init(context); Application app = (Application) context; ClientConfig.applicationCallbacks = mock(ApplicationCallbacks.class); when(ClientConfig.applicationCallbacks.getApplicationInstance()).thenReturn(app); PodDBAdapter.init(context); PodDBAdapter.deleteDatabase(); PodDBAdapter adapter = PodDBAdapter.getInstance(); adapter.open(); adapter.close(); mapDummyMetadata(LOCAL_FEED_DIR1); mapDummyMetadata(LOCAL_FEED_DIR2); shadowOf(MimeTypeMap.getSingleton()).addExtensionMimeTypMapping("mp3", "audio/mp3"); }
Source:
public void setDisplay(DisplayUnit display) { DisplayData mData = display.evaluate(); setAVT(Localizer.processArguments(display.getText().evaluate(ec), new String[] {""}).trim(), mData.getImageURI()); }

Target:
public void setDisplay(DisplayUnit display) { DisplayData mData = display.evaluate(ec); setAVT(Localizer.processArguments(display.getText().evaluate(ec), new String[] {""}).trim(), mData.getImageURI()); }
Source:
public void reset() { clearPartition(false, false); stats.reset(); mutationObserver.onReset(); }

Target:
public void reset() { clearMapStore(); storage.clear(false); stats.reset(); mutationObserver.onReset(); }
Source:
public void setUp() throws Exception { tmpDir = new File(System.getProperty("java.io.tmpdir") + "/ZeppelinLTest_" + System.currentTimeMillis()); System.setProperty("zeppelin.dep.localrepo", tmpDir.getAbsolutePath() + "/local-repo"); tmpDir.mkdirs(); if (repl == null) { intpGroup = new InterpreterGroup(); intpGroup.put("note", new LinkedList<Interpreter>()); repl = new SparkInterpreter(getSparkTestProperties()); repl.setInterpreterGroup(intpGroup); intpGroup.get("note").add(repl); repl.open(); } final RemoteEventClientWrapper remoteEventClientWrapper = new RemoteEventClientWrapper() { @Override public void onParaInfosReceived(String noteId, String paragraphId, Map<String, String> infos) { if (infos != null) { paraIdToInfosMap.put(paragraphId, infos); } } @Override public void onMetaInfosReceived(Map<String, String> infos) { } }; context = new InterpreterContext("note", "id", null, "title", "text", new AuthenticationInfo(), new HashMap<String, Object>(), new GUI(), new AngularObjectRegistry(intpGroup.getId(), null), new LocalResourcePool("id"), new LinkedList<InterpreterContextRunner>(), new InterpreterOutput(null)) { @Override public RemoteEventClientWrapper getClient() { return remoteEventClientWrapper; } }; repl.interpret("sc", context); }

Target:
public void setUp() throws Exception { if (repl == null) { intpGroup = new InterpreterGroup(); intpGroup.put("note", new LinkedList<Interpreter>()); repl = new SparkInterpreter(getSparkTestProperties(tmpDir)); repl.setInterpreterGroup(intpGroup); intpGroup.get("note").add(repl); repl.open(); } final RemoteEventClientWrapper remoteEventClientWrapper = new RemoteEventClientWrapper() { @Override public void onParaInfosReceived(String noteId, String paragraphId, Map<String, String> infos) { if (infos != null) { paraIdToInfosMap.put(paragraphId, infos); } } @Override public void onMetaInfosReceived(Map<String, String> infos) { } }; context = new InterpreterContext("note", "id", null, "title", "text", new AuthenticationInfo(), new HashMap<String, Object>(), new GUI(), new AngularObjectRegistry(intpGroup.getId(), null), new LocalResourcePool("id"), new LinkedList<InterpreterContextRunner>(), new InterpreterOutput(null)) { @Override public RemoteEventClientWrapper getClient() { return remoteEventClientWrapper; } }; repl.interpret("sc", context); }
Source:
protected boolean validateLeaseStorageDomain(Guid leaseStorageDomainId) { StorageDomain domain = storageDomainDao.get(leaseStorageDomainId); StorageDomainValidator validator = new StorageDomainValidator(domain); if (!validate(validator.isDomainExistAndActive()) || validate(validator.isDataDomain())) { return false; } if (!getStoragePoolId().equals(domain.getStoragePoolId())) { return failValidation(EngineMessage.ACTION_TYPE_FAILED_LEASE_STORAGE_IS_NOT_A_PART_OF_POOL); } return true; }

Target:
protected boolean validateLeaseStorageDomain(Guid leaseStorageDomainId) { StorageDomain domain = storageDomainDao.getForStoragePool(leaseStorageDomainId, getStoragePoolId()); StorageDomainValidator validator = new StorageDomainValidator(domain); if (!validate(validator.isDomainExistAndActive()) || !validate(validator.isDataDomain())) { return false; } return true; }
Source:
public DashboardInfo(String runtimeModelId, Collection<String> pages) { super(); this.runtimeModelId = runtimeModelId; this.pages = pages; }

Target:
public DashboardInfo(String runtimeModelId, Collection<String> pages) { this.runtimeModelId = runtimeModelId; this.pages = pages; }
Source:
protected void executeQueryCommand() { List<VmTemplate> retval = DbFacade.getInstance().getVmTemplateDAO().getAll(getUserID(), getParameters().isFiltered()); for (VmTemplate template : retval) { AnonymousMethod1(template); } getQueryReturnValue().setReturnValue(retval); }

Target:
protected void executeQueryCommand() { List<VmTemplate> retval = getDbFacade().getVmTemplateDAO().getAll(getUserID(), getParameters().isFiltered()); for (VmTemplate template : retval) { AnonymousMethod1(template); } getQueryReturnValue().setReturnValue(retval); }
Source:
public void testWriteToServerOk() throws Exception { HttpConnection conn = new HttpConnection("POST", new URL(dbResource.getDbURIWithUserInfo()), "application/json"); ByteArrayInputStream bis = new ByteArrayInputStream(data.getBytes()); assertEquals(data.getBytes().length, bis.available()); conn.setRequestBody(bis); HttpConnection response = conn.execute(); String responseStr = response.responseAsString(); assertTrue("There should be an ok response: " + responseStr, Pattern.compile("" + ".*\"ok\"\\s*:\\s*true.*", Pattern.DOTALL).matcher(responseStr).matches()); assertEquals(0, bis.available()); assertEquals("Should be a 2XX response code", 2, response.getConnection().getResponseCode () / 100); }

Target:
public void testWriteToServerOk() throws Exception { HttpConnection conn = new HttpConnection("POST", new URL(dbResource.getDbURIWithUserInfo()), "application/json"); ByteArrayInputStream bis = new ByteArrayInputStream(data.getBytes()); assertEquals(data.getBytes().length, bis.available()); conn.setRequestBody(bis); HttpConnection response = conn.execute(); String responseStr = response.responseAsString(); String okPattern = ".*\"ok\"\\s*:\\s*true.*"; assertTrue("There should be an ok response: " + responseStr, Pattern.compile(okPattern, Pattern.DOTALL).matcher(responseStr).matches()); assertEquals(0, bis.available()); assertEquals("Should be a 2XX response code", 2, response.getConnection().getResponseCode () / 100); }
Source:
public BootApplicationConfigurationMetadataResolver(ClassLoader parent) { this.parent = parent; JarFile.registerUrlProtocolHandler(); try { Resource[] globalResources = new PathMatchingResourcePatternResolver( ApplicationConfigurationMetadataResolver.class.getClassLoader()).getResources(WHITELIST_PROPERTIES); if (ObjectUtils.isEmpty(globalResources)) { globalResources = new PathMatchingResourcePatternResolver( ApplicationConfigurationMetadataResolver.class.getClassLoader()) .getResources(WHITELIST_LEGACY_PROPERTIES); } loadWhiteLists(globalResources, globalWhiteListedClasses, globalWhiteListedProperties); } catch (IOException e) { throw new RuntimeException("Error reading global white list of configuration properties", e); } }

Target:
public BootApplicationConfigurationMetadataResolver(ClassLoader parent) { this.parent = parent; JarFile.registerUrlProtocolHandler(); try { Resource[] globalLegacyResources = new PathMatchingResourcePatternResolver( ApplicationConfigurationMetadataResolver.class.getClassLoader()) .getResources(WHITELIST_LEGACY_PROPERTIES); Resource[] globalResources = new PathMatchingResourcePatternResolver( ApplicationConfigurationMetadataResolver.class.getClassLoader()) .getResources(WHITELIST_PROPERTIES); loadWhiteLists(concatArrays(globalLegacyResources, globalResources), globalWhiteListedClasses, globalWhiteListedProperties); } catch (IOException e) { throw new RuntimeException("Error reading global white list of configuration properties", e); } }
Source:
public boolean addAll(Collection<? extends E> c) { boolean changed = false; for (Iterator<? extends E> iterator = c.iterator(); iterator.hasNext();) { E element = iterator.next(); changed |= wrappedSet.add(IdentityWrapper.wrap(element)); } return changed; }

Target:
public boolean addAll(Collection<? extends E> c) { boolean changed = false; for (E element : c) { changed |= wrappedSet.add(IdentityWrapper.wrap(element)); } return changed; }
Source:
private Object[] createChildren(Object element) { if (element instanceof MApplication) { List<MPartDescriptor> descriptors = ((MApplication) element).getDescriptors(); Set<String> categoryTags = new HashSet<String>(); Set<MPartDescriptor> visibleViews = new HashSet<MPartDescriptor>(); for (MPartDescriptor descriptor : descriptors) { if (isFilteredByActivity(descriptor.getElementId())) { continue; } List<String> tags = descriptor.getTags(); String category = null; boolean isView = false; for (String tag : tags) { if (tag.equals("View")) isView = true; else if (tag.startsWith(CATEGORY_TAG)) { category = tag.substring(CATEGORY_TAG_LENGTH); } } if (isView) { if (category != null) { categoryTags.add(category); } else { visibleViews.add(descriptor); } } } Set<Object> combinedTopElements = new HashSet<Object>(); combinedTopElements.addAll(categoryTags); combinedTopElements.addAll(visibleViews); return combinedTopElements.toArray(); } else if (element instanceof String) { List<MPartDescriptor> descriptors = application.getDescriptors(); Set<MPartDescriptor> categoryDescriptors = new HashSet<MPartDescriptor>(); for (MPartDescriptor descriptor : descriptors) { if (isFilteredByActivity(descriptor.getElementId())) { continue; } List<String> tags = descriptor.getTags(); for (String tag : tags) { if (!tag.startsWith(CATEGORY_TAG)) continue; String categoryTag = tag.substring(CATEGORY_TAG_LENGTH); if (element.equals(categoryTag)) categoryDescriptors.add(descriptor); } } return categoryDescriptors.toArray(); } return new Object[0]; }

Target:
private Object[] createChildren(Object element) { if (element instanceof MApplication) { List<MPartDescriptor> descriptors = ((MApplication) element).getDescriptors(); Set<String> categoryTags = new HashSet<String>(); Set<MPartDescriptor> visibleViews = new HashSet<MPartDescriptor>(); for (MPartDescriptor descriptor : descriptors) { if (isFilteredByActivity(descriptor.getElementId())) { continue; } List<String> tags = descriptor.getTags(); String category = null; boolean isView = false; for (String tag : tags) { if (tag.equals("View")) isView = true; else if (tag.startsWith(CATEGORY_TAG)) { category = tag.substring(CATEGORY_TAG_LENGTH); } } if (isView) { if (category != null) { categoryTags.add(category); } else { visibleViews.add(descriptor); } } } Set<Object> combinedTopElements = new HashSet<Object>(); combinedTopElements.addAll(categoryTags); combinedTopElements.addAll(visibleViews); return combinedTopElements.toArray(); } else if (element instanceof String) { List<MPartDescriptor> descriptors = application.getDescriptors(); Set<MPartDescriptor> categoryDescriptors = new HashSet<MPartDescriptor>(); for (MPartDescriptor descriptor : descriptors) { if (isFilteredByActivity(descriptor.getElementId()) || isIntroView(descriptor.getElementId())) { continue; } List<String> tags = descriptor.getTags(); for (String tag : tags) { if (!tag.startsWith(CATEGORY_TAG)) continue; String categoryTag = tag.substring(CATEGORY_TAG_LENGTH); if (element.equals(categoryTag)) categoryDescriptors.add(descriptor); } } return categoryDescriptors.toArray(); } return new Object[0]; }
Source:
private FeedbackQuestionAttributes getNewFeedbackQuestionAttributes() { FeedbackTextQuestionDetails questionDetails = new FeedbackTextQuestionDetails("Question text."); return FeedbackQuestionAttributes.builder() .withCourseId("testCourse") .withCreatorEmail("instructor@email.com") .withFeedbackSessionName("testFeedbackSession") .withGiverType(FeedbackParticipantType.INSTRUCTORS) .withRecipientType(FeedbackParticipantType.SELF) .withNumOfEntitiesToGiveFeedbackTo(1) .withQuestionNumber(1) .withQuestionType(FeedbackQuestionType.TEXT) .withQuestionMetaData(new Text(JsonUtils.toJson(questionDetails, FeedbackQuestionType.TEXT.getQuestionDetailsClass()))) .withShowGiverNameTo(new ArrayList<>()) .withShowRecipientNameTo(new ArrayList<>()) .withShowResponseTo(new ArrayList<>()) .buildWithoutRemovingIrrelevantVisibilityOptions(); }

Target:
private FeedbackQuestionAttributes getNewFeedbackQuestionAttributes() { FeedbackTextQuestionDetails questionDetails = new FeedbackTextQuestionDetails("Question text."); return FeedbackQuestionAttributes.builder() .withCourseId("testCourse") .withCreatorEmail("instructor@email.com") .withFeedbackSessionName("testFeedbackSession") .withGiverType(FeedbackParticipantType.INSTRUCTORS) .withRecipientType(FeedbackParticipantType.SELF) .withNumOfEntitiesToGiveFeedbackTo(1) .withQuestionNumber(1) .withQuestionType(FeedbackQuestionType.TEXT) .withQuestionMetaData(questionDetails) .withShowGiverNameTo(new ArrayList<>()) .withShowRecipientNameTo(new ArrayList<>()) .withShowResponseTo(new ArrayList<>()) .build(); }
Source:
private void initialize() { viewModel = new PreferencesDialogViewModel(dialogService, frame); preferenceTabList.itemsProperty().setValue(viewModel.getPreferenceTabs()); PreferencesSearchHandler searchHandler = new PreferencesSearchHandler(viewModel.getPreferenceTabs()); preferenceTabList.itemsProperty().bindBidirectional(searchHandler.filteredPreferenceTabsProperty()); searchBox.textProperty().addListener((observable, previousText, newText) -> { searchHandler.filterTabs(newText.toLowerCase(Locale.ROOT)); preferenceTabList.getSelectionModel().clearSelection(); preferenceTabList.getSelectionModel().selectFirst(); }); searchBox.setPromptText(Localization.lang("Search") + "..."); searchBox.setLeft(IconTheme.JabRefIcons.SEARCH.getGraphicNode()); EasyBind.subscribe(preferenceTabList.getSelectionModel().selectedItemProperty(), tab -> { if (tab == null) { preferencePaneContainer.setContent(null); } else { preferencePaneContainer.setContent(tab.getBuilder()); } }); preferenceTabList.getSelectionModel().selectFirst(); new ViewModelListCellFactory<PreferencesTab>() .withText(PreferencesTab::getTabName) .install(preferenceTabList); DefaultTaskExecutor.runInJavaFXThread(viewModel::setValues); }

Target:
private void initialize() { viewModel = new PreferencesDialogViewModel(dialogService, frame); preferenceTabList.itemsProperty().setValue(viewModel.getPreferenceTabs()); PreferencesSearchHandler searchHandler = new PreferencesSearchHandler(viewModel.getPreferenceTabs()); preferenceTabList.itemsProperty().bindBidirectional(searchHandler.filteredPreferenceTabsProperty()); searchBox.textProperty().addListener((observable, previousText, newText) -> { searchHandler.filterTabs(newText.toLowerCase(Locale.ROOT)); preferenceTabList.getSelectionModel().clearSelection(); preferenceTabList.getSelectionModel().selectFirst(); }); searchBox.setPromptText(Localization.lang("Search") + "..."); searchBox.setLeft(IconTheme.JabRefIcons.SEARCH.getGraphicNode()); EasyBind.subscribe(preferenceTabList.getSelectionModel().selectedItemProperty(), tab -> { if (tab == null) { preferencePaneContainer.setContent(null); } else { preferencePaneContainer.setContent(tab.getBuilder()); } }); preferenceTabList.getSelectionModel().selectFirst(); new ViewModelListCellFactory<PreferencesTab>() .withText(PreferencesTab::getTabName) .install(preferenceTabList); viewModel.setValues(); }
Source:
public Builder withDefaultHint(QueryEvaluationHint engineDefaultHints) { this.engineDefaultHints = engineDefaultHints; this.defaultBackendFactory = engineDefaultHints.getQueryBackendFactory(); return this; }

Target:
public Builder withDefaultHint(QueryEvaluationHint engineDefaultHints) { this.engineDefaultHints = engineDefaultHints; return this; }
Source:
public void clickOnPlusMenuButton() { redrawDriverWait.until(visibilityOf(plusMenuBtn)); new Actions(seleniumWebDriver).moveToElement(plusMenuBtn).click().perform(); }

Target:
public void clickOnPlusMenuButton() { redrawDriverWait.until(visibilityOf(plusMenuBtn)); actionsFactory.createAction(seleniumWebDriver).moveToElement(plusMenuBtn).click().perform(); }
Source:
public boolean requestRouteToHostAddress(int networkType, InetAddress hostAddress) { try { String address; int addressType; if (hostAddress instanceof Inet4Address) { address = hostAddress.getHostAddress(); addressType = IPv4; } else if (hostAddress instanceof Inet6Address) { address = hostAddress.getHostAddress(); addressType = IPv6; } else { return false; } return mService.requestRouteToHostAddress(networkType, addressType, address); } catch (Exception e) { return false; } }

Target:
public boolean requestRouteToHostAddress(int networkType, InetAddress hostAddress) { String address = hostAddress.getHostAddress(); try { return mService.requestRouteToHostAddress(networkType, address); } catch (RemoteException e) { return false; } }
Source:
public static QuotaEnforcementTypeEnum map(QuotaModeType type) { switch (type) { case DISABLED: return QuotaEnforcementTypeEnum.DISABLED; case ENABLED: return QuotaEnforcementTypeEnum.HARD_ENFORCEMENT; case AUDIT: return QuotaEnforcementTypeEnum.SOFT_ENFORCEMENT; default: return null; } }

Target:
public static QuotaEnforcementTypeEnum map(QuotaModeType type) { switch (type) { case DISABLED: return QuotaEnforcementTypeEnum.DISABLED; case ENABLED: return QuotaEnforcementTypeEnum.HARD_ENFORCEMENT; case AUDIT: return QuotaEnforcementTypeEnum.SOFT_ENFORCEMENT; default: throw new IllegalArgumentException("Unknown quota mode type \"" + type + "\""); } }
Source:
protected void runInternal() { hasMapListener = mapEventPublisher.hasEventListener(name); hasWanReplication = mapContainer.isWanReplicationEnabled() && !disableWanReplicationEvent; hasBackups = mapContainer.getTotalBackupCount() > 0; hasInvalidation = mapContainer.hasInvalidationListener(); if (hasBackups) { backupRecordAndDataValuePairs = new ArrayList<>(mergingEntries.size()); } if (hasInvalidation) { invalidationKeys = new ArrayList<>(mergingEntries.size()); } for (MapMergeTypes mergingEntry : mergingEntries) { merge(mergingEntry); } }

Target:
protected void runInternal() { hasMapListener = mapEventPublisher.hasEventListener(name); hasWanReplication = mapContainer.isWanReplicationEnabled() && !disableWanReplicationEvent; hasBackups = mapContainer.getTotalBackupCount() > 0; hasInvalidation = mapContainer.hasInvalidationListener(); if (hasBackups) { backupRecordAndDataValuePairs = new ArrayList<>(mergingEntries.size() * 2); } if (hasInvalidation) { invalidationKeys = new ArrayList<>(mergingEntries.size()); } for (MapMergeTypes mergingEntry : mergingEntries) { merge(mergingEntry); } }
Source:
public void releaseReference(K object) { Integer count = references.get(object); if (count == null) { throw new IllegalStateException("Object does not have any references: " + object); } else if (count > 1) { references.put(object, count - 1); } else if (count == 1){ references.remove(object); } else if (count <= 0) { throw new IllegalStateException("Invalid reference count: " + count); } }

Target:
public void releaseReference(K object) { Integer count = references.get(object); if (count == null) { throw new IllegalStateException("Object does not have any references: " + object); } else if (count > 1) { references.put(object, count - 1); } else if (count == 1) { references.remove(object); } else { throw new IllegalStateException("Invalid reference count: " + count); } }
Source:
public void handleMessage(Message<?> message) throws MessagingException { try { SmesMessageSpecification specification = applyDefaultsIfNecessary( SmesMessageSpecification.fromMessage(this.smppSession, message) .setTimeFormatter(this.timeFormatter)); String[] smsMessageId = specification.send(); logger.debug( "sent message : "+message.getPayload()); logger.debug("message ID(s) for the sent message: " + Arrays.toString(smsMessageId)); } catch (Exception e) { throw new RuntimeException("Exception in trying to process the inbound SMPP message", e); } }

Target:
public void handleMessage(Message<?> message) throws MessagingException { try { SmesMessageSpecification specification = applyDefaultsIfNecessary( SmesMessageSpecification.fromMessage(this.smppSession, message) .setTimeFormatter(this.timeFormatter)); List<String> smsMessageId = specification.send(); logger.debug( "sent message : "+message.getPayload()); logger.debug("message ID(s) for the sent message: " + smsMessageId); } catch (Exception e) { throw new RuntimeException("Exception in trying to process the inbound SMPP message", e); } }
Source:
public void testStableSort() { page.click(By.id("button_sortid")); page.click(By.id("button_sortid")); page.click(By.id("button_sortname")); String[] idList = { "15", "0", "-13.5", "2", "-2", "-1.3", "10.01", "24", "1", "10.7", "3", "33", "10.35", "-0.001", "10.3" }; StringBuilder searchString = new StringBuilder(); for (String element : idList) { searchString.append(element).append("{*}"); } page.verifyContains(searchString.toString()); page.click(By.id("button_sortname")); String[] reversedIdList = { "10.3", "-0.001", "10.35", "33", "3", "10.7", "1", "-2", "-1.3", "10.01", "24", "2", "-13.5", "0", "15" }; searchString = new StringBuilder(); for (String element : reversedIdList) { searchString.append(element).append("{*}"); } page.verifyContains(searchString.toString()); }

Target:
public void testStableSort() { page.click(By.id("button_sortid")); page.click(By.id("button_sortid")); page.click(By.id("button_sortname")); String[] idList = { "15", "0", "-13.5", "2", "-2", "-1.3", "10.01", "24", "1", "10.7", "3", "33", "10.35", "-0.001", "10.3" }; StringBuilder searchString = new StringBuilder(); for (String id : idList) { searchString.append(id).append("{*}"); } page.verifyContains(searchString.toString()); page.click(By.id("button_sortname")); String[] reversedIdList = { "10.3", "-0.001", "10.35", "33", "3", "10.7", "1", "-2", "-1.3", "10.01", "24", "2", "-13.5", "0", "15" }; searchString = new StringBuilder(); for (String id : reversedIdList) { searchString.append(id).append("{*}"); } page.verifyContains(searchString.toString()); }
Source:
public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } Commit other = (Commit) o; return this.commitMetadata.getCommitId().equals(other.commitMetadata.getCommitId()); }

Target:
public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } Commit other = (Commit) o; return this.getId().equals(other.getId()); }
Source:
public void end(Xid xid, int flags) throws XAException { log.infof("end xid:[%s], flag: %s", xid, flags); }

Target:
public void end(Xid xid, int flags) throws XAException { log.tracef("end xid:[%s], flag: %s", xid, flags); }
Source:
private DiffObjectCount count(RevTree left, RevTree right) { PreOrderDiffWalk visitor = new PreOrderDiffWalk(left, right, odb, odb, true); DiffCountConsumer consumer = new DiffCountConsumer(odb); visitor.walk(consumer); DiffObjectCount count = consumer.get(); return count; }

Target:
private DiffObjectCount count(RevTree left, RevTree right) { PreOrderDiffWalk visitor = new PreOrderDiffWalk(left, right, odb, odb); DiffCountConsumer consumer = new DiffCountConsumer(odb); visitor.walk(consumer); DiffObjectCount count = consumer.get(); return count; }
Source:
public void onChatMessage(ChatMessage chatMessage) { Player player = playerService.getPlayerForUsername(chatMessage.getUsername()); ChatPrefs chatPrefs = preferencesService.getPreferences().getChat(); if (player != null && player.getSocialStatus() == FOE && chatPrefs.getHideFoeMessages()) { return; } super.onChatMessage(chatMessage); if (!hasFocus()) { audioService.playPrivateMessageSound(); showNotificationIfNecessary(chatMessage); setUnread(true); incrementUnreadMessagesCount(1); boolean chatFocused = preferencesService.getPreferences().getMainWindow().getLastView().equals(NavigationItem.CHAT.name()); eventBus.post(new UnreadPrivateMessageEvent(chatMessage, chatFocused)); } }

Target:
public void onChatMessage(ChatMessage chatMessage) { Player player = playerService.getPlayerForUsername(chatMessage.getUsername()); ChatPrefs chatPrefs = preferencesService.getPreferences().getChat(); if (player != null && player.getSocialStatus() == FOE && chatPrefs.getHideFoeMessages()) { return; } super.onChatMessage(chatMessage); if (!hasFocus()) { audioService.playPrivateMessageSound(); showNotificationIfNecessary(chatMessage); setUnread(true); incrementUnreadMessagesCount(1); eventBus.post(new UnreadPrivateMessageEvent(chatMessage)); } }
Source:
private WrappedValue<V> getInternal(K key) { V value = null; EntityTag eTag = null; if (service.isRunning()) { String target = buildUrl(service.cacheName, key); try { Invocation get = service.getHttpClient().target(target).request().accept(service.getContentType()) .buildGet(); Response response = get.invoke(); eTag = response.getEntityTag(); value = decodeByteArray(response.readEntity(byte[].class)); } catch (NotFoundException e) { log.warn("RESTEasyHTTPOperations.get::Key: " + key + " does not exist in cache: " + service.cacheName); } catch (Exception e) { throw new RuntimeException("RESTEasyHTTPOperations::get request threw exception: " + target, e); } } return new WrappedValue<V>(eTag, value); }

Target:
private WrappedValue<V> getInternal(K key) { V value = null; EntityTag eTag = null; if (service.isRunning()) { String target = buildUrl(service.cacheName, key); Response response = null; try { Invocation get = service.getHttpClient().target(target).request().accept(service.getContentType()) .buildGet(); response = get.invoke(); if (response.getStatus() == Status.NOT_FOUND.getStatusCode()) { log.warn("RESTEasyHTTPOperations.getInternal::Key: " + key + " does not exist in cache: " + service.cacheName); } else { eTag = response.getEntityTag(); value = decodeByteArray(response.readEntity(byte[].class)); } } catch (Exception e) { throw new RuntimeException("RESTEasyHTTPOperations::get request threw exception: " + target, e); } finally { if (response != null) { response.close(); } } } return new WrappedValue<V>(eTag, value); }
Source:
public AnalyzedAlterTableDropCheckConstraint analyze(Table<?> table, String name, CoordinatorTxnCtx txnCtx) { DocTableInfo tableInfo = (DocTableInfo) schemas.resolveTableInfo( table.getName(), Operation.ALTER, txnCtx.sessionContext().user(), txnCtx.sessionContext().searchPath()); List<CheckConstraint<Symbol>> checkConstraints = tableInfo.checkConstraints(); for (int i = 0; i < checkConstraints.size(); i++) { if (checkConstraints.get(i).name().equals(name)) { return new AnalyzedAlterTableDropCheckConstraint(tableInfo, name); } } throw new IllegalArgumentException(String.format( Locale.ENGLISH, "Cannot find a CHECK CONSTRAINT named [%s], available names are: %s", name, checkConstraints .stream() .map(CheckConstraint::name) .collect(Collectors.toList()))); }

Target:
public AnalyzedAlterTableDropCheckConstraint analyze(Table<?> table, String name, CoordinatorTxnCtx txnCtx) { DocTableInfo tableInfo = (DocTableInfo) schemas.resolveTableInfo( table.getName(), Operation.ALTER, txnCtx.sessionContext().user(), txnCtx.sessionContext().searchPath()); List<CheckConstraint<Symbol>> checkConstraints = tableInfo.checkConstraints(); for (int i = 0; i < checkConstraints.size(); i++) { if (name.equals(checkConstraints.get(i).name())) { return new AnalyzedAlterTableDropCheckConstraint(tableInfo, name); } } throw new IllegalArgumentException(String.format( Locale.ENGLISH, "Cannot find a CHECK CONSTRAINT named [%s], available constraints are: %s", name, Lists2.map(checkConstraints, CheckConstraint::name))); }
Source:
public BridgeType(String bindingId, String thingTypeId, String label) throws IllegalArgumentException { this(new ThingTypeUID(bindingId, thingTypeId), null, label, null, false, null, null, null, null); }

Target:
public BridgeType(String bindingId, String thingTypeId, String label) throws IllegalArgumentException { this(new ThingTypeUID(bindingId, thingTypeId), null, label, null, true, null, null, null, null); }
Source:
public Collection<Class<?>> traverseBundlesForOsgiServices(final Collection<Bundle> bundles) { Collection<Class<?>> allClasses = getClasses(bundles); Set<Class<?>> osgiClasses = new HashSet<Class<?>>(); for (Class<?> clazz : allClasses) { Field[] fields = clazz.getDeclaredFields(); for (Field field : fields) { if (field.isAnnotationPresent(OsgiService.class)) { Class<?> fieldClass = field.getType(); osgiClasses.add(fieldClass); } } Constructor<?>[] constructors = clazz.getConstructors(); for (Constructor<?> constructor : constructors) { Class<?>[] parameterTypes = constructor.getParameterTypes(); Annotation[][] annotations = constructor.getParameterAnnotations(); int j = 0; for (int i = (parameterTypes.length - annotations.length); i < parameterTypes.length; i++) { for (Annotation annotation : annotations[j]) { if (annotation.annotationType().equals(OsgiService.class)) { osgiClasses.add(parameterTypes[j]); break; } } j++; } } } return osgiClasses; }

Target:
public Collection<Class<?>> traverseBundlesForOsgiServices(final Collection<Bundle> bundles) { Collection<Class<?>> allClasses = getClasses(bundles); Set<Class<?>> osgiClasses = new HashSet<Class<?>>(); for (Class<?> clazz : allClasses) { Set<Class<?>> osgiServicesForClass = readOsgiServicesForClass(clazz); osgiServicesForClass.addAll(osgiServicesForClass); } return osgiClasses; }