auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
public void testPodLogOfApplicationPod() { TestUtils.setUpOcBinary(); ApplicationPodIsRunning applicationPodIsRunning = new ApplicationPodIsRunning(); new WaitUntil(applicationPodIsRunning, TimePeriod.LONG); OpenShiftResource pod = new OpenShiftExplorerView().getOpenShift3Connection().getProject(). getOpenShiftResource(Resource.POD, applicationPodIsRunning.getApplicationPodName()); pod.select(); String podName = pod.getName(); new ContextMenu(OpenShiftLabel.ContextMenu.POD_LOG).select(); ConsoleView consoleView = new ConsoleView(); new WaitUntil(new ConsoleHasText() { @Override public String errorMessage() { return "Console of pod log is not opened"; }}, TimePeriod.NORMAL, false); new WaitUntil(new ConsoleHasNoChange(TimePeriod.getCustom(7)), TimePeriod.VERY_LONG); assertTrue("Console label is incorrect, it should contains project name and pod name.\n" + "but label is: " + consoleView.getConsoleLabel(), consoleView.getConsoleLabel().contains( DatastoreOS3.PROJECT1 + "\\" + podName)); assertTrue("Console text should contain output from EAP runtime", consoleView.getConsoleText().contains("Admin console listening on")); }

Target:
public void testPodLogOfApplicationPod() { TestUtils.setUpOcBinary(); ApplicationPodIsRunning applicationPodIsRunning = new ApplicationPodIsRunning(); new WaitUntil(applicationPodIsRunning, TimePeriod.LONG); OpenShiftResource pod = new OpenShiftExplorerView().getOpenShift3Connection().getProject(). getOpenShiftResource(Resource.POD, applicationPodIsRunning.getApplicationPodName()); pod.select(); String podName = pod.getName(); new ContextMenu(OpenShiftLabel.ContextMenu.POD_LOG).select(); ConsoleView consoleView = new ConsoleView(); new WaitUntil(new ConsoleHasSomeText() { @Override public String errorMessage() { return "Console of pod log is not opened or does not have text"; }}, TimePeriod.NORMAL); new WaitUntil(new ConsoleHasNoChange(TimePeriod.getCustom(7)), TimePeriod.VERY_LONG); assertTrue("Console label is incorrect, it should contains project name and pod name.\n" + "but label is: " + consoleView.getConsoleLabel(), consoleView.getConsoleLabel().contains( DatastoreOS3.PROJECT1 + "\\" + podName)); assertTrue("Console text should contain output from EAP runtime", consoleView.getConsoleText().contains("Admin console listening on")); }
Source:
public void testMultiReadSpansSegments() { final long segmentEnd = 5L; addServer(SERVERS.PORT_0); addServer(SERVERS.PORT_1); addServer(SERVERS.PORT_2); bootstrapAllServers(new TestLayoutBuilder() .setEpoch(1L) .addLayoutServer(SERVERS.PORT_0) .addSequencer(SERVERS.PORT_0) .buildSegment() .setStart(0L) .setEnd(segmentEnd) .buildStripe() .addLogUnit(SERVERS.PORT_0) .addToSegment() .buildStripe() .addLogUnit(SERVERS.PORT_1) .addToSegment() .addToLayout() .buildSegment() .setStart(segmentEnd) .setEnd(-1L) .buildStripe() .addLogUnit(SERVERS.PORT_1) .addToSegment() .buildStripe() .addLogUnit(SERVERS.PORT_2) .addToSegment() .addToLayout() .build()); getManagementServer(SERVERS.PORT_0).shutdown(); getManagementServer(SERVERS.PORT_1).shutdown(); getManagementServer(SERVERS.PORT_2).shutdown(); CorfuRuntime rt = getRuntime().connect(); final String testString = "hello world "; final long numAddresses = 10L; for (long i = 0L; i < numAddresses; i++) { TokenResponse token = rt.getSequencerView().next(); rt.getAddressSpaceView().write(token, (testString + i).getBytes()); } Map<Long, ILogData> readResult = rt.getAddressSpaceView().read( ContiguousSet.create(Range.closed(0L, numAddresses - 1), DiscreteDomain.longs())); readResult.forEach((addr, data) -> assertThat(data.getPayload(rt)).isEqualTo((testString + addr).getBytes())); }

Target:
public void testMultiReadSpansSegments() { final long segmentEnd = 5L; addServer(SERVERS.PORT_0); addServer(SERVERS.PORT_1); addServer(SERVERS.PORT_2); bootstrapAllServers(new TestLayoutBuilder() .setEpoch(1L) .addLayoutServer(SERVERS.PORT_0) .addSequencer(SERVERS.PORT_0) .buildSegment() .setStart(0L) .setEnd(segmentEnd) .buildStripe() .addLogUnit(SERVERS.PORT_0) .addToSegment() .buildStripe() .addLogUnit(SERVERS.PORT_1) .addToSegment() .addToLayout() .buildSegment() .setStart(segmentEnd) .setEnd(-1L) .buildStripe() .addLogUnit(SERVERS.PORT_1) .addToSegment() .buildStripe() .addLogUnit(SERVERS.PORT_2) .addToSegment() .addToLayout() .build()); getManagementServer(SERVERS.PORT_0).shutdown(); getManagementServer(SERVERS.PORT_1).shutdown(); getManagementServer(SERVERS.PORT_2).shutdown(); CorfuRuntime rt = getRuntime(); rt.setCacheDisabled(true); rt.connect(); final String testString = "hello world "; final long numAddresses = 10L; for (long i = 0L; i < numAddresses; i++) { TokenResponse token = rt.getSequencerView().next(); rt.getAddressSpaceView().write(token, (testString + i).getBytes()); } Map<Long, ILogData> readResult = rt.getAddressSpaceView().read( ContiguousSet.create(Range.closed(0L, numAddresses - 1), DiscreteDomain.longs())); readResult.forEach((addr, data) -> assertThat(data.getPayload(rt)).isEqualTo((testString + addr).getBytes())); }
Source:
public void checkStackButtons() { newWorkspace.waitPageLoad(); newWorkspace.waitQuickStartButton(); newWorkspace.waitStacks(EXPECTED_QUICK_START_STACKS); assertEquals(newWorkspace.getAvailableStacksCount(), EXPECTED_QUICK_START_STACKS_COUNT); newWorkspace.clickOnSingleMachineButton(); newWorkspace.waitStacks(EXPECTED_SINGLE_MACHINE_STACKS); assertEquals(newWorkspace.getAvailableStacksCount(), EXPECTED_SINGLE_MACHINE_STACKS_COUNT); newWorkspace.clickOnAllButton(); newWorkspace.waitStacks(EXPECTED_ALL_STACKS); assertEquals(newWorkspace.getAvailableStacksCount(), EXPECTED_ALL_STACKS_COUNT); newWorkspace.clickOnMultiMachineButton(); newWorkspace.waitStacks(EXPECTED_MULTI_MACHINE_STACKS); assertEquals(newWorkspace.getAvailableStacksCount(), EXPECTED_MULTI_MACHINE_STACKS_COUNT); newWorkspace.clickOnAllButton(); newWorkspace.waitStacks(EXPECTED_SINGLE_MACHINE_STACKS); newWorkspace.waitStacks(EXPECTED_MULTI_MACHINE_STACKS); assertEquals( newWorkspace.getAvailableStacksCount(), EXPECTED_SINGLE_MACHINE_STACKS_COUNT + EXPECTED_MULTI_MACHINE_STACKS_COUNT); newWorkspace.clickOnQuickStartButton(); newWorkspace.waitStacksOrder(EXPECTED_QUICK_START_STACKS); newWorkspace.clickNameButton(); try { newWorkspace.waitStacksOrder(EXPECTED_QUICK_START_STACKS_REVERSE_ORDER); } catch (TimeoutException ex) { fail("Known issue <LINK_0>", ex); } newWorkspace.clickNameButton(); newWorkspace.waitStacksOrder(EXPECTED_QUICK_START_STACKS); }

