auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
public void shouldConvertValueObjectToDto() { final ProfileGenericDataRequestData source = new ProfileGenericDataRequestData(OBIS_CODE_VALUES, BEGIN_DATE.toDate(), END_DATE.toDate()); final ProfileGenericDataRequestDataDto result = this.mapper.map(source, ProfileGenericDataRequestDataDto.class); assertEquals("mapped values should be identical", result.getBeginDate(), BEGIN_DATE.toDate()); assertEquals("mapped values should be identical", result.getEndDate(), END_DATE.toDate()); assertEquals("mapped values should be identical", result.getObisCode().getA(), OBIS_CODE_VALUES.getA()); assertEquals("mapped values should be identical", result.getObisCode().getB(), OBIS_CODE_VALUES.getB()); assertEquals("mapped values should be identical", result.getObisCode().getC(), OBIS_CODE_VALUES.getC()); assertEquals("mapped values should be identical", result.getObisCode().getD(), OBIS_CODE_VALUES.getD()); assertEquals("mapped values should be identical", result.getObisCode().getE(), OBIS_CODE_VALUES.getE()); assertEquals("mapped values should be identical", result.getObisCode().getF(), OBIS_CODE_VALUES.getF()); }

Target:
public void shouldConvertValueObjectToDto() { final ProfileGenericDataRequestData source = new ProfileGenericDataRequestData(OBIS_CODE_VALUES, BEGIN_DATE.toDate(), END_DATE.toDate()); final ProfileGenericDataRequestDataDto result = this.mapper.map(source, ProfileGenericDataRequestDataDto.class); assertEquals(MAPPED_FIELD_VALUE_MESSAGE, result.getBeginDate(), BEGIN_DATE.toDate()); assertEquals(MAPPED_FIELD_VALUE_MESSAGE, result.getEndDate(), END_DATE.toDate()); assertEquals(MAPPED_FIELD_VALUE_MESSAGE, result.getObisCode().getA(), OBIS_CODE_VALUES.getA()); assertEquals(MAPPED_FIELD_VALUE_MESSAGE, result.getObisCode().getB(), OBIS_CODE_VALUES.getB()); assertEquals(MAPPED_FIELD_VALUE_MESSAGE, result.getObisCode().getC(), OBIS_CODE_VALUES.getC()); assertEquals(MAPPED_FIELD_VALUE_MESSAGE, result.getObisCode().getD(), OBIS_CODE_VALUES.getD()); assertEquals(MAPPED_FIELD_VALUE_MESSAGE, result.getObisCode().getE(), OBIS_CODE_VALUES.getE()); assertEquals(MAPPED_FIELD_VALUE_MESSAGE, result.getObisCode().getF(), OBIS_CODE_VALUES.getF()); }
Source:
protected void executeRuntimeStep(OperationContext context, ModelNode operation) { String name = this.nameExtractor.apply(operation); Metric<C> executable = this.executables.get(name); try { ModelNode result = this.executor.execute(context, executable); if (result != null) { context.getResult().set(result); } } catch (OperationFailedException e) { context.getFailureDescription().set(e.getLocalizedMessage()); } context.completeStep(OperationContext.ResultHandler.NOOP_RESULT_HANDLER); }

Target:
protected void executeRuntimeStep(OperationContext context, ModelNode operation) { String name = Operations.getAttributeName(operation); Metric<C> executable = this.executables.get(name); try { ModelNode result = this.executor.execute(context, executable); if (result != null) { context.getResult().set(result); } } catch (OperationFailedException e) { context.getFailureDescription().set(e.getLocalizedMessage()); } context.completeStep(OperationContext.ResultHandler.NOOP_RESULT_HANDLER); }
Source:
public int getItemCount() { return tourStops.size() * 100; }

Target:
public int getItemCount() { return tourStops.size() * TourUtils.NUMBER_OF_TOUR_LOOP; }
Source:
public static void storeProperties(Properties properties, OutputStream outStream, String comment) { try { OutputStreamWriter osw = new OutputStreamWriter(new BufferedOutputStream(outStream), "UTF-8"); Writer out = new BufferedWriter(osw); if (comment != null) out.write("\n#" + comment + "\n"); out.write("#" + new Date() + "\n"); for (Map.Entry<Object, Object> e : properties.entrySet()) { out.write(e.getKey() + "=" + e.getValue().toString().replaceAll("\\\\", "\\\\\\\\") + "\n"); } out.flush(); out.close(); } catch (FileNotFoundException fnfe) { log.error("target file not found" + fnfe); } catch (UnsupportedEncodingException ex) { log.error("unsupported encoding error hit" + ex); } catch (IOException ioex) { log.error("IO exception encountered trying to append to properties file" + ioex); } }

Target:
public static void storeProperties(Properties properties, OutputStream outStream, String comment) { try { Charset utf8 = Charset.forName("UTF-8"); properties.store(new OutputStreamWriter(outStream, utf8), comment); } catch (FileNotFoundException fnfe) { log.error("target file not found" + fnfe); } catch (UnsupportedEncodingException ex) { log.error("unsupported encoding error hit" + ex); } catch (IOException ioex) { log.error("IO exception encountered trying to append to properties file" + ioex); } }
Source:
public int andCardinality(Container x) { if (this.getCardinality() == 0) return 0; else if (x.getCardinality() ==0) return 0; else { if (x instanceof ArrayContainer) return and((ArrayContainer) x).getCardinality(); else if (x instanceof BitmapContainer) return and((BitmapContainer) x).getCardinality(); return and((RunContainer) x).getCardinality(); } }

Target:
public int andCardinality(Container x) { if (this.getCardinality() == 0) return 0; else if (x.getCardinality() == 0) return 0; else { if (x instanceof ArrayContainer) return andCardinality((ArrayContainer) x); else if (x instanceof BitmapContainer) return andCardinality((BitmapContainer) x); return andCardinality((RunContainer) x); } }
Source:
public void testVideoSurfaceResetting() throws Exception { final int tolerance = 150; final int audioLatencyTolerance = 1000; final int seekPos = 4760; final CountDownLatch seekDone = new CountDownLatch(1); MediaPlayer2.EventCallback ecb = new MediaPlayer2.EventCallback() { @Override public void onCallCompleted( MediaPlayer2 mp, MediaItem2 item, int what, int status) { if (what == MediaPlayer2.CALL_COMPLETED_SEEK_TO) { seekDone.countDown(); } } }; synchronized (mEventCbLock) { mEventCallbacks.add(ecb); } if (!checkLoadResource(R.raw.testvideoh264)) { return; } playLoadedVideo(352, 288, -1); Thread.sleep(SLEEP_TIME); long posBefore = mPlayer.getCurrentPosition(); mPlayer.setSurface(mActivity.getSurfaceHolder2().getSurface()); long posAfter = mPlayer.getCurrentPosition(); assertTrue(mPlayer.getState() == MediaPlayer2.PLAYER_STATE_PLAYING); Thread.sleep(SLEEP_TIME); mPlayer.seekTo(seekPos, MediaPlayer2.SEEK_PREVIOUS_SYNC); seekDone.await(); posAfter = mPlayer.getCurrentPosition(); assertEquals(seekPos, posAfter, tolerance + audioLatencyTolerance); Thread.sleep(SLEEP_TIME / 2); posBefore = mPlayer.getCurrentPosition(); mPlayer.setSurface(null); posAfter = mPlayer.getCurrentPosition(); assertTrue(mPlayer.getState() == MediaPlayer2.PLAYER_STATE_PLAYING); Thread.sleep(SLEEP_TIME); posBefore = mPlayer.getCurrentPosition(); mPlayer.setSurface(mActivity.getSurfaceHolder().getSurface()); posAfter = mPlayer.getCurrentPosition(); assertTrue(mPlayer.getState() == MediaPlayer2.PLAYER_STATE_PLAYING); Thread.sleep(SLEEP_TIME); }

