auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
public void setUp() throws Exception { response = mock(HttpServletResponse.class); request = mock(HttpServletRequest.class); securityService = mock(SecurityService.class); authenticationPluginRegistry = mock(AuthenticationPluginRegistry.class); localizer = mock(Localizer.class); authorizationController = new AuthorizationController(localizer, authenticationPluginRegistry); }

Target:
public void setUp() throws Exception { authenticationPluginRegistry = mock(AuthenticationPluginRegistry.class); localizer = mock(Localizer.class); authorizationController = new AuthorizationController(localizer, authenticationPluginRegistry); response = new MockHttpServletResponse(); }
Source:
public static void checkArgument(boolean expression, @Nullable String messageTemplate, @Nullable Object... messageArgs) { try { Preconditions.checkArgument(expression, messageTemplate, messageArgs); } catch (IllegalArgumentException e) { throw new BadRequestException(e.getMessage(), e); } }

Target:
public static void checkArgument(boolean expression, @Nullable String messageTemplate, @Nullable Object... messageArgs) { if (!expression) { throw new BadRequestException(format(messageTemplate, messageArgs)); } }
Source:
private void createDatastreamForDSM(ZkClient zkClient, String cluster, String connectorType, String... datastreamNames) { for (String datastreamName : datastreamNames) { zkClient.ensurePath(KeyBuilder.datastreams(cluster)); KafkaConnection conn = new KafkaConnection(); conn.setTopicName("dummyTopic"); conn.setPartitions(1); conn.setMetadataBrokers("localhost:11111"); Datastream datastream = new Datastream(); datastream.setName(datastreamName); datastream.setConnectorType(connectorType); datastream.setSource("tscp"); Datastream.Target target = new Datastream.Target(); target.setKafkaConnection(conn); datastream.setTarget(target); ZookeeperBackedDatastreamStore dsStore = new ZookeeperBackedDatastreamStore(zkClient, cluster); dsStore.createDatastream(datastream.getName(), datastream); } }

Target:
private void createDatastreamForDSM(ZkClient zkClient, String cluster, String connectorType, String... datastreamNames) { for (String datastreamName : datastreamNames) { zkClient.ensurePath(KeyBuilder.datastreams(cluster)); KafkaConnection conn = new KafkaConnection(); conn.setTopicName("dummyTopic"); conn.setPartitions(1); conn.setMetadataBrokers("localhost:11111"); Datastream datastream = new Datastream(); datastream.setName(datastreamName); datastream.setConnectorType(connectorType); datastream.setSource("sampleSource"); Datastream.Target target = new Datastream.Target(); target.setKafkaConnection(conn); datastream.setTarget(target); ZookeeperBackedDatastreamStore dsStore = new ZookeeperBackedDatastreamStore(zkClient, cluster); dsStore.createDatastream(datastream.getName(), datastream); } }
Source:
private EhcacheEntityResponse invokeLifeCycleOperation(ClientDescriptor clientDescriptor, LifecycleMessage message) throws ClusterException { switch (message.operation()) { case CONFIGURE: configure(clientDescriptor, (ConfigureStoreManager) message); break; case VALIDATE: validate(clientDescriptor, (ValidateStoreManager) message); break; case CREATE_SERVER_STORE: createServerStore(clientDescriptor, (CreateServerStore) message); break; case VALIDATE_SERVER_STORE: validateServerStore(clientDescriptor, (ValidateServerStore) message); break; case RELEASE_SERVER_STORE: releaseServerStore(clientDescriptor, (ReleaseServerStore) message); break; case DESTROY_SERVER_STORE: destroyServerStore(clientDescriptor, (DestroyServerStore) message); break; case CREATE_CLUSTERED_MAP: createConcurrentMap(clientDescriptor, (CreateClusteredMap) message); break; default: throw new IllegalMessageException("Unknown LifeCycle operation " + message); } return responseFactory.success(); }

Target:
private EhcacheEntityResponse invokeLifeCycleOperation(ClientDescriptor clientDescriptor, LifecycleMessage message) throws ClusterException { switch (message.operation()) { case CONFIGURE: configure(clientDescriptor, (ConfigureStoreManager) message); break; case VALIDATE: validate(clientDescriptor, (ValidateStoreManager) message); break; case CREATE_SERVER_STORE: createServerStore(clientDescriptor, (CreateServerStore) message); break; case VALIDATE_SERVER_STORE: validateServerStore(clientDescriptor, (ValidateServerStore) message); break; case RELEASE_SERVER_STORE: releaseServerStore(clientDescriptor, (ReleaseServerStore) message); break; case DESTROY_SERVER_STORE: destroyServerStore(clientDescriptor, (DestroyServerStore) message); break; default: throw new IllegalMessageException("Unknown LifeCycle operation " + message); } return responseFactory.success(); }
Source:
public static String getUrlAsString(String urlStr) { StringBuilder sb = new StringBuilder(); try { URL url = new URL(urlStr); InputStream is = url.openStream(); BufferedReader br = new BufferedReader(new InputStreamReader(is)); String line; while ( (line = br.readLine()) != null) sb.append(line); closeQuietly(br); closeQuietly(is); } catch (Exception e) { if (Sage.DBG) { e.printStackTrace(); } } return sb.toString(); }

Target:
public static String getUrlAsString(String urlStr) { StringBuilder sb = new StringBuilder(); try { URL url = new URL(urlStr); return getInputStreamAsString(url.openStream()); } catch (Exception e) { if (Sage.DBG) { System.out.println("Failed to read URL to string for " + urlStr); e.printStackTrace(); } } return sb.toString(); }
Source:
public static PaletteGroup getPaletteGroup(Palette palette, IContainer groupDst) { String[] groups = groupDst.getProjectRelativePath().toString().split("/"); if ((0 == groups.length) || ((1 == groups.length) && (0 == groups[0].length()))) { return palette.getRootGroup(); } ArrayList<String> groupList = new ArrayList<String>(); groupList.addAll(Arrays.asList(groups)); if (TypeLibraryTags.TOOL_LIBRARY_PROJECT_NAME.equals(groupList.get(0))) { groupList.remove(0); } return palette.findGroup(groupList); }