Target:
public void checkStackButtons() { newWorkspace.waitPageLoad(); newWorkspace.waitQuickStartButton(); newWorkspace.waitStacks(EXPECTED_QUICK_START_STACKS); newWorkspace.waitStacksCount(EXPECTED_QUICK_START_STACKS_COUNT); newWorkspace.clickOnSingleMachineButton(); newWorkspace.waitStacks(EXPECTED_SINGLE_MACHINE_STACKS); newWorkspace.waitStacksCount(EXPECTED_SINGLE_MACHINE_STACKS_COUNT); newWorkspace.clickOnAllButton(); newWorkspace.waitStacks(EXPECTED_ALL_STACKS); newWorkspace.waitStacksCount(EXPECTED_ALL_STACKS_COUNT); newWorkspace.clickOnMultiMachineButton(); newWorkspace.waitStacks(EXPECTED_MULTI_MACHINE_STACKS); newWorkspace.waitStacksCount(EXPECTED_MULTI_MACHINE_STACKS_COUNT); newWorkspace.clickOnAllButton(); newWorkspace.waitStacks(EXPECTED_SINGLE_MACHINE_STACKS); newWorkspace.waitStacks(EXPECTED_MULTI_MACHINE_STACKS); newWorkspace.waitStacksCount( EXPECTED_SINGLE_MACHINE_STACKS_COUNT + EXPECTED_MULTI_MACHINE_STACKS_COUNT); newWorkspace.clickOnQuickStartButton(); newWorkspace.waitStacksOrder(EXPECTED_QUICK_START_STACKS); newWorkspace.clickNameButton(); try { newWorkspace.waitStacksOrder(EXPECTED_QUICK_START_STACKS_REVERSE_ORDER); } catch (TimeoutException ex) { fail("Known issue <LINK_0>", ex); } newWorkspace.clickNameButton(); newWorkspace.waitStacksOrder(EXPECTED_QUICK_START_STACKS); }
Source:
public void testProcessQueryGraphQl() throws NoHttpResponseException, URISyntaxException { String query = "{\"query\":\"{ group { edges { node { name commonName description } } } }\",\"variables\":null}"; ElideResponse response = mock(ElideResponse.class); when(queryObj.getQuery()).thenReturn(query); when(queryObj.getQueryType()).thenReturn(QueryType.GRAPHQL_V1_0); when(runner.run(query, user)).thenReturn(response); when(response.getResponseCode()).thenReturn(200); when(response.getBody()).thenReturn("ResponseBody"); }

Target:
public void testProcessQueryGraphQl() throws NoHttpResponseException, URISyntaxException { AsyncQuery queryObj = new AsyncQuery(); ElideResponse response = new ElideResponse(200, "ResponseBody"); String query = "{\"query\":\"{ group { edges { node { name commonName description } } } }\",\"variables\":null}"; String id = "edc4a871-dff2-4054-804e-d80075cf827d"; queryObj.setId(id); queryObj.setQuery(query); queryObj.setQueryType(QueryType.GRAPHQL_V1_0); when(runner.run(query, user)).thenReturn(response); AsyncQueryThread queryThread = new AsyncQueryThread(queryObj, user, elide, runner, asyncQueryDao, "v1"); queryResultObj = queryThread.processQuery(); assertEquals(queryResultObj.getResponseBody(), "ResponseBody"); assertEquals(queryResultObj.getHttpStatus(), 200); }
Source:
public ScheduledFuture<?> scheduleHealthCheck(final ExecutorDriver driver, final String host, final Integer port) { ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); final Runnable checker = new Runnable() { public void run() { performHealthCheck(host, port, driver); } }; return scheduler.scheduleWithFixedDelay(checker, 120, 30, SECONDS); }

Target:
public ScheduledFuture<?> scheduleHealthCheck(final ExecutorDriver driver, final String host, final Integer port) { ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); final Runnable checker = new Runnable() { HttpClient client = HttpClientBuilder.create().build(); HttpGet request = new HttpGet("http://" + host + ":" + port); public void run() { performHealthCheck(host, port, driver, client, request); } }; return scheduler.scheduleWithFixedDelay(checker, 30, 30, SECONDS); }
Source:
public void incrementalSSTableSelection() throws Exception { cfs.setMinimumCompactionThreshold(10); SSTableReader sstable1 = createSSTable(() -> QueryProcessor.executeInternal(String.format("INSERT INTO %s.%s (k, v) VALUES (1, 1)", keyspace, table))); SSTableReader sstable2 = createSSTable(() -> QueryProcessor.executeInternal(String.format("INSERT INTO %s.%s (k, v) VALUES (2, 2)", keyspace, table))); SSTableReader sstable3 = createSSTable(() -> QueryProcessor.executeInternal(String.format("INSERT INTO %s.%s (k, v) VALUES (3, 3)", keyspace, table))); SSTableReader sstable4 = createSSTable(() -> QueryProcessor.executeInternal(String.format("INSERT INTO %s.%s (k, v) VALUES (4, 4)", keyspace, table))); UUID pendingRepair = UUIDGen.getTimeUUID(); long repairedAt = System.currentTimeMillis(); mutateRepaired(sstable2, ActiveRepairService.UNREPAIRED_SSTABLE, pendingRepair, false); mutateRepaired(sstable3, ActiveRepairService.UNREPAIRED_SSTABLE, UUIDGen.getTimeUUID(), false); mutateRepaired(sstable4, repairedAt, NO_PENDING_REPAIR, false); Assert.assertEquals(Sets.newHashSet(sstable1, sstable2, sstable3, sstable4), selectReaders(NO_PENDING_REPAIR)); Assert.assertEquals(Sets.newHashSet(sstable2), selectReaders(pendingRepair)); }