Target:
public void testVideoSurfaceResetting() throws Exception { final int tolerance = 150; final int audioLatencyTolerance = 1000; final int seekPos = 1840; final CountDownLatch seekDone = new CountDownLatch(1); MediaPlayer2.EventCallback ecb = new MediaPlayer2.EventCallback() { @Override public void onCallCompleted( MediaPlayer2 mp, MediaItem2 item, int what, int status) { if (what == MediaPlayer2.CALL_COMPLETED_SEEK_TO) { seekDone.countDown(); } } }; synchronized (mEventCbLock) { mEventCallbacks.add(ecb); } if (!checkLoadResource( R.raw.video_480x360_mp4_h264_500kbps_25fps_aac_stereo_128kbps_44100hz)) { return; } playLoadedVideo(480, 360, -1); Thread.sleep(SLEEP_TIME); long posBefore = mPlayer.getCurrentPosition(); mPlayer.setSurface(mActivity.getSurfaceHolder2().getSurface()); long posAfter = mPlayer.getCurrentPosition(); assertTrue(mPlayer.getState() == MediaPlayer2.PLAYER_STATE_PLAYING); Thread.sleep(SLEEP_TIME); mPlayer.seekTo(seekPos, MediaPlayer2.SEEK_PREVIOUS_SYNC); seekDone.await(); posAfter = mPlayer.getCurrentPosition(); assertEquals(seekPos, posAfter, tolerance + audioLatencyTolerance); Thread.sleep(SLEEP_TIME / 2); posBefore = mPlayer.getCurrentPosition(); mPlayer.setSurface(null); posAfter = mPlayer.getCurrentPosition(); assertTrue(mPlayer.getState() == MediaPlayer2.PLAYER_STATE_PLAYING); Thread.sleep(SLEEP_TIME); posBefore = mPlayer.getCurrentPosition(); mPlayer.setSurface(mActivity.getSurfaceHolder().getSurface()); posAfter = mPlayer.getCurrentPosition(); assertTrue(mPlayer.getState() == MediaPlayer2.PLAYER_STATE_PLAYING); Thread.sleep(SLEEP_TIME); }
Source:
public byte[] generateCSR(String sigAlg, KeyPair keyPair) { ByteArrayOutputStream outStream = new ByteArrayOutputStream(); PrintStream printStream = new PrintStream(outStream); try { PKCS10CertificationRequestBuilder p10Builder = new JcaPKCS10CertificationRequestBuilder( new X500Principal("CN=Requested Test Certificate"), keyPair.getPublic()); JcaContentSignerBuilder csBuilder = new JcaContentSignerBuilder("SHA256withRSA"); ContentSigner signer = csBuilder.build(keyPair.getPrivate()); PKCS10CertificationRequest csr = p10Builder.build(signer); return csr.getEncoded(); } catch (Exception ex) { ex.printStackTrace(); } finally { if (null != outStream) { try { outStream.close(); } catch (IOException e) { e.printStackTrace(); } } if (null != printStream) { printStream.close(); } } return new byte[0]; }

Target:
public byte[] generateCSR(String sigAlg, KeyPair keyPair) { ByteArrayOutputStream outStream = new ByteArrayOutputStream(); PrintStream printStream = new PrintStream(outStream); try { PKCS10CertificationRequestBuilder p10Builder = new JcaPKCS10CertificationRequestBuilder( new X500Principal("CN=Requested Test Certificate"), keyPair.getPublic()); JcaContentSignerBuilder csBuilder = new JcaContentSignerBuilder("SHA256withRSA"); ContentSigner signer = csBuilder.build(keyPair.getPrivate()); PKCS10CertificationRequest csr = p10Builder.build(signer); return csr.getEncoded(); } catch (OperatorCreationException ex) { log.error("Error while Key generation operation", ex); } catch (IOException ex) { log.error("Error while generating CSR,ex"); } return new byte[0]; }
Source:
private void decrementCurrentUsageInBytesIfRequired(long delta) { if(byteSized) { while(true) { long expect = currentUsageinBytes.get(); long update = expect - delta; if(update < 0l) { throw new AssertionError("It's screwed"); } if(currentUsageinBytes.compareAndSet(expect, update)) { break; } } } }

Target:
private void decrementCurrentUsageInBytesIfRequired(long delta) { if(byteSized) { long current = currentUsageinBytes.addAndGet(-delta); if(current < 0L) { throw new AssertionError("Current usage can never be negative"); } } }
Source:
void updatePrimaryStar() { if (_env == null || !OTOptions.isEditable(_obsComp.getProgram(), _obsComp.getContextObservation())) return; final TargetEnvironment env = _dataObject.getTargetEnvironment(); final Option<SPTarget> targetOpt = getSelectedPos(); final Option<IndexedGuideGroup> iggOpt = targetOpt.flatMap(this::getTargetGroup).orElse(getSelectedGroup()); final boolean primaryGroupIsSelected = iggOpt.exists(igg -> igg.group().equals(env.getOrCreatePrimaryGuideGroup())); if (targetOpt.isDefined() && primaryGroupIsSelected) { final boolean autoGroup = targetOpt.flatMap(this::getTargetGroup).exists(igg -> igg.group().isAutomatic()); if (!autoGroup) PrimaryTargetToggle.instance.toggle(_dataObject, targetOpt.getValue()); } else { iggOpt.foreach(igg -> { final GuideGroup primary = env.getOrCreatePrimaryGuideGroup(); ImOption.apply(env.getGuideEnvironment()).foreach(ge -> { final GuideGrp grp = igg.group().grp(); if (ge != null && grp instanceof AutomaticGroup.Disabled$) { final TargetEnvironment envNew = env.setGuideEnvironment(ge.setAutomaticGroup(GuideGroup.AutomaticInitial()).setPrimaryIndex(0)); _dataObject.setTargetEnvironment(envNew); _model.enableAutoRow(envNew); } else if (ge != null && primary != igg.group() && confirmGroupChange(primary, igg.group())) { _dataObject.setTargetEnvironment(env.setGuideEnvironment(ge.setPrimaryIndex(igg.index()))); if (grp instanceof AutomaticGroup.Active) { updatePosAngle(((AutomaticGroup.Active) grp).posAngle()); } } }); }); } }