Target:
public static PaletteGroup getPaletteGroup(Palette palette, IContainer groupDst) { String[] groups = groupDst.getProjectRelativePath().toString().split("/"); if ((0 == groups.length) || ((1 == groups.length) && (0 == groups[0].length()))) { return palette.getRootGroup(); } List<String> groupList = new ArrayList<>(); groupList.addAll(Arrays.asList(groups)); if (TypeLibraryTags.TOOL_LIBRARY_PROJECT_NAME.equals(groupList.get(0))) { groupList.remove(0); } return palette.findGroup(groupList); }
Source:
protected void buildVmCD() { XmlRpcStruct struct; if (vm.getVmPayload() != null && vm.getVmPayload().getType() == VmDeviceType.CDROM) { VmDevice vmDevice = new VmDevice(new VmDeviceId(Guid.NewGuid(), vm.getId()), VmDeviceType.DISK.getName(), VmDeviceType.CDROM.getName(), "", 0, (vm.getVmPayload() == null) ? null : vm.getVmPayload().getSpecParams(), true, true, true, ""); struct = new XmlRpcStruct(); addCdDetails(vmDevice, struct); addDevice(struct, vmDevice, ""); } if (vm.isRunOnce() && !StringUtils.isEmpty(vm.getCdPath())) { VmDevice vmDevice = new VmDevice(new VmDeviceId(Guid.NewGuid(), vm.getId()), VmDeviceType.DISK.getName(), VmDeviceType.CDROM.getName(), "", 0, (vm.getVmPayload() == null) ? null : vm.getVmPayload().getSpecParams(), true, true, true, ""); struct = new XmlRpcStruct(); addCdDetails(vmDevice, struct); addDevice(struct, vmDevice, vm.getCdPath()); } else { List<VmDevice> vmDevices = DbFacade.getInstance() .getVmDeviceDao() .getVmDeviceByVmIdTypeAndDevice(vm.getId(), VmDeviceType.DISK.getName(), VmDeviceType.CDROM.getName()); for (VmDevice vmDevice : vmDevices) { if (!vmDevice.getIsManaged()) { continue; } boolean isPayload = (VmPayload.isPayload(vmDevice.getSpecParams()) && vmDevice.getDevice().equals(VmDeviceType.CDROM.getName())); struct = new XmlRpcStruct(); String cdPath = vm.getCdPath(); addCdDetails(vmDevice, struct); if (isPayload) { struct.add(VdsProperties.Index, "3"); } addAddress(vmDevice, struct); addDevice(struct, vmDevice, (cdPath == null && !isPayload) ? "" : cdPath); } } }

Target:
protected void buildVmCD() { XmlRpcStruct struct; if (vm.getVmPayload() != null && vm.getVmPayload().getType() == VmDeviceType.CDROM) { VmDevice vmDevice = new VmDevice(new VmDeviceId(Guid.NewGuid(), vm.getId()), VmDeviceType.DISK.getName(), VmDeviceType.CDROM.getName(), "", 0, (vm.getVmPayload() == null) ? null : vm.getVmPayload().getSpecParams(), true, true, true, ""); struct = new XmlRpcStruct(); addCdDetails(vmDevice, struct); addDevice(struct, vmDevice, ""); } if (vm.isRunOnce() && !StringUtils.isEmpty(vm.getCdPath())) { VmDevice vmDevice = new VmDevice(new VmDeviceId(Guid.NewGuid(), vm.getId()), VmDeviceType.DISK.getName(), VmDeviceType.CDROM.getName(), "", 0, (vm.getVmPayload() == null) ? null : vm.getVmPayload().getSpecParams(), true, true, true, ""); struct = new XmlRpcStruct(); addCdDetails(vmDevice, struct); addDevice(struct, vmDevice, vm.getCdPath()); } else { List<VmDevice> vmDevices = DbFacade.getInstance() .getVmDeviceDao() .getVmDeviceByVmIdTypeAndDevice(vm.getId(), VmDeviceType.DISK.getName(), VmDeviceType.CDROM.getName()); for (VmDevice vmDevice : vmDevices) { if (!vmDevice.getIsManaged()) { continue; } struct = new XmlRpcStruct(); String cdPath = vm.getCdPath(); addCdDetails(vmDevice, struct); addAddress(vmDevice, struct); addDevice(struct, vmDevice, cdPath == null ? "" : cdPath); } } }
Source:
void shouldBeAbleHandleNOOPsDuringRunCypher() throws Exception { StubServer server = StubServer.start( "noop.script", 9001 ); URI uri = URI.create( "bolt://127.0.0.1:9001" ); int x; try ( Driver driver = GraphDatabase.driver( uri, INSECURE_CONFIG ) ) { try ( Session session = driver.session() ) { List<String> names = session.run( "MATCH (n) RETURN n.name" ).list( rec -> rec.get( 0 ).asString() ); assertEquals( asList( "Foo", "Bar", "Baz" ), names ); } } assertThat( server.exitStatus(), equalTo( 0 ) ); }

Target:
void shouldBeAbleHandleNOOPsDuringRunCypher() throws Exception { StubServer server = StubServer.start( "noop.script", 9001 ); URI uri = URI.create( "bolt://127.0.0.1:9001" ); try ( Driver driver = GraphDatabase.driver( uri, INSECURE_CONFIG ) ) { try ( Session session = driver.session() ) { List<String> names = session.run( "MATCH (n) RETURN n.name" ).list( rec -> rec.get( 0 ).asString() ); assertEquals( asList( "Foo", "Bar", "Baz" ), names ); } } assertThat( server.exitStatus(), equalTo( 0 ) ); }
Source:
private void logEnabledExtensions() { log.info("Start of enabled extensions list"); for (ExtensionEntry entry: loadedEntries.values()) { if (entry.extension != null && entry.enabled) { Map<ExtensionProperties, Object> context = entry.extension.getContext(); log.info(String.format( "Instance name: '%1$s', Extension name: '%2$s', Author '%3$s', Version '%4$s', Home: '%5$s' License: '%6$s' File: '%7$s'", emptyIfNull(context.get(ExtensionProperties.NAME)), emptyIfNull(context.get(ExtensionProperties.EXTENSION_NAME)), emptyIfNull(context.get(ExtensionProperties.AUTHOR)), emptyIfNull(context.get(ExtensionProperties.VERSION)), emptyIfNull(context.get(ExtensionProperties.HOME)), emptyIfNull(context.get(ExtensionProperties.LICENSE)), emptyIfNull(entry.file) ) ); } } log.info("End of enabled extensions list"); }