Target:
public void incrementalSSTableSelection() throws Exception { cfs.disableAutoCompaction(); SSTableReader sstable1 = createSSTable(() -> QueryProcessor.executeInternal(String.format("INSERT INTO %s.%s (k, v) VALUES (1, 1)", keyspace, table))); SSTableReader sstable2 = createSSTable(() -> QueryProcessor.executeInternal(String.format("INSERT INTO %s.%s (k, v) VALUES (2, 2)", keyspace, table))); SSTableReader sstable3 = createSSTable(() -> QueryProcessor.executeInternal(String.format("INSERT INTO %s.%s (k, v) VALUES (3, 3)", keyspace, table))); SSTableReader sstable4 = createSSTable(() -> QueryProcessor.executeInternal(String.format("INSERT INTO %s.%s (k, v) VALUES (4, 4)", keyspace, table))); UUID pendingRepair = UUIDGen.getTimeUUID(); long repairedAt = System.currentTimeMillis(); mutateRepaired(sstable2, ActiveRepairService.UNREPAIRED_SSTABLE, pendingRepair, false); mutateRepaired(sstable3, ActiveRepairService.UNREPAIRED_SSTABLE, UUIDGen.getTimeUUID(), false); mutateRepaired(sstable4, repairedAt, NO_PENDING_REPAIR, false); Assert.assertEquals(Sets.newHashSet(sstable1, sstable2, sstable3, sstable4), selectReaders(NO_PENDING_REPAIR)); Assert.assertEquals(Sets.newHashSet(sstable2), selectReaders(pendingRepair)); }
Source:
private Optional<MethodExecutor> getMethodExecutor(EvaluationContextExtensionAdapter adapter, String name, List<TypeDescriptor> argumentTypes) { FunctionsMap functions = adapter.getFunctions(); Optional<Function> function = functions.get(name, argumentTypes); return function.map(FunctionMethodExecutor::new); }

Target:
private Optional<MethodExecutor> getMethodExecutor(EvaluationContextExtensionAdapter adapter, String name, List<TypeDescriptor> argumentTypes) { return adapter.getFunctions().get(name, argumentTypes).map(FunctionMethodExecutor::new); }
Source:
public static void firePlayerLoadingEvent(EntityPlayer player, IPlayerFileData playerFileData, String uuidString) { SaveHandler sh = (SaveHandler) playerFileData; File dir = ObfuscationReflectionHelper.getPrivateValue(SaveHandler.class, sh, "field_75771_c"); MinecraftForge.EVENT_BUS.post(new PlayerEvent.LoadFromFile(player, dir, uuidString)); }

Target:
public static void firePlayerLoadingEvent(EntityPlayer player, IPlayerFileData playerFileData, String uuidString) { SaveHandler sh = (SaveHandler) playerFileData; File dir = ObfuscationReflectionHelper.getPrivateValue(SaveHandler.class, sh, "field_"+"75771_c"); MinecraftForge.EVENT_BUS.post(new PlayerEvent.LoadFromFile(player, dir, uuidString)); }
Source:
private static String randomId() { byte[] randomBytes = new byte[16]; RANDOM.nextBytes(randomBytes); randomBytes[6] &= 0x0f; randomBytes[6] |= 0x40; randomBytes[8] &= 0x3f; randomBytes[8] |= 0x80; ByteBuffer buffer = ByteBuffer.wrap(randomBytes); long msb = buffer.getLong(0); long lsb = buffer.getLong(8); return new UUID(msb, lsb).toString(); }

Target:
public static String randomId() { return Long.toHexString(ThreadLocalRandom.current().nextLong()); }
Source:
public IdentityProvider[] getEnabledAllIdPs() throws IdentityProviderManagementException { try { String tenantDomain = CarbonContext.getThreadLocalCarbonContext().getTenantDomain(); List<IdentityProvider> identityProviders = IdentityProviderManager.getInstance().getEnabledIdPs (tenantDomain); return identityProviders.toArray(new IdentityProvider[identityProviders.size()]); } catch (IdentityProviderManagementException idpException) { log.error("Error while getting enabled registered Identity providers", idpException); throw idpException; } }

Target:
public IdentityProvider[] getEnabledAllIdPs() throws IdentityProviderManagementException { String tenantDomain = ""; try { tenantDomain = CarbonContext.getThreadLocalCarbonContext().getTenantDomain(); List<IdentityProvider> identityProviders = IdentityProviderManager.getInstance().getEnabledIdPs (tenantDomain); return identityProviders.toArray(new IdentityProvider[identityProviders.size()]); } catch (IdentityProviderManagementException idpException) { log.error("Error while getting enabled registered Identity providers in tenantDomain : " + tenantDomain, idpException); throw idpException; } }
Source:
public void disconnect() throws IOException { channel.close(); connection.close(); }

Target:
public void disconnect(){ try { channel.close(); } catch (IOException e) { e.printStackTrace(); } try { connection.close(); } catch (IOException e) { e.printStackTrace(); } }
Source:
public Publisher(PublisherReverseResolver repositoryNameLookup, PublisherPackFactory packFactory, SessionGenerator generator) { sessions = new HashMap<String, PublisherSession>(); pushStream = new PublisherStream(); sessionDeleter = new ScheduledThreadPoolExecutor(1); sessionLifetime = DEFAULT_SESSION_GRACE_PERIOD; sessionRollbackCount = DEFAULT_SESSION_ROLLBACK_COUNT; this.repositoryNameLookup = repositoryNameLookup; this.packFactory = packFactory; this.generator = generator; }

Target:
public Publisher(PublisherReverseResolver repositoryNameLookup, PublisherPackFactory packFactory, SessionGenerator generator) { sessions = new HashMap<String, PublisherSession>(); pushStream = new PublisherStream(); sessionDeleter = new ScheduledThreadPoolExecutor( 1, new ThreadFactory() { public Thread newThread(Runnable r) { Thread t = new Thread(r); t.setName("SessionDeleter"); t.setDaemon(true); return t; } }); sessionLifetime = DEFAULT_SESSION_GRACE_PERIOD; sessionRollbackCount = DEFAULT_SESSION_ROLLBACK_COUNT; this.repositoryNameLookup = repositoryNameLookup; this.packFactory = packFactory; this.generator = generator; }
Source:
public ConceptName getPreferredName(Locale forLocale) { if (log.isDebugEnabled()) { log.debug("Getting preferred conceptName for locale: " + forLocale); } if (getNames(forLocale).isEmpty()) { log.debug("The locale is {}.", forLocale); return null; } else if (forLocale == null) { log.warn("Locale cannot be null"); return null; } for (ConceptName nameInLocale : getNames(forLocale)) { if (ObjectUtils.nullSafeEquals(nameInLocale.getLocalePreferred(), true)) { return nameInLocale; } } ConceptName bestMatch = null; for (ConceptName nameInLocale : getPartiallyCompatibleNames(forLocale)) { if (ObjectUtils.nullSafeEquals(nameInLocale.getLocalePreferred(), true)) { Locale nameLocale = nameInLocale.getLocale(); if (forLocale.getLanguage().equals(nameLocale.getLanguage())) { return nameInLocale; } else { bestMatch = nameInLocale; } } } if (bestMatch != null) { return bestMatch; } return getFullySpecifiedName(forLocale); }