Target:
void updatePrimaryStar() { if (_env == null || !OTOptions.isEditable(_obsComp.getProgram(), _obsComp.getContextObservation())) return; final TargetEnvironment env = _dataObject.getTargetEnvironment(); final Option<SPTarget> targetOpt = getSelectedPos(); final Option<IndexedGuideGroup> iggOpt = targetOpt.flatMap(this::getTargetGroup).orElse(getSelectedGroup()); final boolean primaryGroupIsSelected = iggOpt.exists(igg -> igg.group().equals(env.getPrimaryGuideGroup())); if (!primaryGroupIsSelected) { iggOpt.foreach(igg -> { final GuideGroup primary = env.getPrimaryGuideGroup(); ImOption.apply(env.getGuideEnvironment()).foreach(ge -> { final GuideGrp grp = igg.group().grp(); if (ge != null && grp instanceof AutomaticGroup.Disabled$) { final TargetEnvironment envNew = env.setGuideEnvironment(ge.setAutomaticGroup(GuideGroup.AutomaticInitial()).setPrimaryIndex(0)); _dataObject.setTargetEnvironment(envNew); _model.enableAutoRow(envNew); } else if (ge != null && primary != igg.group() && confirmGroupChange(primary, igg.group())) { _dataObject.setTargetEnvironment(env.setGuideEnvironment(ge.setPrimaryIndex(igg.index()))); if (grp instanceof AutomaticGroup.Active) { updatePosAngle(((AutomaticGroup.Active) grp).posAngle()); } } }); }); } final boolean autoGroup = targetOpt.flatMap(this::getTargetGroup).exists(igg -> igg.group().isAutomatic()); if (!autoGroup) { targetOpt.foreach(target -> { if (primaryGroupIsSelected || iggOpt.exists(igg -> igg.group().getAllContaining(target).forall(gpt -> gpt.getPrimary().forall(pt -> pt != target)))) { PrimaryTargetToggle.instance.toggle(_dataObject, target); } }); } }
Source:
public void methodCallCanBeAnnotatedAsByName() { db.getJdbi().useHandle(h -> { h.getConfig(Enums.class).defaultByOrdinal(); Object byName = h.createQuery("select :name") .bind("name", Foobar.FOO.name()) .mapTo(QualifiedType.of(Foobar.class).with(EnumByName.class)) .findOnly(); assertThat(byName) .isEqualTo(Foobar.FOO); }); }

Target:
public void methodCallCanBeAnnotatedAsByName() { h.getConfig(Enums.class).setEnumStrategy(EnumStrategy.BY_ORDINAL); Object byName = h.createQuery("select :name") .bind("name", Foobar.FOO.name()) .mapTo(QualifiedType.of(Foobar.class).with(EnumByName.class)) .findOnly(); assertThat(byName) .isEqualTo(Foobar.FOO); }
Source:
protected void configure() { Multibinder<ServicePlugin> plugins = Multibinder.newSetBinder(binder(), ServicePlugin.class); plugins.addBinding().toInstance(Plugins.of(new HttpBackend(port))); bind(ObjectValidator.class).to(ApacheObjectValidator.class).in(Singleton.class); install(new ServletModule() { @Override protected void configureServlets() { bind(TestServlet.class).in(Singleton.class); serve("/test").with(TestServlet.class); } }); install(new SitebricksModule() { @Override protected void configureSitebricks() { at("/testservice").serve(ExampleService.class); at("/r/controllers").serve(ApControllerService.class); at("/r/aps").serve(AccessPointService.class); at("/r/operators").serve(OperatorService.class); at("/r/roaming-groups").serve(RoamingGroupService.class); at("/r/network").serve(NetworkService.class); } }); bindInterceptor(annotatedWith(Service.class), returns(only(Reply.class)), new HttpRequestErrorReporter("Internal Server Error")); }

Target:
protected void configure() { Multibinder<ServicePlugin> plugins = Multibinder.newSetBinder(binder(), ServicePlugin.class); plugins.addBinding().toInstance(Plugins.of(new HttpBackend(port))); bind(ObjectValidator.class).to(ApacheObjectValidator.class).in(Singleton.class); install(new ServletModule() { @Override protected void configureServlets() { bind(TestServlet.class).in(Singleton.class); serve("/test").with(TestServlet.class); } }); install(new SitebricksModule() { @Override protected void configureSitebricks() { at("/testservice").serve(ExampleService.class); at("/r/controllers").serve(ApControllerService.class); at("/r/aps").serve(AccessPointService.class); at("/r/operators").serve(OperatorService.class); at("/r/roaming-groups").serve(RoamingGroupService.class); at("/r/venues").serve(VenueService.class); at("/r/ip-types").serve(IpTypeService.class); at("/r/auth-types").serve(AuthTypeEndpoint.class); } }); bindInterceptor(annotatedWith(Service.class), returns(only(Reply.class)), new HttpRequestErrorReporter("Internal Server Error")); }
Source:
public void visitFunctionDef(FunctionDef functionDef) { Optional.ofNullable(functionDef.name().symbol()).ifPresent(symbol -> { SymbolUsage symbolUsage = symbolToUsages.getOrDefault(symbol, new SymbolUsage()); symbolUsage.isWrite = true; symbolToUsages.put(symbol, symbolUsage); }); }

Target:
public void visitFunctionDef(FunctionDef functionDef) { Optional.ofNullable(functionDef.name().symbol()).ifPresent(symbol -> symbolToUsages.computeIfAbsent(symbol, s -> new SymbolUsage()).isWrite = true); }
Source:
public OperationBuilder extensions(Map<String, Object> extensions) { this.vendorExtensions = defaultIfAbsent(extensions, this.vendorExtensions); return this; }