Target:
private void logEnabledExtensions() { log.info("Start of enabled extensions list"); for (ExtensionEntry entry: loadedEntries.values()) { if (entry.extension != null) { Map<ExtensionProperties, Object> context = entry.extension.getContext(); log.info(String.format( "Instance name: '%1$s', Extension name: '%2$s', Version: '%3$s', License: '%4$s', Home: '%5$s', Author '%6$s', File: '%7$s'", emptyIfNull(context.get(ExtensionProperties.NAME)), emptyIfNull(context.get(ExtensionProperties.EXTENSION_NAME)), emptyIfNull(context.get(ExtensionProperties.VERSION)), emptyIfNull(context.get(ExtensionProperties.LICENSE)), emptyIfNull(context.get(ExtensionProperties.HOME)), emptyIfNull(context.get(ExtensionProperties.AUTHOR)), emptyIfNull(entry.file) ) ); } } log.info("End of enabled extensions list"); }
Source:
private static RowOrderAndPostAggregations computePostAggregations( PlannerContext plannerContext, RowSignature inputRowSignature, Project project, int outputNameCounter ) { final List<String> rowOrder = new ArrayList<>(); final List<Aggregation> aggregations = new ArrayList<>(); for (final RexNode postAggregatorRexNode : project.getChildExps()) { final DruidExpression postAggregatorExpression = Expressions.toDruidExpression( plannerContext, inputRowSignature, postAggregatorRexNode ); if (postAggregatorExpression == null) { throw new CannotBuildQueryException(project, postAggregatorRexNode); } if (postAggregatorDirectColumnIsOk(inputRowSignature, postAggregatorExpression, postAggregatorRexNode)) { rowOrder.add(postAggregatorExpression.getDirectColumn()); } else { final String postAggregatorName = "p" + outputNameCounter++; final PostAggregator postAggregator = new ExpressionPostAggregator( postAggregatorName, postAggregatorExpression.getExpression(), null, plannerContext.getExprMacroTable() ); aggregations.add(Aggregation.create(postAggregator)); rowOrder.add(postAggregator.getName()); } } return new RowOrderAndPostAggregations(rowOrder, aggregations); }

Target:
private static ProjectRowOrderAndPostAggregations computePostAggregations( PlannerContext plannerContext, RowSignature inputRowSignature, Project project, int outputNameCounter ) { final List<String> rowOrder = new ArrayList<>(); final List<PostAggregator> aggregations = new ArrayList<>(); for (final RexNode postAggregatorRexNode : project.getChildExps()) { final DruidExpression postAggregatorExpression = Expressions.toDruidExpression( plannerContext, inputRowSignature, postAggregatorRexNode ); if (postAggregatorExpression == null) { throw new CannotBuildQueryException(project, postAggregatorRexNode); } if (postAggregatorDirectColumnIsOk(inputRowSignature, postAggregatorExpression, postAggregatorRexNode)) { rowOrder.add(postAggregatorExpression.getDirectColumn()); } else { final String postAggregatorName = "p" + outputNameCounter++; final PostAggregator postAggregator = new ExpressionPostAggregator( postAggregatorName, postAggregatorExpression.getExpression(), null, plannerContext.getExprMacroTable() ); aggregations.add(postAggregator); rowOrder.add(postAggregator.getName()); } } return new ProjectRowOrderAndPostAggregations(rowOrder, aggregations); }
Source:
public Set<ScanFilter> getScanFilters() { return scanFilters; }

Target:
List<ScanFilter> getScanFilters() { return scanFilters; }
Source:
private String constructName(ITestNGMethod method) { return method.getConstructorOrMethod().getDeclaringClass().getSimpleName() + "." + method.getMethodName(); }

Target:
private static String constructName(ITestNGMethod method) { return method.getConstructorOrMethod().getDeclaringClass().getSimpleName() + "." + method.getMethodName(); }
Source:
public List<String> getFiles(GerritQueryHandler gerritQueryHandler) { return change.getFiles(gerritQueryHandler); }

Target:
public List<String> getFiles(GerritQueryHandler gerritQueryHandler) { List<String> files = change.getFiles(gerritQueryHandler); if (files == null) { return Collections.emptyList(); } return files; }
Source:
public static BufferedImage getScreenshot(HWND target) { GDI32 gdi32 = GDI32.INSTANCE; User32 user32 = User32.INSTANCE; RECT rect = new RECT(); user32.GetWindowRect(target, rect); Rectangle rectangle = rect.toRectangle(); HDC hdcTarget = user32.GetDC(target); HDC hdcTargetMem = gdi32.CreateCompatibleDC(hdcTarget); HBITMAP hBitmap = gdi32.CreateCompatibleBitmap(hdcTarget, rectangle.width, rectangle.height); HANDLE hdcTargetOld = gdi32.SelectObject(hdcTargetMem, hBitmap); gdi32.BitBlt(hdcTargetMem, 0, 0, rectangle.width, rectangle.height, hdcTarget, 0, 0, GDI32.SRCCOPY); gdi32.SelectObject(hdcTargetMem, hdcTargetOld); gdi32.DeleteDC(hdcTargetMem); BITMAPINFO bmi = new BITMAPINFO(); bmi.bmiHeader.biWidth = rectangle.width; bmi.bmiHeader.biHeight = -rectangle.height; bmi.bmiHeader.biPlanes = 1; bmi.bmiHeader.biBitCount = 32; bmi.bmiHeader.biCompression = WinGDI.BI_RGB; Memory buffer = new Memory(rectangle.width * rectangle.height * 4); gdi32.GetDIBits(hdcTarget, hBitmap, 0, rectangle.height, buffer, bmi, WinGDI.DIB_RGB_COLORS); BufferedImage image = new BufferedImage(rectangle.width, rectangle.height, BufferedImage.TYPE_INT_RGB); image.setRGB(0, 0, rectangle.width, rectangle.height, buffer.getIntArray(0, rectangle.width * rectangle.height), 0, rectangle.width); gdi32.DeleteObject(hBitmap); user32.ReleaseDC(target, hdcTarget); return image; }