Target:
public ConceptName getPreferredName(Locale forLocale) { if (log.isDebugEnabled()) { log.debug("Getting preferred conceptName for locale: " + forLocale); } if (getNames(forLocale).isEmpty()) { log.debug("there are no names defined for concept with id: in the locale: {}", conceptId, forLocale); return null; } else if (forLocale == null) { log.warn("Locale cannot be null"); return null; } for (ConceptName nameInLocale : getNames(forLocale)) { if (ObjectUtils.nullSafeEquals(nameInLocale.getLocalePreferred(), true)) { return nameInLocale; } } ConceptName bestMatch = null; for (ConceptName nameInLocale : getPartiallyCompatibleNames(forLocale)) { if (ObjectUtils.nullSafeEquals(nameInLocale.getLocalePreferred(), true)) { Locale nameLocale = nameInLocale.getLocale(); if (forLocale.getLanguage().equals(nameLocale.getLanguage())) { return nameInLocale; } else { bestMatch = nameInLocale; } } } if (bestMatch != null) { return bestMatch; } return getFullySpecifiedName(forLocale); }
Source:
public ChainedPreferenceStore(IPreferenceStore[] preferenceStores) { Assert.isTrue(preferenceStores != null && preferenceStores.length > 0); fPreferenceStores= new IPreferenceStore[preferenceStores.length]; System.arraycopy(preferenceStores, 0, fPreferenceStores, 0, preferenceStores.length); for (IPreferenceStore fPreferenceStore : fPreferenceStores) { PropertyChangeListener listener= new PropertyChangeListener(fPreferenceStore); fChildListeners.add(listener); } }

Target:
public ChainedPreferenceStore(IPreferenceStore[] preferenceStores) { Assert.isTrue(preferenceStores != null && preferenceStores.length > 0); fPreferenceStores= new IPreferenceStore[preferenceStores.length]; System.arraycopy(preferenceStores, 0, fPreferenceStores, 0, preferenceStores.length); for (IPreferenceStore store : fPreferenceStores) { PropertyChangeListener listener= new PropertyChangeListener(store); fChildListeners.add(listener); } }
Source:
private List<SourceFile> generateSourceFiles(DescriptorLanguage descriptorLanguage) throws IOException { String resourceFilePath; String dockstorePath; SourceFile.TypeEnum type; if (descriptorLanguage == CWL) { resourceFilePath = "tar-param.cwl"; dockstorePath = "/Dockstore.cwl"; type = SourceFile.TypeEnum.DOCKSTORE_CWL; } else if (descriptorLanguage == WDL) { resourceFilePath = "hello.wdl"; dockstorePath = "/Dockstore.wdl"; type = SourceFile.TypeEnum.DOCKSTORE_WDL; } else { throw new CustomWebApplicationException("Only wdl and cwl are an option", HttpStatus.SC_BAD_REQUEST); } SourceFile descriptorFile = new SourceFile(); descriptorFile .setContent(FileUtils.readFileToString(new File(ResourceHelpers.resourceFilePath(resourceFilePath)), StandardCharsets.UTF_8)); descriptorFile.setType(type); descriptorFile.setPath(dockstorePath); descriptorFile.setAbsolutePath(dockstorePath); SourceFile dockerfile = new SourceFile(); dockerfile.setContent("FROM ubuntu:latest"); dockerfile.setType(SourceFile.TypeEnum.DOCKERFILE); dockerfile.setPath("/Dockerfile"); dockerfile.setAbsolutePath("/Dockerfile"); return Lists.newArrayList(descriptorFile, dockerfile); }

Target:
private List<SourceFile> generateSourceFiles(DescriptorLanguage descriptorLanguage) throws IOException { String resourceFilePath; String dockstorePath; SourceFile.TypeEnum type; if (descriptorLanguage == CWL) { resourceFilePath = "tar-param.cwl"; dockstorePath = "/Dockstore.cwl"; type = SourceFile.TypeEnum.DOCKSTORE_CWL; } else if (descriptorLanguage == WDL) { resourceFilePath = "hello.wdl"; dockstorePath = "/Dockstore.wdl"; type = SourceFile.TypeEnum.DOCKSTORE_WDL; } else { throw new CustomWebApplicationException("Only WDL and CWL are an option", HttpStatus.SC_BAD_REQUEST); } SourceFile descriptorFile = new SourceFile(); descriptorFile .setContent(FileUtils.readFileToString(new File(ResourceHelpers.resourceFilePath(resourceFilePath)), StandardCharsets.UTF_8)); descriptorFile.setType(type); descriptorFile.setPath(dockstorePath); descriptorFile.setAbsolutePath(dockstorePath); SourceFile dockerfile = new SourceFile(); dockerfile.setContent("FROM ubuntu:latest"); dockerfile.setType(SourceFile.TypeEnum.DOCKERFILE); dockerfile.setPath("/Dockerfile"); dockerfile.setAbsolutePath("/Dockerfile"); return Lists.newArrayList(descriptorFile, dockerfile); }
Source:
public void shouldExtractPastTikaWriteLimitIfConfigured() throws Exception { int stringLength = DEFAULT_TIKA_WRITE_LIMIT + 1; String rndString = randomString(stringLength); File tempFile = File.createTempFile("tika_extraction_", ".txt"); tempFile.deleteOnExit(); IoUtil.write(rndString, tempFile); SimpleProblems problems = new SimpleProblems(); TextExtractorContext context = new TextExtractorContext(execContext, path(tempFile.getName()), inputProperties, "text/plain", problems); StringTextExtractorOutput output = new StringTextExtractorOutput(); extractor.setWriteLimit(stringLength); extractor.extractFrom(new FileInputStream(tempFile), output, context); assertTrue(problems.toString(), problems.isEmpty()); assertEquals(rndString, output.toString()); }