Target:
public OperationBuilder extensions(Map<String, Object> extensions) { this.vendorExtensions.putAll(nullToEmptyMap(extensions)); return this; }
Source:
public void fastEnqueue(final DeferredSerialization ds) { if (m_isSSLConfigured) { m_port.queueTask(new Runnable() { @Override public void run() { Iterator<DeferredSerialization> dsIter = new SSLDeferredSerializationIterator(m_sslEngine, ds); synchronized (NIOWriteStream.this) { updateLastPendingWriteTimeAndQueueBackpressure(); while (dsIter.hasNext()) { m_queuedWrites.offer(dsIter.next()); } m_port.setInterests( SelectionKey.OP_WRITE, 0); } } }); } else { m_port.queueTask(new Runnable() { @Override public void run() { synchronized (NIOWriteStream.this) { updateLastPendingWriteTimeAndQueueBackpressure(); try { final int serializedSize = ds.getSerializedSize(); if (!(serializedSize == DeferredSerialization.EMPTY_MESSAGE_LENGTH)) { m_queuedWrites.offer(new DeferredSerialization() { @Override public ByteBuffer serialize(ByteBuffer outbuf) throws IOException { if (outbuf.remaining() >= serializedSize) { ds.serialize(outbuf); return null; } else { ByteBuffer allocated = ByteBuffer.allocate(serializedSize); ds.serialize(allocated); allocated.flip(); return allocated; } } @Override public void cancel() { } @Override public int getSerializedSize() throws IOException { throw new UnsupportedOperationException("getSerializedSize not supported"); } }); } } catch(IOException e){ throw new RuntimeException("Failed to get serialized size for ds " + e.getMessage()); } m_port.setInterests( SelectionKey.OP_WRITE, 0); } } }); } }

Target:
public void fastEnqueue(final DeferredSerialization ds) { m_port.queueTask(new Runnable() { @Override public void run() { synchronized (NIOWriteStream.this) { updateLastPendingWriteTimeAndQueueBackpressure(); m_queuedWrites.offer(ds); m_port.setInterests( SelectionKey.OP_WRITE, 0); } } }); }
Source:
private ProjectNode buildProjectedAggregation(PlanBuilder planBuilder, Predicate<Symbol> projectionFilter) { Symbol a = planBuilder.symbol("a"); Symbol b = planBuilder.symbol("b"); return planBuilder.project( Assignments.identity(ImmutableList.of(a, b).stream().filter(projectionFilter).collect(toImmutableSet())), planBuilder.aggregation(aggregationBuilder -> aggregationBuilder .source(planBuilder.values()) .addGroupingSet() .addAggregation(a, planBuilder.expression("count()"), ImmutableList.of()) .addAggregation(b, planBuilder.expression("count()"), ImmutableList.of()))); }

Target:
private ProjectNode buildProjectedAggregation(PlanBuilder planBuilder, Predicate<Symbol> projectionFilter) { Symbol a = planBuilder.symbol("a"); Symbol b = planBuilder.symbol("b"); Symbol key = planBuilder.symbol("key"); return planBuilder.project( Assignments.identity(ImmutableList.of(a, b).stream().filter(projectionFilter).collect(toImmutableSet())), planBuilder.aggregation(aggregationBuilder -> aggregationBuilder .source(planBuilder.values(key)) .addGroupingSet(key) .addAggregation(a, planBuilder.expression("count()"), ImmutableList.of()) .addAggregation(b, planBuilder.expression("count()"), ImmutableList.of()))); }
Source:
public void deleteValue(final String secretKey) { try { final KeyStore ks = getSecretsStore(); ks.deleteEntry(secretKey); saveSecretsStore(ks); flushCache(); } catch (KeyStoreException e) { Logger.warn(this.getClass(), "Unable to delete secret from " + SECRETS_STORE_FILE + ": " + e); throw new DotRuntimeException(e); } }

Target:
public void deleteValue(final String secretKey) { try { final KeyStore keyStore = getSecretsStore(); keyStore.deleteEntry(secretKey); saveSecretsStore(keyStore); flushCache(secretKey); } catch (KeyStoreException | DotCacheException e) { Logger.warn(this.getClass(), "Unable to delete secret from " + SECRETS_STORE_FILE + ": " + e); throw new DotRuntimeException(e); } }
Source:
private void createCommonViewer(Composite container, IProject project) { commonViewer = new CommonViewer(navigatorId, container, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL); INavigatorContentService contentService = NavigatorContentServiceFactory.INSTANCE .createContentService(navigatorId, commonViewer); contentService.createCommonContentProvider(); contentService.createCommonLabelProvider(); INavigatorFilterService filterService = commonViewer.getNavigatorContentService().getFilterService(); ViewerFilter[] visibleFilters = filterService.getVisibleFilters(true); for (int i = 0; i < visibleFilters.length; i++) { commonViewer.addFilter(visibleFilters[i]); } commonViewer.setSorter(new CommonViewerSorter()); commonViewer.addFilter(new TypeListPatternFilter()); commonViewer.getControl().addMouseListener(new MouseListener() { @Override public void mouseUp(MouseEvent e) { } @Override public void mouseDown(MouseEvent e) { commonViewer.getControl().forceFocus(); } @Override public void mouseDoubleClick(MouseEvent e) { } }); if (project.getName().equals(TypeLibraryTags.TOOL_LIBRARY_PROJECT_NAME)) { commonViewer.setInput(TypeLibrary.getToolLibFolder()); } else { commonViewer.setInput(project); } GridData fillBoth = new GridData(); fillBoth.horizontalAlignment = GridData.FILL; fillBoth.grabExcessHorizontalSpace = true; fillBoth.verticalAlignment = GridData.FILL; fillBoth.grabExcessVerticalSpace = true; commonViewer.getControl().setLayoutData(fillBoth); }

Target:
private void createCommonViewer(Composite container, IProject project) { commonViewer = new CommonViewer(navigatorId, container, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL); INavigatorContentService contentService = NavigatorContentServiceFactory.INSTANCE .createContentService(navigatorId, commonViewer); contentService.createCommonContentProvider(); contentService.createCommonLabelProvider(); INavigatorFilterService filterService = commonViewer.getNavigatorContentService().getFilterService(); ViewerFilter[] visibleFilters = filterService.getVisibleFilters(true); for (int i = 0; i < visibleFilters.length; i++) { commonViewer.addFilter(visibleFilters[i]); } commonViewer.setSorter(new CommonViewerSorter()); commonViewer.addFilter(new TypeListPatternFilter()); commonViewer.getControl().addMouseListener(new MouseListener() { @Override public void mouseUp(MouseEvent e) { } @Override public void mouseDown(MouseEvent e) { commonViewer.getControl().forceFocus(); } @Override public void mouseDoubleClick(MouseEvent e) { } }); if (project.getName().equals(TypeLibraryTags.TOOL_LIBRARY_PROJECT_NAME)) { commonViewer.setInput(TypeLibrary.getToolLibFolder()); } else { commonViewer.setInput(project); } GridData fillBoth = new GridData(GridData.FILL, GridData.FILL, true, true); commonViewer.getControl().setLayoutData(fillBoth); }
Source:
public Client map(ClientsRecord r) { Long lastSeen = r.getLastseen(); ApiDate dateLastSeen; if (lastSeen == null) { dateLastSeen = null; } else { dateLastSeen = new ApiDate(lastSeen); } return new Client( r.getId(), r.getName(), r.getDescription(), new ApiDate(r.getCreatedat()), r.getCreatedby(), new ApiDate(r.getUpdatedat()), r.getUpdatedby(), dateLastSeen, r.getEnabled(), r.getAutomationallowed() ); }