Target:
public static BufferedImage getScreenshot(HWND target) { RECT rect = new RECT(); User32.INSTANCE.GetWindowRect(target, rect); Rectangle rectangle = rect.toRectangle(); HDC hdcTarget = User32.INSTANCE.GetDC(target); HDC hdcTargetMem = GDI32.INSTANCE.CreateCompatibleDC(hdcTarget); HBITMAP hBitmap = GDI32.INSTANCE.CreateCompatibleBitmap(hdcTarget, rectangle.width, rectangle.height); HANDLE hdcTargetOld = GDI32.INSTANCE.SelectObject(hdcTargetMem, hBitmap); GDI32.INSTANCE.BitBlt(hdcTargetMem, 0, 0, rectangle.width, rectangle.height, hdcTarget, 0, 0, GDI32.SRCCOPY); GDI32.INSTANCE.SelectObject(hdcTargetMem, hdcTargetOld); GDI32.INSTANCE.DeleteDC(hdcTargetMem); BITMAPINFO bmi = new BITMAPINFO(); bmi.bmiHeader.biWidth = rectangle.width; bmi.bmiHeader.biHeight = -rectangle.height; bmi.bmiHeader.biPlanes = 1; bmi.bmiHeader.biBitCount = 32; bmi.bmiHeader.biCompression = WinGDI.BI_RGB; Memory buffer = new Memory(rectangle.width * rectangle.height * 4); GDI32.INSTANCE.GetDIBits(hdcTarget, hBitmap, 0, rectangle.height, buffer, bmi, WinGDI.DIB_RGB_COLORS); BufferedImage image = new BufferedImage(rectangle.width, rectangle.height, BufferedImage.TYPE_INT_RGB); image.setRGB(0, 0, rectangle.width, rectangle.height, buffer.getIntArray(0, rectangle.width * rectangle.height), 0, rectangle.width); GDI32.INSTANCE.DeleteObject(hBitmap); User32.INSTANCE.ReleaseDC(target, hdcTarget); return image; }
Source:
private ApiInfo apiInfo() { return new ApiInfoBuilder() .title("Jagger as a Service") .description("Some neat description") .license("Do we have some kind of license?") .licenseUrl("In case we have the one, there might be an URL to such") .version("1.2.6") .build(); }

Target:
private ApiInfo apiInfo() { return new ApiInfoBuilder() .title("Jagger as a Service") .description("JaaS in a main artifact in Jagger 2. It is an always listening component.\n\n" + "It provides different information through its REST API.\n\n" + "JaaS artifact packed as an all in jar (with all dependencies inside) with embedded Tomcat.\n\n" + "JaaS based on Spring Boot, so its properties can be configured using one of Spring Boot ways" + "By default JaaS is listening on port 8080.\n" + "To change it just override property \"server.port\".") .license("GNU LESSER GENERAL PUBLIC LICENSE Version 2.1") .licenseUrl("<LINK_1>") .version(version) .build(); }
Source:
public static Pair<Ritual, EnumFacing> getRitualFromRuins(TileMasterRitualStone tile) { BlockPos pos = tile.getPos(); World world = tile.getWorld(); Ritual possibleRitual = null; EnumFacing possibleDirection = null; int highestCount = 0; for (Ritual ritual : BloodMagic.RITUAL_MANAGER.getRituals()) { for (EnumFacing direction : EnumFacing.HORIZONTALS) { List<RitualComponent> components = Lists.newArrayList(); ritual.gatherComponents(components::add); int currentCount = 0; for (RitualComponent component : components) { BlockPos newPos = pos.add(component.getOffset(direction)); if (isRuneType(world, newPos, component.getRuneType())) currentCount += 1; } if (currentCount > highestCount) { highestCount = currentCount; possibleRitual = ritual; possibleDirection = direction; } } } return Pair.of(possibleRitual, possibleDirection); }

Target:
public static Pair<Ritual, EnumFacing> getRitualFromRuins(TileMasterRitualStone tile) { BlockPos pos = tile.getPos(); World world = tile.getWorld(); Ritual possibleRitual = tile.getCurrentRitual(); EnumFacing possibleDirection = tile.getDirection(); int highestCount = 0; if (possibleRitual == null || possibleDirection == null) for (Ritual ritual : BloodMagic.RITUAL_MANAGER.getRituals()) { for (EnumFacing direction : EnumFacing.HORIZONTALS) { List<RitualComponent> components = Lists.newArrayList(); ritual.gatherComponents(components::add); int currentCount = 0; for (RitualComponent component : components) { BlockPos newPos = pos.add(component.getOffset(direction)); if (isRuneType(world, newPos, component.getRuneType())) currentCount += 1; } if (currentCount > highestCount) { highestCount = currentCount; possibleRitual = ritual; possibleDirection = direction; } } } return Pair.of(possibleRitual, possibleDirection); }
Source:
public HTTPResponse sendRequest(IAuthenticate auth) throws Exception { HttpClient client; if(insecure) { client = HTTPUtils.getHttpClientWithNoSSLValidation(); } else { client = new DefaultHttpClient(); } if(type == RequestType.GET) { HttpGet get = new HttpGet(url); req=get; } else { HttpPost post = new HttpPost(url); if(entity != null) post.setEntity(entity); req = post; if (connectionTimeout > 0.0) { HttpParams httpParams = new BasicHttpParams(); int cto = (int)(connectionTimeout * 1000.0); HttpConnectionParams.setConnectionTimeout(httpParams, cto ); post.setParams(httpParams); } } if(headers.size() > 0) { for(Entry<String, String> entry : headers.entrySet()) { req.setHeader(entry.getKey(), entry.getValue()); } } auth.sign(this); return new HTTPResponse(client.execute(req)); }

Target:
public HTTPResponse sendRequest(IAuthenticate auth) throws Exception { HttpClient client; if(insecure) { client = HTTPUtils.getHttpClientWithNoSSLValidation(); } else { client = new DefaultHttpClient(); } if(type == RequestType.GET) { HttpGet get = new HttpGet(url); req=get; } else { HttpPost post = new HttpPost(url); if(entity != null) { post.setEntity(entity); } req = post; if (httpParams == null) { httpParams = new BasicHttpParams(); int cto = (int)(connectionTimeout * 1000.0); HttpConnectionParams.setConnectionTimeout(httpParams, cto ); } post.setParams(httpParams); } if(headers.size() > 0) { for(Entry<String, String> entry : headers.entrySet()) { req.setHeader(entry.getKey(), entry.getValue()); } } auth.sign(this); return new HTTPResponse(client.execute(req)); }
Source:
public static String addIndent(String content, int numberOfIndents) { if (numberOfIndents <= 0) { return content; } else { final String lineIndent = IntStream.range(0, numberOfIndents).mapToObj(i -> "\t").reduce("", String::concat); return Arrays.stream(content.split(System.lineSeparator())) .map(s -> lineIndent + s) .collect(Collectors.joining(System.lineSeparator())); } }

Target:
public static String addIndent(String content, int numberOfIndents) { if (numberOfIndents <= 0) { return content; } else { String lineIndent = IntStream.range(0, numberOfIndents).mapToObj(i -> "\t").reduce("", String::concat); return Arrays.stream(content.split(System.lineSeparator())) .map(s -> lineIndent + s) .collect(Collectors.joining(System.lineSeparator())); } }
Source:
public void verifyQuery(String query) { boolean flag = false; for (WebElement element:resultLinks) { if (element.getText().contains(query)){ flag=true; } } Assertion.assertTrue(flag, "there is no result link in the page"); }