Target:
public void shouldExtractPastTikaWriteLimitIfConfigured() throws Exception { int stringLength = DEFAULT_TIKA_WRITE_LIMIT + 1; String rndString = randomString(stringLength); File tempFile = File.createTempFile("tika_extraction_", ".txt"); try { IoUtil.write(rndString, tempFile); SimpleProblems problems = new SimpleProblems(); TextExtractorContext context = new TextExtractorContext(execContext, path(tempFile.getName()), inputProperties, "text/plain", problems); StringTextExtractorOutput output = new StringTextExtractorOutput(); extractor.setWriteLimit(stringLength); extractor.extractFrom(new FileInputStream(tempFile), output, context); assertTrue(problems.toString(), problems.isEmpty()); assertEquals(rndString, output.toString()); } finally { tempFile.delete(); } }
Source:
public int getPlacementPriority(BlockStateHolder block) { if (Blocks.shouldPlaceLate(block.getBlockType())) { return 1; } else if (Blocks.shouldPlaceLast(block.getBlockType())) { return 2; } else if (Blocks.shouldPlaceFinal(block.getBlockType())) { return 3; } else { return 0; } }

Target:
private PlacementPriority getPlacementPriority(BlockStateHolder block) { return priorityMap.getOrDefault(block.getBlockType(), PlacementPriority.FIRST); }
Source:
public Fragment getItem(int position) { String tabNumber = tabs.get(position); if(tabNumber.startsWith(TAB_NUMBER_KIOSK + "\t")) { String kiosk[] = tabNumber.split("\t"); if(kiosk.length==2) { KioskFragment fragment = null; try { fragment = KioskFragment.getInstance(currentServiceId, kiosk[1]); fragment.useAsFrontPage(true); return fragment; } catch (Exception e) { ErrorActivity.reportError(activity, e, activity.getClass(), null, ErrorActivity.ErrorInfo.make(UserAction.UI_ERROR, "none", "", R.string.app_ui_crash)); } } } else if(tabNumber.startsWith(TAB_NUMBER_CHANNEL + "\t")) { String channelInfo[] = tabNumber.split("\t"); if(channelInfo.length==4) { ChannelFragment fragment = ChannelFragment.getInstance(Integer.parseInt(channelInfo[3]), channelInfo[1], channelInfo[2]); fragment.useAsFrontPage(true); return fragment; } else { return new BlankFragment(); } } else { switch (tabNumber) { case TAB_NUMBER_BLANK: return new BlankFragment(); case TAB_NUMBER_SUBSCIRPTIONS: SubscriptionFragment sFragment = new SubscriptionFragment(); sFragment.useAsFrontPage(true); return sFragment; case TAB_NUMBER_FEED: FeedFragment fFragment = new FeedFragment(); fFragment.useAsFrontPage(true); return fFragment; case TAB_NUMBER_BOOKMARKS: BookmarkFragment bFragment = new BookmarkFragment(); bFragment.useAsFrontPage(true); return bFragment; case TAB_NUMBER_HISTORY: StatisticsPlaylistFragment cFragment = new StatisticsPlaylistFragment(); cFragment.useAsFrontPage(true); return cFragment; } } return new BlankFragment(); }

Target:
public Fragment getItem(int position) { String tabInformation = tabs.get(position); if(tabInformation.startsWith(TAB_NUMBER_KIOSK + "\t")) { String kiosk[] = tabInformation.split("\t"); if(kiosk.length==3) { KioskFragment fragment = null; try { fragment = KioskFragment.getInstance(Integer.parseInt(kiosk[2]), kiosk[1]); fragment.useAsFrontPage(true); return fragment; } catch (Exception e) { ErrorActivity.reportError(activity, e, activity.getClass(), null, ErrorActivity.ErrorInfo.make(UserAction.UI_ERROR, "none", "", R.string.app_ui_crash)); } } } else if(tabInformation.startsWith(TAB_NUMBER_CHANNEL + "\t")) { String channelInfo[] = tabInformation.split("\t"); if(channelInfo.length==4) { ChannelFragment fragment = ChannelFragment.getInstance(Integer.parseInt(channelInfo[3]), channelInfo[1], channelInfo[2]); fragment.useAsFrontPage(true); return fragment; } else { return new BlankFragment(); } } else { switch (tabInformation) { case TAB_NUMBER_BLANK: return new BlankFragment(); case TAB_NUMBER_SUBSCIRPTIONS: SubscriptionFragment sFragment = new SubscriptionFragment(); sFragment.useAsFrontPage(true); return sFragment; case TAB_NUMBER_FEED: FeedFragment fFragment = new FeedFragment(); fFragment.useAsFrontPage(true); return fFragment; case TAB_NUMBER_BOOKMARKS: BookmarkFragment bFragment = new BookmarkFragment(); bFragment.useAsFrontPage(true); return bFragment; case TAB_NUMBER_HISTORY: StatisticsPlaylistFragment cFragment = new StatisticsPlaylistFragment(); cFragment.useAsFrontPage(true); return cFragment; } } return new BlankFragment(); }
Source:
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_visit_dashboard); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); if (toolbar != null) { setSupportActionBar(toolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); } Intent intent = getIntent(); VisitDashboardFragment visitDashboardFragment = (VisitDashboardFragment) getSupportFragmentManager().findFragmentById(R.id.visitDashboardContentFrame); if (visitDashboardFragment == null) { visitDashboardFragment = VisitDashboardFragment.newInstance(); } addFragmentToActivity(getSupportFragmentManager(), visitDashboardFragment, R.id.visitDashboardContentFrame); mPresenter = new VisitDashboardPresenter(visitDashboardFragment, intent); }

Target:
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_visit_dashboard); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); if (toolbar != null) { setSupportActionBar(toolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); } Intent intent = getIntent(); VisitDashboardFragment visitDashboardFragment = (VisitDashboardFragment) getSupportFragmentManager().findFragmentById(R.id.visitDashboardContentFrame); if (visitDashboardFragment == null) { visitDashboardFragment = VisitDashboardFragment.newInstance(); } if (!visitDashboardFragment.isActive()) { addFragmentToActivity(getSupportFragmentManager(), visitDashboardFragment, R.id.visitDashboardContentFrame); } mPresenter = new VisitDashboardPresenter(visitDashboardFragment, intent.getLongExtra(ApplicationConstants.BundleKeys.VISIT_ID, 0)); }
Source:
private CompletableFuture<KieCompilationResponse> internalBuild(Path projectPath, String mavenRepoPath, String settingXML, boolean skipProjectDepCreation, String goal, Map<Path, InputStream> override) { WorkspaceCompilationInfo info = new WorkspaceCompilationInfo(projectPath); AFCompiler compiler = getCompiler(projectPath); CompilationRequest req; if(settingXML != null) { req = new DefaultCompilationRequest(mavenRepoPath, info, new String[]{MavenCLIArgs.ALTERNATE_USER_SETTINGS + settingXML, goal}, skipProjectDepCreation); }else{ req = new DefaultCompilationRequest(mavenRepoPath, info, new String[]{goal}, skipProjectDepCreation); } return CompletableFuture.supplyAsync(() -> ((KieCompilationResponse) compiler.compile(req, override)), executor); }