Target:
public Client map(ClientsRecord r) { ApiDate lastSeen = Optional.ofNullable(r.getLastseen()).map(ApiDate::new).orElse(null); return new Client( r.getId(), r.getName(), r.getDescription(), new ApiDate(r.getCreatedat()), r.getCreatedby(), new ApiDate(r.getUpdatedat()), r.getUpdatedby(), lastSeen, r.getEnabled(), r.getAutomationallowed() ); }
Source:
public static List<ServiceRegistration> scanServiceInfo(ServiceInfo serviceInfo) { return Arrays.stream(serviceInfo.serviceInstance().getClass().getInterfaces()) .filter(serviceInterface -> serviceInterface.isAnnotationPresent(Service.class)) .map( serviceInterface -> { Map<String, String> userTags = serviceInfo.tags(); Map<String, String> apiTags = Reflect.serviceTags(serviceInterface); Map<String, String> buffer = new HashMap<>(apiTags); buffer.putAll(userTags); return new InterfaceInfo(serviceInterface, Collections.unmodifiableMap(buffer)); }) .map( interfaceInfo -> { Class<?> serviceInterface = interfaceInfo.serviceInterface; Map<String, String> serviceTags = interfaceInfo.tags; String namespace = Reflect.serviceName(serviceInterface); List<ServiceMethodDefinition> actions = Arrays.stream(serviceInterface.getMethods()) .filter(method -> method.isAnnotationPresent(ServiceMethod.class)) .map( method -> new ServiceMethodDefinition(Reflect.methodName(method)) .setTags(Reflect.serviceMethodTags(method))) .collect(Collectors.toList()); return new ServiceRegistration(namespace, serviceTags, actions); }) .collect(Collectors.toList()); }

Target:
public static List<ServiceRegistration> scanServiceInfo(ServiceInfo serviceInfo) { return Arrays.stream(serviceInfo.serviceInstance().getClass().getInterfaces()) .filter(serviceInterface -> serviceInterface.isAnnotationPresent(Service.class)) .map( serviceInterface -> { Map<String, String> serviceInfoTags = serviceInfo.tags(); Map<String, String> apiTags = Reflect.serviceTags(serviceInterface); Map<String, String> buffer = new HashMap<>(apiTags); buffer.putAll(serviceInfoTags); return new InterfaceInfo(serviceInterface, Collections.unmodifiableMap(buffer)); }) .map( interfaceInfo -> { Class<?> serviceInterface = interfaceInfo.serviceInterface; Map<String, String> serviceTags = interfaceInfo.tags; String namespace = Reflect.serviceName(serviceInterface); List<ServiceMethodDefinition> actions = Arrays.stream(serviceInterface.getMethods()) .filter(method -> method.isAnnotationPresent(ServiceMethod.class)) .map( method -> new ServiceMethodDefinition( Reflect.methodName(method), Reflect.serviceMethodTags(method))) .collect(Collectors.toList()); return new ServiceRegistration(namespace, serviceTags, actions); }) .collect(Collectors.toList()); }
Source:
public String generateURL( String scheme, String clusterName ) { String clusterURL = null; try { if ( !Const.isEmpty( clusterName ) && !Const.isEmpty( clusterName ) ) { NamedCluster namedCluster = read( clusterName, Spoon.getInstance().getMetaStore() ); String ncHostname = null, ncPort = null, ncUsername = null, ncPassword = null; if ( namedCluster != null ) { if ( scheme.equals( HadoopSpoonPlugin.HDFS_SCHEME ) ) { ncHostname = namedCluster.getHdfsHost() != null ? namedCluster.getHdfsHost() : ""; ncPort = namedCluster.getHdfsPort() != null ? namedCluster.getHdfsPort() : ""; ncUsername = namedCluster.getHdfsUsername() != null ? namedCluster.getHdfsUsername() : ""; ncPassword = namedCluster.getHdfsPassword() != null ? namedCluster.getHdfsPassword() : ""; } ncHostname = getVariableSpace().environmentSubstitute( ncHostname ); ncPort = getVariableSpace().environmentSubstitute( ncPort ); ncUsername = getVariableSpace().environmentSubstitute( ncUsername ); ncPassword = getVariableSpace().environmentSubstitute( ncPassword ); StringBuffer urlString = new StringBuffer( scheme ); urlString.append( "://" ); if ( ncUsername != null && !ncUsername.trim().equals( "" ) ) { urlString.append( ncUsername ); urlString.append( ":" ); urlString.append( ncPassword ); urlString.append( "@" ); } urlString.append( ncHostname ); if ( !Const.isEmpty( ncPort ) ) { urlString.append( ":" ); urlString.append( ncPort ); } clusterURL = urlString.toString(); } } } catch ( Exception e ) { clusterURL = null; } return clusterURL; }

Target:
public String generateURL( String scheme, String clusterName ) { String clusterURL = null; try { if ( !Const.isEmpty( scheme ) && !Const.isEmpty( clusterName ) ) { NamedCluster namedCluster = read( clusterName, Spoon.getInstance().getMetaStore() ); String ncHostname = null, ncPort = null, ncUsername = null, ncPassword = null; if ( namedCluster != null ) { if ( scheme.equals( HadoopSpoonPlugin.HDFS_SCHEME ) ) { ncHostname = namedCluster.getHdfsHost() != null ? namedCluster.getHdfsHost() : ""; ncPort = namedCluster.getHdfsPort() != null ? namedCluster.getHdfsPort() : ""; ncUsername = namedCluster.getHdfsUsername() != null ? namedCluster.getHdfsUsername() : ""; ncPassword = namedCluster.getHdfsPassword() != null ? namedCluster.getHdfsPassword() : ""; } ncHostname = getVariableSpace().environmentSubstitute( ncHostname ); ncPort = getVariableSpace().environmentSubstitute( ncPort ); ncUsername = getVariableSpace().environmentSubstitute( ncUsername ); ncPassword = getVariableSpace().environmentSubstitute( ncPassword ); UrlFileName file = new UrlFileName( scheme, ncHostname, Integer.parseInt( ncPort ), -1, ncUsername, ncPassword, null, null, null ); clusterURL = file.getURI(); } } } catch ( Exception e ) { clusterURL = null; } return clusterURL; }
Source:
protected void runCommands() { List<AttachNetworkToVdsGroupParameter> params = new ArrayList<>(); Set<Guid> networkIds = new HashSet<>(); for (CommandBase<?> command : getCommands()) { if (command.getReturnValue().getCanDoAction()) { AttachNetworkToVdsGroupParameter parameters = (AttachNetworkToVdsGroupParameter) command.getParameters(); params.add(parameters); Network network = DbFacade.getInstance().getNetworkDao().get(parameters.getNetworkCluster().getNetworkId()); if (NetworkUtils.isConfiguredByLabel(network)) { networkIds.add(network.getId()); } } } if (networkIds.size() <= 1) { super.runCommands(); } if (!params.isEmpty()) { Backend.getInstance().runInternalAction(getActionType(), new ClusterNetworksParameters(params.get(0).getVdsGroupId(), params)); } }