Target:
public void verifyQuery(String query) { boolean isPresent = false; for (WebElement element:resultLinks) { if (element.getText().contains(query)){ isPresent = true; break; } } Assertion.assertTrue(isPresent, "there is no result link in the page"); }
Source:
public IValidatorProblem match(Rule pattern, String input) throws WildcardException { tokenList = parseWildcard(pattern.getDescription()); String bigpattern = makeBigPattern(pattern.getDescription(), wcards); Pattern pat = Pattern.compile(bigpattern); Matcher matcher = pat.matcher(input); if (matcher.matches()) { String fileName = null; int lineNumber = -1; String message = null; Pattern lPattern = Pattern.compile(getPattern('n', wcards)); Pattern mPattern = Pattern.compile(getPattern('m', wcards)); Pattern fPattern = Pattern.compile(getPattern('f', wcards)); for (int i = 1; i <= matcher.groupCount(); i++) { if (matcher.group(i) != null) { String group = matcher.group(i); Matcher lMatch = lPattern.matcher(group); if (lMatch.find()) { lineNumber = Integer.valueOf(lMatch.group()).intValue(); continue; } Matcher fMatch = fPattern.matcher(group); if (fMatch.find()) { if (fileName == null) { fileName = fMatch.group(); continue; } } Matcher mMatch = mPattern.matcher(group); if (mMatch.find()) { message = mMatch.group(); continue; } } } if (message == null) { message = input; } return new ValidatorProblem(fileName, message, lineNumber, pattern .getProblemType()); } return null; }

Target:
public IValidatorProblem match(Rule pattern, String input) throws WildcardException { tokenList = parseWildcard(pattern.getDescription()); String bigpattern = makeBigPattern(pattern.getDescription(), wcards); Pattern pat = Pattern.compile(bigpattern); Matcher matcher = pat.matcher(input); if (matcher.matches()) { String fileName = null; int lineNumber = -1; String message = null; Pattern lPattern = Pattern.compile(getPattern('n', wcards)); Pattern mPattern = Pattern.compile(getPattern('m', wcards)); Pattern fPattern = Pattern.compile(getPattern('f', wcards)); for (int i = 1; i <= matcher.groupCount(); i++) { if (matcher.group(i) != null) { String group = matcher.group(i); Matcher lMatch = lPattern.matcher(group); if (lMatch.find()) { lineNumber = Integer.parseInt(lMatch.group()); continue; } Matcher fMatch = fPattern.matcher(group); if (fMatch.find()) { if (fileName == null) { fileName = fMatch.group(); continue; } } Matcher mMatch = mPattern.matcher(group); if (mMatch.find()) { message = mMatch.group(); continue; } } } if (message == null) { message = input; } return new ValidatorProblem(fileName, message, lineNumber, pattern .getProblemType()); } return null; }
Source:
public int hashCode() { final int prime = 31; int result = 1; result = prime * result + Long.valueOf(getEventId()).hashCode(); return result; }

Target:
public int hashCode() { return Long.valueOf(eventId).hashCode(); }
Source:
public final Set<String> getImports(@NotNull final Document document, @NotNull final Project project) { PsiDocumentManager psiInstance = PsiDocumentManager.getInstance(project); Set<String> imports = new HashSet<String>(); PsiFile psiFile; if (psiInstance != null && (psiInstance.getPsiFile(document)) != null) { psiFile = psiInstance.getPsiFile(document); if (psiFile != null) { PsiElement[] psiRootChildren = psiFile.getChildren(); PsiElement[] importListChildren; PsiElement[] importsElementList; for (PsiElement element : psiRootChildren) { if (element.getNode().getElementType().toString().equals(IMPORT_LIST)) { importListChildren = element.getChildren(); for (PsiElement importElement : importListChildren) { if (importElement.getNode().getElementType(). toString().equals(IMPORT_STATEMENT)) { importsElementList = importElement.getChildren(); if (importsElementList[2] != null) { imports.add(importsElementList[2].getNode().getText()); } } } } } } } return imports; }

Target:
public final Set<String> getImports(@NotNull final Document document, @NotNull final Project project) { PsiDocumentManager psiInstance = PsiDocumentManager.getInstance(project); Set<String> imports = new HashSet<String>(); if (psiInstance != null && (psiInstance.getPsiFile(document)) != null) { PsiFile psiFile = psiInstance.getPsiFile(document); if (psiFile != null) { PsiElement[] psiRootChildren = psiFile.getChildren(); for (PsiElement element : psiRootChildren) { if (element.getNode().getElementType().toString().equals(IMPORT_LIST)) { PsiElement[] importListChildren = element.getChildren(); for (PsiElement importElement : importListChildren) { if (importElement.getNode().getElementType(). toString().equals(IMPORT_STATEMENT)) { PsiElement[] importsElementList = importElement.getChildren(); if (importsElementList[2] != null) { imports.add(importsElementList[2].getNode().getText()); } } } } } } } return imports; }
Source:
public void doMonitor(ServiceEmitter emitter) { final AtomicLong priorCount = priorRequestCount.get(); final ServiceMetricEvent.Builder builder = ServiceMetricEvent.builder(); emitter.emit(builder.build("query/cache/redis/total/requests", totalRequestCount.get())); emitter.emit(builder.build("query/cache/redis/delta/requests", totalRequestCount.get() - priorCount.get())); if (!priorRequestCount.compareAndSet(priorCount, totalRequestCount)) { log.error("Prior value changed while I was reporting! updating anyways"); priorRequestCount.set(totalRequestCount); } }

Target:
public void doMonitor(ServiceEmitter emitter) { final long priorCount = priorRequestCount.get(); final long totalCount = totalRequestCount.get(); final ServiceMetricEvent.Builder builder = ServiceMetricEvent.builder(); emitter.emit(builder.build("query/cache/redis/total/requests", totalCount)); emitter.emit(builder.build("query/cache/redis/delta/requests", totalCount - priorCount)); if (!priorRequestCount.compareAndSet(priorCount, totalCount)) { log.error("Prior value changed while I was reporting! updating anyways"); priorRequestCount.set(totalCount); } }
Source:
public DTreeUserInteraction expand(IProgressMonitor monitor) { for (DTreeItem child : tree.getOwnedTreeItems()) { if (!child.isExpanded()) { new DTreeItemUserInteraction(child, ctx).expand(monitor); } } return this; }