Target:
private CompletableFuture<KieCompilationResponse> internalBuild(Path projectPath, String mavenRepoPath, String settingXML, boolean skipProjectDepCreation, String goal, Map<Path, InputStream> override) { WorkspaceCompilationInfo info = new WorkspaceCompilationInfo(projectPath); AFCompiler compiler = getCompiler(projectPath); CompilationRequest req; if (settingXML != null) { req = getDefaultRequest(mavenRepoPath, info, skipProjectDepCreation, new String[]{MavenCLIArgs.ALTERNATE_USER_SETTINGS + settingXML, goal}); } else { req = getDefaultRequest(mavenRepoPath, info, skipProjectDepCreation, new String[]{goal}); } return CompletableFuture.supplyAsync(() -> ((KieCompilationResponse) compiler.compile(req, override)), executor); }
Source:
void removeRelation (int type, Accessible target) { AccessibleObject accessibleObject = target.getAccessibleObject(); if (accessibleObject!= null) { OS.atk_object_remove_relationship (handle, toATKRelation(type), accessibleObject.handle); } }

Target:
void removeRelation (int type, Accessible target) { AccessibleObject targetAccessibleObject = target.getAccessibleObject(); if (targetAccessibleObject != null) { OS.atk_object_remove_relationship (handle, toATKRelation(type), targetAccessibleObject.handle); } }
Source:
public Reader createReader(RuntimeContainer container) { return new CouchbaseReader(container, this); }

Target:
public Reader<IndexedRecord> createReader(RuntimeContainer container) { return new CouchbaseReader(container, this); }
Source:
public static void populate(Object object, Map<String, String> values) throws Exception { final Map<String, String> clonedValues = new HashMap<String, String>(values); final Set<String> candidates = new HashSet<String>(); final Class<?> clazz = object.getClass(); for (Method candidate : clazz.getMethods()) { String methodName = candidate.getName(); if (methodName.matches("^set[A-Z].*") && candidate.getReturnType().equals(Void.TYPE) && candidate.getParameterTypes().length == 1) { candidate.setAccessible(true); String propertyName = methodName.substring(3, 4).toLowerCase() + methodName.substring(4); candidates.add(propertyName); if (clonedValues.containsKey(propertyName)) { if (shouldBeTrimmed(clazz, propertyName)) { String trimmed = MultilineTrimmer.trim(clonedValues.get(propertyName)); clonedValues.put(propertyName, trimmed); } candidate.invoke( object, convert(candidate.getParameterTypes()[0], clonedValues.get(propertyName))); clonedValues.remove(propertyName); } } } if(!clonedValues.isEmpty()) { log.warning( "Configuration contain properties not supported by the backing object " + clazz.getName() + "\n" + "Unused property entries: " + clonedValues + "\n" + "Supported property names: " + candidates); } }

Target:
public static void populate(Object object, Map<String, String> values) throws Exception { final Map<String, String> clonedValues = new HashMap<String, String>(values); final Set<String> candidates = new HashSet<String>(); final Class<?> clazz = object.getClass(); for (Method candidate : clazz.getMethods()) { if (isSetter(candidate)) { candidate.setAccessible(true); final String methodName = candidate.getName(); String propertyName = methodName.substring(3, 4).toLowerCase() + methodName.substring(4); candidates.add(propertyName); if (clonedValues.containsKey(propertyName)) { if (shouldBeTrimmed(candidate)) { String trimmed = MultilineTrimmer.trim(clonedValues.get(propertyName)); clonedValues.put(propertyName, trimmed); } candidate.invoke( object, convert(candidate.getParameterTypes()[0], clonedValues.get(propertyName))); clonedValues.remove(propertyName); } } } if(!clonedValues.isEmpty()) { log.warning( "Configuration contain properties not supported by the backing object " + clazz.getName() + "\n" + "Unused property entries: " + clonedValues + "\n" + "Supported property names: " + candidates); } }
Source:
public long getLastModified(String src) { if (getCheckPeriod() < 0) return 1; URLConnection conn = null; try { final URL url = getExtendletContext().getResource(src); if (url != null) { conn = url.openConnection(); final long v = conn.getLastModified(); return v != -1 ? v : 0; } } catch (Throwable ex) { } finally { if (conn != null) { try { conn.getInputStream().close(); } catch (Exception ignored) { } } } return -1; }

Target:
public long getLastModified(String src) { if (getCheckPeriod() < 0) return 1; URLConnection conn = null; try { final URL url = getExtendletContext().getResource(src); if (url != null) { conn = url.openConnection(); final long v = conn.getLastModified(); return v != -1 ? v : 0; } } catch (Throwable ex) { } finally { if (conn != null) { try { conn.getInputStream().close(); } catch (Throwable e) { log.warn("The connection cannot be closed", e); } } } return -1; }
Source:
public final void connectServers(final AbstractServerWebSocketHandler parent) { try { createAndAddConnection(parent, isConnectionLocal(), "srl02.tamu.edu", PORT, this.isSecure(), SubmissionClientWebSocket.class); } catch (ConnectionException e) { LOG.info(LoggingConstants.EXCEPTION_MESSAGE, e); } }

Target:
public final void connectServers(final AbstractServerWebSocketHandler parent) { try { createAndAddConnection(parent, isConnectionLocal(), "srl02.tamu.edu", PORT, this.isSecure(), SubmissionClientWebSocket.class); } catch (ConnectionException e) { LOG.error(LoggingConstants.EXCEPTION_MESSAGE, e); } }
Source:
protected void cleanup() { try { try { epollFd.close(); } catch (IOException e) { logger.warn("Failed to close the epoll fd.", e); } try { WAKEN_UP_UPDATER.compareAndSet(this, WAKEUP_ALLOWED, WAKEUP_NOT_ALLOWED); while (wakenUp != WAKEUP_NOT_ALLOWED) { } eventFd.close(); } catch (IOException e) { logger.warn("Failed to close the event fd.", e); } try { timerFd.close(); } catch (IOException e) { logger.warn("Failed to close the timer fd.", e); } } finally { if (iovArray != null) { iovArray.release(); iovArray = null; } if (datagramPacketArray != null) { datagramPacketArray.release(); datagramPacketArray = null; } events.free(); } }