Target:
protected void runCommands() { List<AttachNetworkToVdsGroupParameter> params = new ArrayList<>(); Set<Guid> networkIds = new HashSet<>(); for (CommandBase<?> command : getCommands()) { if (command.getReturnValue().getCanDoAction()) { AttachNetworkToVdsGroupParameter parameters = (AttachNetworkToVdsGroupParameter) command.getParameters(); params.add(parameters); Network network = DbFacade.getInstance().getNetworkDao().get(parameters.getNetworkCluster().getNetworkId()); if (NetworkUtils.isConfiguredByLabel(network)) { networkIds.add(network.getId()); } } } if (networkIds.size() <= 1) { super.runCommands(); return; } if (!params.isEmpty()) { Backend.getInstance().runInternalAction(VdcActionType.AttachNetworksToCluster, new ClusterNetworksParameters(params.get(0).getVdsGroupId(), params)); } }
Source:
private ListenableFuture<?> stashOrSubmitTask(RunnableWithES runnable, boolean callExecute) { if (!m_isActive) { synchronized (m_executorLock) { if (!m_isActive) { m_queuedActions.add(runnable); return Futures.immediateFuture(null); } } } setupExecutor(); runnable.setExecutorService(m_executor.get()); if (m_executor.get().isShutdown()) { return Futures.immediateFuture(null); } if (callExecute) { m_executor.get().execute(runnable); return Futures.immediateFuture(null); } else { return m_executor.get().submit(runnable); } }

Target:
private ListenableFuture<?> stashOrSubmitTask(RunnableWithES runnable, boolean callExecute) { if (m_executor==null) { synchronized (m_executorLock) { if (m_executor==null) { if (m_queuedActions.size() > 50) { exportLog.error("Queue for export source for generation " + m_generation + " is going beyond 50. Not queueing anymore events"); return Futures.immediateFuture(null); } m_queuedActions.add(runnable); return Futures.immediateFuture(null); } } } runnable.setExecutorService(m_executor); if (m_executor.isShutdown()) { return Futures.immediateFuture(null); } if (callExecute) { m_executor.execute(runnable); return Futures.immediateFuture(null); } else { return m_executor.submit(runnable); } }
Source:
public void dsnBounceShouldAddPrefixToSubjectWhenPrefixIsConfigured() throws Exception { FakeMailetConfig mailetConfig = FakeMailetConfig.builder() .mailetName(MAILET_NAME) .mailetContext(fakeMailContext) .setProperty("prefix", "pre") .build(); dsnBounce.init(mailetConfig); FakeMail mail = FakeMail.builder() .name(MAILET_NAME) .sender(MailAddressFixture.ANY_AT_JAMES) .mimeMessage(MimeMessageBuilder.mimeMessageBuilder() .setSubject("My subject")) .build(); dsnBounce.service(mail); List<SentMail> sentMails = fakeMailContext.getSentMails(); assertThat(sentMails).hasSize(1); SentMail sentMail = sentMails.get(0); assertThat(sentMail.getSubject().orElse(null)).isEqualTo("pre My subject"); }

Target:
public void dsnBounceShouldAddPrefixToSubjectWhenPrefixIsConfigured() throws Exception { FakeMailetConfig mailetConfig = FakeMailetConfig.builder() .mailetName(MAILET_NAME) .mailetContext(fakeMailContext) .setProperty("prefix", "pre") .build(); dsnBounce.init(mailetConfig); FakeMail mail = FakeMail.builder() .name(MAILET_NAME) .sender(MailAddressFixture.ANY_AT_JAMES) .mimeMessage(MimeMessageBuilder.mimeMessageBuilder() .setSubject("My subject")) .build(); dsnBounce.service(mail); assertThat(fakeMailContext.getSentMails()).hasSize(1).allSatisfy( sentMail -> assertThat(sentMail.getSubject()).contains("pre My subject")); }
Source:
private static void validateSelectionClause(Map<Identifier, Expression> aliasMap, PinotQuery pinotQuery) throws SqlCompilationException { Set<String> aliasKeys = new HashSet<>(); for (Identifier identifier : aliasMap.keySet()) { String aliasName = identifier.getName().toLowerCase(); if (aliasKeys.contains(aliasName)) { throw new SqlCompilationException("Duplicated alias name found."); } aliasKeys.add(aliasName); } for (Expression selectExpr : pinotQuery.getSelectList()) { matchIdentifierInAliasMap(selectExpr, aliasKeys); } }

Target:
private static void validateSelectionClause(Map<Identifier, Expression> aliasMap, PinotQuery pinotQuery) throws SqlCompilationException { Set<String> aliasKeys = new HashSet<>(); for (Identifier identifier : aliasMap.keySet()) { String aliasName = identifier.getName().toLowerCase(); if (!aliasKeys.add(aliasName)) { throw new SqlCompilationException("Duplicated alias name found."); } } for (Expression selectExpr : pinotQuery.getSelectList()) { matchIdentifierInAliasMap(selectExpr, aliasKeys); } }
Source:
public AcknowledgementType auditLog(LogEventRequestType request, AssertionType assertion) { LOG.debug("Entering AuditRepositoryProxyWebServiceSecured.auditLog(...)"); if (request.getAuditMessage() == null) { LOG.error("Audit Request Message is null"); synchronized (result) { return result; } } else { secureRequest.setAuditMessage(request.getAuditMessage()); } secureRequest.setDirection(request.getDirection()); secureRequest.setRemoteHCID(request.getRemoteHCID()); secureRequest.setEventType(request.getEventType()); secureRequest.setEventID(request.getEventID()); secureRequest.setEventOutcomeIndicator(request.getEventOutcomeIndicator()); secureRequest.setEventTimestamp(request.getEventTimestamp()); secureRequest.setUserId(request.getUserId()); secureRequest.setRelatesTo(request.getRelatesTo()); secureRequest.setRequestMessageId(request.getRequestMessageId()); try { String url = oProxyHelper.getUrlLocalHomeCommunity(NhincConstants.AUDIT_REPO_SECURE_SERVICE_NAME); if (NullChecker.isNotNullish(url)) { ServicePortDescriptor<AuditRepositoryManagerSecuredPortType> portDescriptor = new AuditRepositorySecuredServicePortDescriptor(); CONNECTClient<AuditRepositoryManagerSecuredPortType> client = CONNECTCXFClientFactory.getInstance() .getCONNECTClientSecured(portDescriptor, url, assertion); synchronized (result) { result = (AcknowledgementType) client.invokePort(AuditRepositoryManagerSecuredPortType.class, invokeMethodName, secureRequest); } } } catch (Exception e) { LOG.error("Failed to call the web service (" + NhincConstants.AUDIT_REPO_SECURE_SERVICE_NAME + "). An unexpected exception occurred. " + "Exception: " + e.getLocalizedMessage(), e); } LOG.debug("In AuditRepositoryProxyWebServiceSecured.auditLog(...) - completed called to ConnectionManager to " + "retrieve endpoint."); return result; }