Target:
public DTreeUserInteraction expand(IProgressMonitor monitor) { try { monitor.beginTask("Tree item expandion", tree.getOwnedTreeItems().size()); for (DTreeItem child : tree.getOwnedTreeItems()) { if (!child.isExpanded()) { new DTreeItemUserInteraction(child, ctx).expand(new SubProgressMonitor(monitor, 1)); } } } finally { monitor.done(); } return this; }
Source:
public ExportRepoImageParameters() { super(); }

Target:
public ExportRepoImageParameters() { }
Source:
protected void onActivityResult(int requestCode, int resultCode, Intent intent) { switch (requestCode) { case CommCareHomeActivity.UPGRADE_APP: if (resultCode == RESULT_CANCELED) { UpdateTask task = UpdateTask.getRunningInstance(); if (task != null) { Toast.makeText(this, R.string.update_canceled, Toast.LENGTH_LONG).show(); task.cancel(true); } } else if (resultCode == RESULT_OK) { if (intent.getBooleanExtra(CommCareSetupActivity.KEY_REQUIRE_REFRESH, true)) { Toast.makeText(this, Localization.get("update.success"), Toast.LENGTH_LONG).show(); CommCareApplication._().expireUserSession(); } return; } break; case CommCareHomeActivity.MISSING_MEDIA_ACTIVITY: refresh(); if (resultCode == RESULT_CANCELED) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.media_not_verified); builder.setMessage(R.string.skipped_verification_warning_2) .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dialog = builder.create(); dialog.show(); } else if (resultCode == RESULT_OK) { Toast.makeText(this, R.string.media_verified, Toast.LENGTH_LONG).show(); } } }

Target:
protected void onActivityResult(int requestCode, int resultCode, Intent intent) { switch (requestCode) { case CommCareHomeActivity.UPGRADE_APP: if (resultCode == RESULT_CANCELED) { UpdateTask task = UpdateTask.getRunningInstance(); if (task != null) { Toast.makeText(this, R.string.update_canceled, Toast.LENGTH_LONG).show(); task.cancel(true); } } else if (resultCode == RESULT_OK) { if (intent.getBooleanExtra(CommCareSetupActivity.KEY_REQUIRE_REFRESH, true)) { Toast.makeText(this, Localization.get("update.success"), Toast.LENGTH_LONG).show(); CommCareApplication._().expireUserSession(); } return; } break; case CommCareHomeActivity.MISSING_MEDIA_ACTIVITY: refresh(); if (resultCode == RESULT_CANCELED) { String title = getString(R.string.media_not_verified); String msg = getString(R.string.skipped_verification_warning_2); AlertDialogFactory.showBasicAlertDialog(this, title, msg, null); } else if (resultCode == RESULT_OK) { Toast.makeText(this, R.string.media_verified, Toast.LENGTH_LONG).show(); } } }
Source:
public void onGitStatusChanged(String endpointId, StatusChangedEventDto statusChangedEventDto) { Tree tree = projectExplorerPresenterProvider.get().getTree(); Status status = statusChangedEventDto.getStatus(); tree.getNodeStorage() .getAll() .stream() .filter( node -> node instanceof FileNode && statusChangedEventDto .getProjectName() .equals(getRootProject(((ResourceNode) node).getData().asFile()).getName())) .forEach( node -> { Resource resource = ((ResourceNode) node).getData(); File file = resource.asFile(); String nodeLocation = resource.getLocation().removeFirstSegments(1).toString(); VcsStatus newVcsStatus; if (status.getUntracked().contains(nodeLocation)) { newVcsStatus = UNTRACKED; } else if (status.getModified().contains(nodeLocation) || status.getChanged().contains(nodeLocation)) { newVcsStatus = MODIFIED; } else if (status.getAdded().contains(nodeLocation)) { newVcsStatus = ADDED; } else { newVcsStatus = NOT_MODIFIED; } if (file.getVcsStatus() != newVcsStatus) { file.setVcsStatus(newVcsStatus); tree.refresh(node); } }); }