Target:
protected void cleanup() { try { try { epollFd.close(); } catch (IOException e) { logger.warn("Failed to close the epoll fd.", e); } try { if (!WAKEN_UP_UPDATER.compareAndSet(this, WAKEUP_ALLOWED, WAKEUP_NOT_ALLOWED)) { while (wakenUp != WAKEUP_NOT_ALLOWED) { } } eventFd.close(); } catch (IOException e) { logger.warn("Failed to close the event fd.", e); } try { timerFd.close(); } catch (IOException e) { logger.warn("Failed to close the timer fd.", e); } } finally { if (iovArray != null) { iovArray.release(); iovArray = null; } if (datagramPacketArray != null) { datagramPacketArray.release(); datagramPacketArray = null; } events.free(); } }
Source:
public String toString() { StringBuilder sb = new StringBuilder(); sb.append(this.getClass().getSimpleName()); sb.append("["); if (outputModuleId != null) { sb.append(outputModuleId); sb.append("."); sb.append(outputName); } if (reference != null) { sb.append(reference); } sb.append("->"); sb.append(inputName); sb.append("]"); return sb.toString(); }

Target:
public String toString() { StringBuilder sb = new StringBuilder(); sb.append(this.getClass().getSimpleName()); sb.append("["); if (outputModuleId != null) { sb.append(outputModuleId); sb.append("."); sb.append(outputName); } if (reference != null) { sb.append("("); sb.append(reference); sb.append(")"); } sb.append("->"); sb.append(inputName); sb.append("]"); return sb.toString(); }
Source:
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { if (!(request instanceof HttpServletRequest) || !(response instanceof HttpServletResponse) || monitoringDisabled || !instanceEnabled) { chain.doFilter(request, response); return; } final HttpServletRequest httpRequest = (HttpServletRequest) request; final HttpServletResponse httpResponse = (HttpServletResponse) response; if (httpRequest.getRequestURI().endsWith(getMonitoringUrl(httpRequest))) { doMonitoring(httpRequest, httpResponse); return; } if (!httpCounter.isDisplayed() || isRequestExcluded((HttpServletRequest) request)) { chain.doFilter(request, response); return; } doFilter(chain, httpRequest, httpResponse); }

Target:
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { if (!(request instanceof HttpServletRequest) || !(response instanceof HttpServletResponse) || monitoringDisabled || !instanceEnabled) { chain.doFilter(request, response); return; } final HttpServletRequest httpRequest = (HttpServletRequest) request; final HttpServletResponse httpResponse = (HttpServletResponse) response; if (httpRequest.getRequestURI().equals(getMonitoringUrl(httpRequest)) || (Parameters.getMonitoringPathAuthenticated() != null && httpRequest.getRequestURI().equals(getMonitoringPathAuthenticated(httpRequest)))) { doMonitoring(httpRequest, httpResponse); return; } if (!httpCounter.isDisplayed() || isRequestExcluded((HttpServletRequest) request)) { chain.doFilter(request, response); return; } doFilter(chain, httpRequest, httpResponse); }
Source:
SolrClient createSolrHttpClient(String coreName) throws IOException, SolrServerException { final HttpClientBuilder httpClientBuilder = createHttpBuilder(); final HttpSolrClient.Builder solrClientBuilder = new HttpSolrClient.Builder(getCoreUrl(coreName)); try (final Closer closer = new Closer()) { createSolrCore(coreName, httpClientBuilder.build()); CloseableHttpClient noRetryHttpClient = httpClientBuilder.build(); final HttpSolrClient noRetrySolrClient = closer.with(solrClientBuilder.withHttpClient(noRetryHttpClient).build()); CloseableHttpClient yesRetryHttpClient = httpClientBuilder.setRetryHandler(new SolrHttpRequestRetryHandler(coreName)).build(); final HttpSolrClient retrySolrClient = closer.with(solrClientBuilder.withHttpClient(yesRetryHttpClient).build()); return closer.returning(new PingAwareSolrClientProxy(retrySolrClient, noRetrySolrClient)); } }

Target:
SolrClient createSolrHttpClient(String coreName) throws IOException, SolrServerException { final HttpClientBuilder httpClientBuilder = createHttpBuilder(); final HttpSolrClient.Builder solrClientBuilder = new HttpSolrClient.Builder(solrSettings.getCoreUrl(coreName)); try (final Closer closer = new Closer()) { createSolrCore(coreName, closer.with(httpClientBuilder.build())); CloseableHttpClient noRetryHttpClient = httpClientBuilder.build(); closer.with(noRetryHttpClient); CloseableHttpClient yesRetryHttpClient = httpClientBuilder.setRetryHandler(new SolrHttpRequestRetryHandler(coreName)).build(); closer.with(yesRetryHttpClient); final HttpSolrClient noRetrySolrClient = solrClientBuilder.withHttpClient(noRetryHttpClient).build(); final HttpSolrClient retrySolrClient = solrClientBuilder.withHttpClient(yesRetryHttpClient).build(); return closer.returning(new PingAwareSolrClientProxy(retrySolrClient, noRetrySolrClient)); } }
Source:
public void run() { Stopwatch stopwatch = Stopwatch.createStarted(); while (stopwatch.elapsed(TimeUnit.MILLISECONDS) < timeouts.getWatchTimeoutMs()) { try (LogWatch logWatch = client .pods() .inNamespace(namespace) .withName(podName) .inContainer(containerName) .watchLog()) { synchronized (this) { if (closed.get()) { return; } currentLogWatch = logWatch; } if (!readAndHandle(currentLogWatch.getOutput(), logHandler)) { LOG.trace( "failed to get the logs for '{} : : {}'. Container probably still starting after [{}]ms.", namespace, podName, containerName, stopwatch.elapsed(TimeUnit.MILLISECONDS)); Thread.sleep(timeouts.getWaitBeforeNextTry()); } else { LOG.debug( "finished watching the logs of '{} : : {}'", namespace, podName, containerName); return; } } catch (InterruptedException e) { LOG.error( "Failed watch the logs '{} : : {}', nothing better to do here.", namespace, podName, containerName, e); return; } } }

Target:
public void run() { Stopwatch stopwatch = Stopwatch.createStarted(); while (stopwatch.elapsed(TimeUnit.MILLISECONDS) < timeouts.getWatchTimeoutMs()) { try (LogWatch logWatch = client .pods() .inNamespace(namespace) .withName(podName) .inContainer(containerName) .watchLog()) { synchronized (this) { if (closed) { return; } currentLogWatch = logWatch; } if (currentLogWatch.getOutput() == null || !readAndHandle( ByteStreams.limit(currentLogWatch.getOutput(), inputStreamLimit), logHandler)) { LOG.trace( "failed to get the logs for '{} : : {}'. Container probably still starting after [{}]ms.", namespace, podName, containerName, stopwatch.elapsed(TimeUnit.MILLISECONDS)); Thread.sleep(timeouts.getWaitBeforeNextTry()); } else { LOG.debug( "finished watching the logs of '{} : : {}'", namespace, podName, containerName); return; } } catch (InterruptedException e) { LOG.error( "Failed watch the logs '{} : : {}', nothing better to do here.", namespace, podName, containerName, e); return; } } }
Source:
public Page<E> asPage() { Objects.requireNonNull(webContext); Watch w = Watch.start(); Page<E> result = new Page<E>().withStart(1).withPageSize(pageSize); result.bindToRequest(webContext); if (Strings.isFilled(result.getQuery()) && !searchFields.isEmpty()) { baseQuery.where(baseQuery.filters() .queryString(baseQuery.getDescriptor(), result.getQuery(), searchFields)); } applyFacets(result); try { setupPaging(result); List<E> items = executeQuery(); enforcePaging(result, items); fillPage(w, result, items); } catch (Exception e) { UserContext.handle(e); } return result; }