Target:
public AcknowledgementType auditLog(LogEventRequestType request, AssertionType assertion) { LOG.debug("Entering AuditRepositoryProxyWebServiceSecured.auditLog(...)"); if (request.getAuditMessage() == null) { LOG.error("Audit Request Message is null"); synchronized (result) { return result; } } try { String url = oProxyHelper.getUrlLocalHomeCommunity(NhincConstants.AUDIT_REPO_SECURE_SERVICE_NAME); if (NullChecker.isNotNullish(url)) { ServicePortDescriptor<AuditRepositoryManagerSecuredPortType> portDescriptor = new AuditRepositorySecuredServicePortDescriptor(); CONNECTClient<AuditRepositoryManagerSecuredPortType> client = CONNECTCXFClientFactory.getInstance() .getCONNECTClientSecured(portDescriptor, url, assertion); synchronized (result) { result = (AcknowledgementType) client.invokePort(AuditRepositoryManagerSecuredPortType.class, invokeMethodName, createLogSecureEventRequestType(request)); } } } catch (Exception e) { LOG.error("Failed to call the web service (" + NhincConstants.AUDIT_REPO_SECURE_SERVICE_NAME + "). An unexpected exception occurred. " + "Exception: " + e.getLocalizedMessage(), e); } LOG.debug("In AuditRepositoryProxyWebServiceSecured.auditLog(...) - completed called to ConnectionManager to " + "retrieve endpoint."); return result; }
Source:
static List<Class<? extends RequirementFulfiller>> collectFulfillers(List<Class<? extends RequirementFulfiller>> builtinFulfillers, Class<? extends Annotation> filterAnnotation) { Set<Class<? extends RequirementFulfiller>> userFulfillers = getAnnotatedSubTypesOf(RequirementFulfiller.class, filterAnnotation); List<Class<? extends RequirementFulfiller>> allFulfillers = new ArrayList<>(builtinFulfillers); allFulfillers.addAll(userFulfillers); return ImmutableList.copyOf( allFulfillers.stream() .sorted(new RequirementFulfillerByPriorityComparator()) .collect(toList()) ); }

Target:
static List<Class<? extends RequirementFulfiller>> collectFulfillers(List<Class<? extends RequirementFulfiller>> builtinFulfillers, Class<? extends Annotation> filterAnnotation) { List<Class<? extends RequirementFulfiller>> allFulfillers = scanForFulfillersAndSort(filterAnnotation); allFulfillers.addAll(getBuiltInFulfillerPosition(allFulfillers), builtinFulfillers); return ImmutableList.copyOf(allFulfillers); }
Source:
public void delete(long fileId, long pageIndex) throws IOException { Files.delete(getFilePath(fileId, pageIndex)); }

Target:
public void delete(long fileId, long pageIndex) throws IOException, PageNotFoundException { Path p = getFilePath(fileId, pageIndex); if (!Files.exists(p)) { throw new PageNotFoundException(p.toString()); } Files.delete(p); mSize.decrementAndGet(); if (!Files.newDirectoryStream(p.getParent()).iterator().hasNext()) { Files.delete(p.getParent()); } }
Source:
public long maxWorkflowTasks() { return systemConfig.get("executor.task_max_run", long.class, MAX_WORKFLOW_TASKS); }

Target:
public long maxWorkflowTasks() { return numOfMaxWorkflowTasks; }
Source:
private static RelationalSymbolicValue binaryRelationToSymbolicValue(BinaryRelation binaryRelation) { switch (binaryRelation.kind) { case EQUAL: case METHOD_EQUALS: case LESS_THAN: return new RelationalSymbolicValue(binaryRelation.kind, binaryRelation.leftOp, binaryRelation.rightOp); case NOT_EQUAL: return new RelationalSymbolicValue(Kind.NOT_EQUAL, binaryRelation.leftOp, binaryRelation.rightOp); case GREATER_THAN: return new RelationalSymbolicValue(Kind.LESS_THAN, binaryRelation.rightOp, binaryRelation.leftOp); case GREATER_THAN_OR_EQUAL: return new RelationalSymbolicValue(Kind.GREATER_THAN_OR_EQUAL, binaryRelation.leftOp, binaryRelation.rightOp); case LESS_THAN_OR_EQUAL: return new RelationalSymbolicValue(Kind.GREATER_THAN_OR_EQUAL, binaryRelation.rightOp, binaryRelation.leftOp); case NOT_METHOD_EQUALS: return new RelationalSymbolicValue(Kind.NOT_METHOD_EQUALS, binaryRelation.rightOp, binaryRelation.leftOp); default: throw new IllegalStateException("Unable to convert to relational SV " + binaryRelation); } }

Target:
private static RelationalSymbolicValue binaryRelationToSymbolicValue(BinaryRelation binaryRelation) { switch (binaryRelation.kind) { case EQUAL: case METHOD_EQUALS: case NOT_EQUAL: case NOT_METHOD_EQUALS: case LESS_THAN: case GREATER_THAN_OR_EQUAL: return new RelationalSymbolicValue(binaryRelation.kind, binaryRelation.leftOp, binaryRelation.rightOp); case GREATER_THAN: case LESS_THAN_OR_EQUAL: return new RelationalSymbolicValue(binaryRelation.kind.symmetric(), binaryRelation.rightOp, binaryRelation.leftOp); default: throw new IllegalStateException("Unable to convert to relational SV " + binaryRelation); } }
Source:
public Component getContent(Project project, ExtensionUtil util) { Layout layout = new CssLayout(); layout.addStyleName(STYLE_SCRUM_INFOBOX); layout.setSizeFull(); boolean rendered = false; ScrumProjectExt scrumExt = project.getExtension(ScrumProjectExt.class); if (scrumExt != null) { if (CollectionUtils.isNotBlank(scrumExt.getProductOwners())) { createLabel(layout, "Product Owner", STYLE_TEAMLABEL); Component peopleComponent = PeopleComponent.getPeopleListComponentForMember(scrumExt.getProductOwners()); layout.addComponent(peopleComponent); rendered = true; } if (CollectionUtils.isNotBlank(scrumExt.getScrumMasters())) { createLabel(layout, "Scrum Master", STYLE_TEAMLABEL); Component peopleComponent = PeopleComponent.getPeopleListComponentForMember(scrumExt.getScrumMasters()); layout.addComponent(peopleComponent); rendered = true; } if (StringUtils.isNotBlank(scrumExt.getBacklogUrl())) { createLink(layout, "Scrum Backlog", scrumExt.getBacklogUrl(), DEFAULT_TARGET, STYLE_SCRUM_LOG); rendered = true; } addLastModifiedInfo(layout, scrumExt); } if (!rendered) { createLabel(layout, "SCRUM extension added but no data maintained.", STYLE_LABEL); } addLastModifiedInfo(layout, scrumExt); return layout; }