Target:
public void onGitStatusChanged(String endpointId, StatusChangedEventDto statusChangedEventDto) { Tree tree = projectExplorerPresenterProvider.get().getTree(); Status status = statusChangedEventDto.getStatus(); tree.getNodeStorage() .getAll() .stream() .filter( node -> node instanceof FileNode && statusChangedEventDto .getProjectName() .equals(getRootPath(((FileNode) node).getData().getLocation()))) .forEach( node -> { Resource resource = ((FileNode) node).getData(); File file = resource.asFile(); String nodeLocation = resource.getLocation().removeFirstSegments(1).toString(); VcsStatus newVcsStatus; if (status.getUntracked().contains(nodeLocation)) { newVcsStatus = UNTRACKED; } else if (status.getModified().contains(nodeLocation) || status.getChanged().contains(nodeLocation)) { newVcsStatus = MODIFIED; } else if (status.getAdded().contains(nodeLocation)) { newVcsStatus = ADDED; } else { newVcsStatus = NOT_MODIFIED; } if (file.getVcsStatus() != newVcsStatus) { file.setVcsStatus(newVcsStatus); tree.refresh(node); } }); }
Source:
private AboutInfo promptForFeature() throws WorkbenchException { ArrayList welcomeFeatures = new ArrayList(); URL productUrl = null; IProduct product = Platform.getProduct(); if (product != null) { productUrl = ProductProperties.getWelcomePageUrl(product); welcomeFeatures.add(new AboutInfo(product)); } AboutInfo[] features = IDEWorkbenchPlugin.getDefault() .getFeatureInfos(); for (int i = 0; i < features.length; i++) { URL url = features[i].getWelcomePageURL(); if (url != null && (productUrl == null || !url.toString().equals(productUrl.toString())) { welcomeFeatures.add(features[i]); } } Shell shell = workbenchWindow.getShell(); if (welcomeFeatures.size() == 0) { MessageDialog.openInformation(shell, IDEWorkbenchMessages.QuickStartMessageDialog_title, IDEWorkbenchMessages.QuickStartMessageDialog_message); return null; } features = new AboutInfo[welcomeFeatures.size()]; welcomeFeatures.toArray(features); FeatureSelectionDialog d = new FeatureSelectionDialog(shell, features, product == null ? null : product.getId(), IDEWorkbenchMessages.WelcomePageSelectionDialog_title, IDEWorkbenchMessages.WelcomePageSelectionDialog_message, IIDEHelpContextIds.WELCOME_PAGE_SELECTION_DIALOG); if (d.open() != Window.OK || d.getResult().length != 1) { return null; } return (AboutInfo) d.getResult()[0]; }

Target:
private AboutInfo promptForFeature() throws WorkbenchException { ArrayList welcomeFeatures = new ArrayList(); URL productUrl = null; IProduct product = Platform.getProduct(); if (product != null) { productUrl = ProductProperties.getWelcomePageUrl(product); welcomeFeatures.add(new AboutInfo(product)); } AboutInfo[] features = IDEWorkbenchPlugin.getDefault() .getFeatureInfos(); for (int i = 0; i < features.length; i++) { URL url = features[i].getWelcomePageURL(); if (url != null && (productUrl == null || !url.toString().equals(productUrl.toString()))) { welcomeFeatures.add(features[i]); } } Shell shell = workbenchWindow.getShell(); if (welcomeFeatures.size() == 0) { MessageDialog.openInformation(shell, IDEWorkbenchMessages.QuickStartMessageDialog_title, IDEWorkbenchMessages.QuickStartMessageDialog_message); return null; } features = new AboutInfo[welcomeFeatures.size()]; welcomeFeatures.toArray(features); FeatureSelectionDialog d = new FeatureSelectionDialog(shell, features, product == null ? null : product.getId(), IDEWorkbenchMessages.WelcomePageSelectionDialog_title, IDEWorkbenchMessages.WelcomePageSelectionDialog_message, IIDEHelpContextIds.WELCOME_PAGE_SELECTION_DIALOG); if (d.open() != Window.OK || d.getResult().length != 1) { return null; } return (AboutInfo) d.getResult()[0]; }
Source:
public CompletableFuture<Collection<Replay>> loadLocalReplays() { String replayFileGlob = clientProperties.getReplay().getReplayFileGlob(); Path replaysDirectory = preferencesService.getReplaysDirectory(); if (Files.notExists(replaysDirectory)) { noCatch(() -> createDirectories(replaysDirectory)); } DirectoryStream<Path> directoryStream = Files.newDirectoryStream(replaysDirectory, replayFileGlob); List<CompletableFuture<Replay>> replayFutures = StreamSupport.stream(directoryStream.spliterator(), false) .sorted(Comparator.comparing(path -> noCatch(() -> Files.getLastModifiedTime((Path) path))).reversed()) .limit(MAX_REPLAYS) .map( replayFile -> { try { return loadLocalReplay(replayFile); } catch (Exception e) { return null; } }) .filter(replay -> replay != null) .collect(Collectors.toList()); CompletableFuture[] replayFuturesArray = replayFutures.toArray(new CompletableFuture[replayFutures.size()]); return CompletableFuture.allOf(replayFuturesArray) .thenApply(ignoredVoid -> replayFutures.stream() .map(future -> future.join()) .collect(Collectors.toList())); }

Target:
public CompletableFuture<Collection<Replay>> loadLocalReplays() throws IOException { String replayFileGlob = clientProperties.getReplay().getReplayFileGlob(); Path replaysDirectory = preferencesService.getReplaysDirectory(); if (Files.notExists(replaysDirectory)) { noCatch(() -> createDirectories(replaysDirectory)); } try (DirectoryStream<Path> directoryStream = Files.newDirectoryStream(replaysDirectory, replayFileGlob)) { List<CompletableFuture<Replay>> replayFutures = StreamSupport.stream(directoryStream.spliterator(), false) .sorted(Comparator.comparing(path -> noCatch(() -> Files.getLastModifiedTime((Path) path))).reversed()) .limit(MAX_REPLAYS) .map( replayFile -> tryLoadingLocalReplay(replayFile)) .filter(e -> !e.isCompletedExceptionally()) .collect(Collectors.toList()); CompletableFuture[] replayFuturesArray = replayFutures.toArray(new CompletableFuture[replayFutures.size()]); return CompletableFuture.allOf(replayFuturesArray) .thenApply(ignoredVoid -> replayFutures.stream() .map(future -> future.join()) .collect(Collectors.toList())); } }
Source:
public void setActiveSheet(int sheetNum) { if (sheetNum >= 0 && sheetNum < numSheetsWritten) { activeSheetNum = sheetNum; } else if (sheetNum < 0) { throw new OseeCoreException("Cannot set active sheet less than zero"); } else { throw new OseeCoreException("Cannot set active sheet higher than the number of sheets written"); } }

Target:
public void setActiveSheet(int sheetNum) { if (sheetNum >= 0 && sheetNum < numSheetsWritten) { activeSheetNum = sheetNum; } else if (sheetNum < 0) { throw new OseeArgumentException("Cannot set active sheet less than zero"); } else { throw new OseeArgumentException("Cannot set active sheet higher than the number of sheets written"); } }
Source:
public void given_multibranchWithSources_when_createEventWhileIndexing_then_onlyOneBuildCreated() throws Exception { try (MockSCMController c = MockSCMController.create()) { c.createRepository("foo"); BasicMultiBranchProject prj = r.jenkins.createProject(BasicMultiBranchProject.class, "foo"); prj.setCriteria(null); prj.getSourcesList().add(new BranchSource(new MockSCMSource(null, c, "foo", true, false, false))); c.withLatency(MockLatency.fixed(100, TimeUnit.MILLISECONDS)); long lastModified = prj.getComputation().getEventsFile().lastModified(); QueueTaskFuture<Queue.Executable> future = prj.scheduleBuild2(0).getFuture(); SCMHeadEvent.fireNow(new MockSCMHeadEvent(SCMEvent.Type.CREATED, c, "foo", "master", c.getRevision("foo", "master"))); future.get(); FreeStyleProject master = prj.getItem("master"); waitUntilNoActivityIgnoringThreadDeathUpTo(10000); assertThat(prj.getComputation().getEventsFile().lastModified(), greaterThan(lastModified)); assertThat("The master branch was built once only", master.getLastBuild().getNumber(), is(1)); assertThat(master.getLastBuild().getResult(), is(Result.SUCCESS)); List<Throwable> deaths = new ArrayList<Throwable>(); for (Computer comp : r.jenkins.getComputers()) { for (Executor e : comp.getExecutors()) { if (e.getCauseOfDeath() != null) { deaths.add(e.getCauseOfDeath()); } } for (Executor e : comp.getOneOffExecutors()) { if (e.getCauseOfDeath() != null) { deaths.add(e.getCauseOfDeath()); } } } assertThat("None of the executors have died abnormally", deaths, containsInAnyOrder()); } }

Target:
public void given_multibranchWithSources_when_createEventWhileIndexing_then_onlyOneBuildCreated() throws Exception { try (MockSCMController c = MockSCMController.create()) { c.createRepository("foo"); BasicMultiBranchProject prj = r.jenkins.createProject(BasicMultiBranchProject.class, "foo"); prj.setCriteria(null); prj.getSourcesList().add(new BranchSource(new MockSCMSource(null, c, "foo", true, false, false))); c.withLatency(MockLatency.fixed(100, TimeUnit.MILLISECONDS)); long lastModified = prj.getComputation().getEventsFile().lastModified(); QueueTaskFuture<Queue.Executable> future = prj.scheduleBuild2(0).getFuture(); SCMHeadEvent.fireNow(new MockSCMHeadEvent( "given_multibranchWithSources_when_createEventWhileIndexing_then_onlyOneBuildCreated", SCMEvent.Type.CREATED, c, "foo", "master", c.getRevision("foo", "master") )); future.get(); FreeStyleProject master = prj.getItem("master"); waitUntilNoActivityIgnoringThreadDeathUpTo(10000); assertThat(prj.getComputation().getEventsFile().lastModified(), greaterThan(lastModified)); assertThat("The master branch was built once only", master.getLastBuild().getNumber(), is(1)); assertThat(master.getLastBuild().getResult(), is(Result.SUCCESS)); List<Throwable> deaths = new ArrayList<Throwable>(); for (Computer comp : r.jenkins.getComputers()) { for (Executor e : comp.getExecutors()) { if (e.getCauseOfDeath() != null) { deaths.add(e.getCauseOfDeath()); } } for (Executor e : comp.getOneOffExecutors()) { if (e.getCauseOfDeath() != null) { deaths.add(e.getCauseOfDeath()); } } } assertThat("None of the executors have died abnormally", deaths, containsInAnyOrder()); } }
Source:
public SaltUpdateEvent[] getInitEvents() { return new SaltUpdateEvent[]{SaltUpdateEvent.SALT_UPDATE_EVENT}; }

Target:
public SaltUpdateEvent[] getInitEvents() { return new SaltUpdateEvent[]{SALT_UPDATE_EVENT}; }
Source:
public void afterExecute(final Runnable r, Throwable t) { super.afterExecute(r, t); if (t == null && r instanceof Future<?>) { try { Object result = ((Future<?>) r).get(); } catch (java.util.concurrent.CancellationException cancellationException) { t = cancellationException; } catch (java.util.concurrent.ExecutionException executionException) { t = executionException.getCause(); } catch (InterruptedException interruptedException) { Thread.currentThread().interrupt(); } } if (t != null) { Logging.error("Thread {0} raised {1}", Thread.currentThread().getName(), t); } }

Target:
public void afterExecute(final Runnable r, Throwable t) { super.afterExecute(r, t); if (t == null && r instanceof Future<?>) { try { Object result = ((Future<?>) r).get(); } catch (CancellationException cancellationException) { t = cancellationException; } catch (ExecutionException executionException) { t = executionException.getCause(); } catch (InterruptedException interruptedException) { Thread.currentThread().interrupt(); } } if (t != null) { Logging.error("Thread {0} raised {1}", Thread.currentThread().getName(), t); } }
Source:
public static void createAndWaitForStream(AmazonKinesisClient kinesisClient, String streamName, int shardCount) { if (streamExists(kinesisClient, streamName)) { String state = getStreamState(kinesisClient, streamName); switch (state) { case "DELETING": long waitTimeDelete = System.currentTimeMillis() + TIMEOUT; while (System.currentTimeMillis() < waitTimeDelete && streamExists(kinesisClient, streamName)) { try { LOG.debug("Deleting Stream ", streamName); TimeUnit.MILLISECONDS.sleep(SLEEP_INTERVAL); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } } if (streamExists(kinesisClient, streamName)) { throw new IllegalStateException(String.format("Timed out waiting for stream to delete", streamName)); } createStream(streamName, shardCount, kinesisClient); break; case "ACTIVE": LOG.info("Stream already exists", streamName); return; case "CREATING": LOG.info("Stream is being created", streamName); break; case "UPDATING": LOG.info("Stream is being updated", streamName); return; default: throw new IllegalStateException(String.format("Illegal stream state: {}", state)); } } else { createStream(streamName, shardCount, kinesisClient); } long waitTimeCreate = System.currentTimeMillis() + TIMEOUT; while (System.currentTimeMillis() < waitTimeCreate) { try { TimeUnit.MILLISECONDS.sleep(SLEEP_INTERVAL); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } try { String streamStatus = getStreamState(kinesisClient, streamName); if ("ACTIVE".equals(streamStatus)) { LOG.info("Stream is ACTIVE", streamName); return; } } catch (ResourceNotFoundException e) { throw new IllegalStateException(String.format("Stream %s did not become active in %d", streamName, TIMEOUT), e); } } if (!getStreamState(kinesisClient, streamName).equals("ACTIVE")) { throw new IllegalStateException(String.format("Stream %s did not become active in %d", streamName, TIMEOUT)); } }

Target:
public static void createAndWaitForStream(AmazonKinesisClient kinesisClient, String streamName, int shardCount) { if (streamExists(kinesisClient, streamName)) { StreamStatus streamStatus = getStreamState(kinesisClient, streamName); switch (streamStatus) { case DELETING: waitForStreamState(kinesisClient, streamName, null); createStream(streamName, shardCount, kinesisClient); break; case ACTIVE: LOG.info("Stream already exists", streamName); return; case CREATING: LOG.info("Stream is being created", streamName); break; case UPDATING: LOG.info("Stream is being updated", streamName); return; default: throw new IllegalStateException(String.format("Illegal stream state: %s", streamStatus)); } } else { createStream(streamName, shardCount, kinesisClient); } waitForStreamState(kinesisClient, streamName, StreamStatus.ACTIVE); }
Source:
private Callable<ChecksExecutionResult> createProcessFileCallable(File file) { final String fileName = file.getAbsolutePath(); return () -> { ChecksExecutionResult result; try { final SortedSet<LocalizedMessage> messages = processFile(file); fireErrors(fileName, messages); fireFileFinished(fileName); result = ChecksExecutionResult.getCompleted(file, messages); } catch (CheckstyleException ex) { result = ChecksExecutionResult.getFailed(file, ex); } return result; }; }

Target:
private Callable<CheckerExecutionResult> createProcessFileCallable(File file) { return () -> { CheckerExecutionResult result; try { fireEventsAndProcessFile(file); result = new CheckerExecutionResult(); } catch (CheckstyleException ex) { result = new CheckerExecutionResult(ex); } return result; }; }