Target:
public Page<E> asPage() { Objects.requireNonNull(webContext); Watch w = Watch.start(); Page<E> result = new Page<E>().withStart(1).withPageSize(pageSize); result.bindToRequest(webContext); applyQuery(result.getQuery()); applyFacets(result); try { setupPaging(result); List<E> items = executeQuery(); enforcePaging(result, items); fillPage(w, result, items); } catch (Exception e) { UserContext.handle(e); } return result; }
Source:
public static AuditMessageType.ActiveParticipant createActiveParticipantFromUser(final UserType userInfo, final Boolean userIsReq) { final AuditMessageType.ActiveParticipant participant = new AuditMessageType.ActiveParticipant(); if (ipAddr == null) { try { ipAddr = InetAddress.getLocalHost().getHostAddress(); } catch (final UnknownHostException ex) { LOG.error("UnknownHostException thrown getting local host address: {}", ex.getLocalizedMessage(), ex); throw new RuntimeException(); } } String userId = null; if (userInfo != null && userInfo.getUserName() != null && userInfo.getUserName().length() > 0) { userId = userInfo.getUserName(); } if (userId != null) { participant.setUserID(userId); } String userName = null; if (userInfo != null && userInfo.getPersonName() != null) { if (userInfo.getPersonName().getGivenName() != null && userInfo.getPersonName().getGivenName().length() > 0) { userName = userInfo.getPersonName().getGivenName(); } if (userInfo.getPersonName().getFamilyName() != null && userInfo.getPersonName().getFamilyName().length() > 0) { if (userName != null) { userName += " " + userInfo.getPersonName().getFamilyName(); } else { userName = userInfo.getPersonName().getFamilyName(); } } } if (userName != null) { participant.setUserName(userName); } participant.setUserIsRequestor(userIsReq); participant.setNetworkAccessPointID(ipAddr); participant.setNetworkAccessPointTypeCode(AuditDataTransformConstants.NETWORK_ACCESSOR_PT_TYPE_CODE_IP); return participant; }

Target:
public static AuditMessageType.ActiveParticipant createActiveParticipantFromUser(final UserType userInfo, final Boolean userIsReq) { final AuditMessageType.ActiveParticipant participant = new AuditMessageType.ActiveParticipant(); if (ipAddr == null) { try { ipAddr = InetAddress.getLocalHost().getHostAddress(); } catch (final UnknownHostException ex) { LOG.error("UnknownHostException thrown getting local host address: {}", ex.getLocalizedMessage(), ex); throw new RuntimeException(); } } String userId = null; if (userInfo != null && userInfo.getUserName() != null && userInfo.getUserName().length() > 0) { userId = userInfo.getUserName(); } if (userId != null) { participant.setUserID(userId); } String userName = null; if (userInfo != null && userInfo.getPersonName() != null) { if (StringUtils.isNotEmpty(userInfo.getPersonName().getGivenName())) { userName = userInfo.getPersonName().getGivenName(); } if (StringUtils.isNotEmpty(userInfo.getPersonName().getFamilyName())) { if (userName != null) { userName += " " + userInfo.getPersonName().getFamilyName(); } else { userName = userInfo.getPersonName().getFamilyName(); } } } if (userName != null) { participant.setUserName(userName); } participant.setUserIsRequestor(userIsReq); participant.setNetworkAccessPointID(ipAddr); participant.setNetworkAccessPointTypeCode(AuditDataTransformConstants.NETWORK_ACCESSOR_PT_TYPE_CODE_IP); return participant; }
Source:
public String parseMessage(HttpResponse response) { if (response.getPayload() == null) return null; try { return Strings2.toString(response.getPayload()); } catch (IOException e) { throw Throwables.propagate(e); } finally { try { response.getPayload().getInput().close(); } catch (IOException e) { throw Throwables.propagate(e); } } }

Target:
public String parseMessage(HttpResponse response) { if (response.getPayload() == null) return null; try { return Strings2.toString(response.getPayload()); } catch (IOException e) { throw Throwables.propagate(e); } finally { try { response.getPayload().close(); } catch (IOException e) { throw Throwables.propagate(e); } } }
Source:
public ActionResult execute() { String courseId = getRequestParamValue(Const.ParamsNames.COURSE_ID); if (courseId != null) { if (logic.getCourse(courseId) == null) { return new JsonResult("No course with id: " + courseId, HttpStatus.SC_NOT_FOUND); } boolean hasResponses = logic.hasResponsesForCourse(courseId); return new JsonResult(new HasResponsesData(hasResponses)); } String feedbackQuestionID = getRequestParamValue(Const.ParamsNames.FEEDBACK_QUESTION_ID); if (feedbackQuestionID != null) { if (logic.getFeedbackQuestion(feedbackQuestionID) == null) { return new JsonResult("No feedback question with id: " + feedbackQuestionID, HttpStatus.SC_NOT_FOUND); } boolean hasResponses = logic.areThereResponsesForQuestion(feedbackQuestionID); return new JsonResult(new HasResponsesData(hasResponses)); } throw new InvalidHttpParameterException("At least courseid or questionid must be supplied"); }

Target:
public ActionResult execute() { String feedbackQuestionID = getRequestParamValue(Const.ParamsNames.FEEDBACK_QUESTION_ID); if (feedbackQuestionID != null) { if (logic.getFeedbackQuestion(feedbackQuestionID) == null) { return new JsonResult("No feedback question with id: " + feedbackQuestionID, HttpStatus.SC_NOT_FOUND); } boolean hasResponses = logic.areThereResponsesForQuestion(feedbackQuestionID); return new JsonResult(new HasResponsesData(hasResponses)); } String courseId = getNonNullRequestParamValue(Const.ParamsNames.COURSE_ID); if (logic.getCourse(courseId) == null) { return new JsonResult("No course with id: " + courseId, HttpStatus.SC_NOT_FOUND); } boolean hasResponses = logic.hasResponsesForCourse(courseId); return new JsonResult(new HasResponsesData(hasResponses)); }