Target:
public Component getContent(Project project, ExtensionUtil util) { Layout layout = new CssLayout(); layout.addStyleName(STYLE_SCRUM_INFOBOX); layout.setSizeFull(); boolean rendered = false; ScrumProjectExt scrumExt = project.getExtension(ScrumProjectExt.class); if (scrumExt != null) { if (CollectionUtils.isNotBlank(scrumExt.getProductOwners())) { createLabel(layout, "Product Owner", STYLE_TEAMLABEL); Component peopleComponent = PeopleComponent.getPeopleListComponentForMember(scrumExt.getProductOwners()); layout.addComponent(peopleComponent); rendered = true; } if (CollectionUtils.isNotBlank(scrumExt.getScrumMasters())) { createLabel(layout, "Scrum Master", STYLE_TEAMLABEL); Component peopleComponent = PeopleComponent.getPeopleListComponentForMember(scrumExt.getScrumMasters()); layout.addComponent(peopleComponent); rendered = true; } if (StringUtils.isNotBlank(scrumExt.getBacklogUrl())) { createLink(layout, "Scrum Backlog", scrumExt.getBacklogUrl(), DEFAULT_TARGET, STYLE_SCRUM_LOG); rendered = true; } } if (!rendered) { createLabel(layout, "SCRUM extension added but no data maintained.", STYLE_LABEL); } return layout; }
Source:
public AggregationBuilder groupingSets(List<List<Symbol>> groupingSets) { this.groupingSets.clear(); this.groupingSets.addAll(groupingSets); return this; }

Target:
public AggregationBuilder groupingSets(List<List<Symbol>> groupingSets) { checkState(this.groupingSets.isEmpty(), "groupingSets already defined"); this.groupingSets.addAll(groupingSets); return this; }
Source:
public ImageView getProfileView() { final View profileView = findViewById(R.id.toolbar_profile_image); if (profileView != null && profileView instanceof ImageView) { profileView.setVisibility(View.VISIBLE); return (ImageView) profileView; } return null; }

Target:
public ImageView getProfileView() { final View profileView = findViewById(R.id.toolbar_profile_image); if (profileView != null && profileView instanceof ImageView) { return (ImageView) profileView; } return null; }
Source:
public void testGetAllLoadBalancers() { List<LoadBalancer> loadBalancers = api.loadBalancerApi().getAllLoadBalancers(); assertNotNull(loadBalancers); assertFalse(loadBalancers.isEmpty()); }

Target:
public void testGetAllLoadBalancers() { List<LoadBalancer> loadBalancers = api.loadBalancerApi().getAllLoadBalancers(); assertFalse(loadBalancers.isEmpty()); }
Source:
public static HostAndPortRange parse(String addrStr, int dfltPortFrom, int dfltPortTo, String errMsgPrefix) throws IgniteCheckedException { assert dfltPortFrom <= dfltPortTo; String host; String portStr; int portFrom; int portTo; if (F.isEmpty(addrStr)) throw createParseError(addrStr, errMsgPrefix, "Address is empty"); if (addrStr.contains("[")) { int hostEndIdx = addrStr.indexOf(']'); if (hostEndIdx == -1) { throw createParseError(addrStr, errMsgPrefix, "IPv6 host is incorrect"); } host = addrStr.substring(1, hostEndIdx); if (hostEndIdx == addrStr.length() - 1) { portFrom = dfltPortFrom; portTo = dfltPortTo; } else { portStr = addrStr.substring(hostEndIdx + 2); int[] ports = verifyPortStr(addrStr, errMsgPrefix, portStr); portFrom = ports[0]; portTo = ports[1]; } } else { final int colIdx = addrStr.indexOf(':'); if (colIdx > 0) { host = addrStr.substring(0, colIdx); portStr = addrStr.substring(colIdx + 1); int[] ports = verifyPortStr(addrStr, errMsgPrefix, portStr); portFrom = ports[0]; portTo = ports[1]; } else if (colIdx == 0) { throw createParseError(addrStr, errMsgPrefix, "Host name is empty"); } else { host = addrStr; portFrom = dfltPortFrom; portTo = dfltPortTo; } } return new HostAndPortRange(host, portFrom, portTo); }

Target:
public static HostAndPortRange parse(String addrStr, int dfltPortFrom, int dfltPortTo, String errMsgPrefix) throws IgniteCheckedException { assert dfltPortFrom <= dfltPortTo; String host; String portStr; int portFrom; int portTo; if (F.isEmpty(addrStr)) throw createParseError(addrStr, errMsgPrefix, "Address is empty"); if (addrStr.charAt(0) == '[') { int hostEndIdx = addrStr.indexOf(']'); if (hostEndIdx == -1) throw createParseError(addrStr, errMsgPrefix, "Failed to parse IPv6 address, missing ']'"); host = addrStr.substring(1, hostEndIdx); if (hostEndIdx == addrStr.length() - 1) { portFrom = dfltPortFrom; portTo = dfltPortTo; } else { portStr = addrStr.substring(hostEndIdx + 2); int[] ports = verifyPortStr(addrStr, errMsgPrefix, portStr); portFrom = ports[0]; portTo = ports[1]; } } else { final int colIdx = addrStr.lastIndexOf(':'); if (colIdx > 0) { if (addrStr.lastIndexOf(':', colIdx - 1) != -1) { try { Inet6Address.getByName(addrStr); host = addrStr; portFrom = dfltPortFrom; portTo = dfltPortTo; } catch (UnknownHostException e) { throw createParseError(addrStr, errMsgPrefix, "IPv6 is incorrect", e); } } else { host = addrStr.substring(0, colIdx); portStr = addrStr.substring(colIdx + 1); int[] ports = verifyPortStr(addrStr, errMsgPrefix, portStr); portFrom = ports[0]; portTo = ports[1]; } } else if (colIdx == 0) throw createParseError(addrStr, errMsgPrefix, "Host name is empty"); else { host = addrStr; portFrom = dfltPortFrom; portTo = dfltPortTo; } } return new HostAndPortRange(host, portFrom, portTo); }