auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public Set<String> getConsumedEvents() { Set<String> set = new HashSet<>(super.getConsumedEvents()); if (hasCells == null) { return set; } for(HasCell<T, ?> currentHasCell : hasCells) { if(currentHasCell instanceof Column) { Set<String> consumedEvents = ((Column)(currentHasCell)).getCell().getConsumedEvents(); if(consumedEvents != null) { set.addAll(consumedEvents); } } <START> if(currentHasCell instanceof AbstractCell) { <END> set.addAll(((AbstractCell)currentHasCell).getConsumedEvents()); } } return set; }</code><technical_language>I interface -- "Cell" instead of "AbstractCell". a more proper do in Java. Other that, good</technical_language>

Target:
public Set<String> getConsumedEvents() { Set<String> set = new HashSet<>(super.getConsumedEvents()); if (hasCells == null) { return set; } for(HasCell<T, ?> currentHasCell : hasCells) { if(currentHasCell instanceof Column) { Set<String> consumedEvents = ((Column)(currentHasCell)).getCell().getConsumedEvents(); if(consumedEvents != null) { set.addAll(consumedEvents); } } if(currentHasCell instanceof Cell) { set.addAll(((Cell)currentHasCell).getConsumedEvents()); } } return set; }
Source:
<code>public void scalaOutputTest() throws IOException, InterruptedException { Note note = ZeppelinServer.notebook.createNote("note1", anonymous); Paragraph p = note.addNewParagraph(anonymous); p.setText("%spark import java.util.Date\n" + "import java.net.URL\n" + "println(\"hello\")\n" ); note.run(p.getId(), true); assertEquals(Status.FINISHED, p.getStatus()); assertEquals("hello\n" + "import java.util.Date\n" + "import java.net.URL\n", p.getReturn().message().get(0).getData()); p.setText("%spark invalid_code"); note.run(p.getId(), true); assertEquals(Status.ERROR, p.getStatus()); assertTrue(p.getReturn().message().get(0).getData().contains("error: ")); p.setText("%spark(p1=v1,p2=v2) print(z.getInterpreterContext().getLocalProperties().size())"); note.run(p.getId(), true); assertEquals(Status.FINISHED, p.getStatus()); assertEquals("2", p.getReturn().message().get(0).getData()); List<InterpreterCompletion> completions = note.completion(p.getId(), "sc.", 2); assertTrue(completions.size() > 0); p.setText("%spark sc.range(1,10).map(e=>{Thread.sleep(1000); e}).collect()"); note.run(p.getId(), false); <START> Thread.sleep(3000); <END> p.abort(); Thread.sleep(3000); assertEquals(Status.ABORT, p.getStatus()); ZeppelinServer.notebook.removeNote(note.getId(), anonymous); }</code><technical_language>busy waiting, event latch here? In current implementation, this test lasts for seconds, if is necessary. Unfortunately, tests slow = (</technical_language>

Target:
public void scalaOutputTest() throws IOException, InterruptedException { Note note = ZeppelinServer.notebook.createNote("note1", anonymous); Paragraph p = note.addNewParagraph(anonymous); p.setText("%spark import java.util.Date\n" + "import java.net.URL\n" + "println(\"hello\")\n" ); note.run(p.getId(), true); assertEquals(Status.FINISHED, p.getStatus()); assertEquals("hello\n" + "import java.util.Date\n" + "import java.net.URL\n", p.getReturn().message().get(0).getData()); p.setText("%spark invalid_code"); note.run(p.getId(), true); assertEquals(Status.ERROR, p.getStatus()); assertTrue(p.getReturn().message().get(0).getData().contains("error: ")); p.setText("%spark(p1=v1,p2=v2) print(z.getInterpreterContext().getLocalProperties().size())"); note.run(p.getId(), true); assertEquals(Status.FINISHED, p.getStatus()); assertEquals("2", p.getReturn().message().get(0).getData()); List<InterpreterCompletion> completions = note.completion(p.getId(), "sc.", 2); assertTrue(completions.size() > 0); p.setText("%spark sc.range(1,10).map(e=>{Thread.sleep(1000); e}).collect()"); note.run(p.getId(), false); waitForRunning(p); p.abort(); waitForFinish(p); assertEquals(Status.ABORT, p.getStatus()); ZeppelinServer.notebook.removeNote(note.getId(), anonymous); }
Source:
<code>public T get() { if (persistence == null) { <START> synchronized (this) { <END> this.persistence = build(conn, databases); } } if (disableCaching) { persistence.disableCaching(); } return persistence; }</code><technical_language>is synchronization prevent people simultaneously database connection? if so, I a case call get() persistences simultaneously time. if goal synchronizing conn safer</technical_language>

Target:
public T get() { if (persistence == null) { synchronized (this) { if (persistence == null) { this.persistence = build(conn, databases); } } } if (disableCaching) { persistence.disableCaching(); } return persistence; }
Source:
<code>public void write(KeyValue keyValue) throws IOException { this.mWriter.write(keyValue.getValue()); <START> if (DELIMITER != 92){ <END> this.mWriter.write(DELIMITER); } }</code><technical_language>hard-coded 92</technical_language>

Target:
public void write(KeyValue keyValue) throws IOException { this.mWriter.write(keyValue.getValue()); if (addDelimiter){ this.mWriter.write(mDelimiter); } }
Source:
<code>public void checkAccessModifier(Method method) { final int modifiers = method.getModifiers(); final boolean nonDefaultModifier = <START> Modifier.isPublic(modifiers) || Modifier.isProtected(modifiers) || Modifier.isPrivate(modifiers); <END> if (nonDefaultModifier) { warnOnWrongModifier("Command handler method should be declared with default access modifier.", method); } }</code><technical_language>static import</technical_language>

Target:
public void checkAccessModifier(Method method) { final int modifiers = method.getModifiers(); final boolean nonDefaultModifier = Modifier.isPublic(modifiers) || Modifier.isProtected(modifiers) || Modifier.isPrivate(modifiers); if (nonDefaultModifier) { warnOnWrongModifier("Command handler method should be declared with the default access modifier.", method); } }
Source:
<code>public ImageData getImageData (int zoom) { copyImageDataFromDpiImageStorage(DPIUtil.mapZoomToImageSelectorIndex(zoom)); ImageData returnVal = getImageData (); <START> copyImageDataFromDpiImageStorage(device.getImageSelector()); <END> return returnVal; }</code><technical_language>call copy 2nd time</technical_language>

Target:
public ImageData getImageData (int zoom) { copyImageDataFromDpiImageStorage(DPIUtil.mapZoomToImageSelectorIndex(zoom)); ImageData returnVal = getImageData (); copyImageDataFromDpiImageStorage(getImageSelector()); return returnVal; }
Source:
<code>public void defaultPrefix() throws Exception { final MockHttpServletRequest request = new MockHttpServletRequest("POST", "/hotels"); MockHttpServletResponse response = new MockHttpServletResponse(); FilterChain filterChain = new NoOpFilterChain(); filter.doFilter(request, response, filterChain); <START> assertThat(filter.beforeRequestMessage).isNotNull(); <END> assertThat(filter.beforeRequestMessage.startsWith(AbstractRequestLoggingFilter.DEFAULT_BEFORE_MESSAGE_PREFIX)).isTrue(); assertThat(filter.afterRequestMessage).isNotNull(); assertThat(filter.afterRequestMessage.startsWith(AbstractRequestLoggingFilter.DEFAULT_AFTER_MESSAGE_PREFIX)).isTrue(); }</code><technical_language>suggestion</technical_language>

Target:
public void defaultPrefix() throws Exception { MockHttpServletRequest request = new MockHttpServletRequest("POST", "/hotels"); MockHttpServletResponse response = new MockHttpServletResponse(); FilterChain filterChain = new NoOpFilterChain(); filter.doFilter(request, response, filterChain); assertThat(filter.beforeRequestMessage).startsWith(AbstractRequestLoggingFilter.DEFAULT_BEFORE_MESSAGE_PREFIX); assertThat(filter.afterRequestMessage).startsWith(AbstractRequestLoggingFilter.DEFAULT_AFTER_MESSAGE_PREFIX); }
Source:
<code>public List<Resource> getAllowedResources(PerunSession sess, Member member) throws InternalErrorException, MemberNotExistsException, PrivilegeException { Utils.checkPerunSession(sess); if (!AuthzResolver.isAuthorized(sess, Role.PERUNADMIN) && !AuthzResolver.isAuthorized(sess, Role.VOADMIN, member) <START> && !AuthzResolver.isAuthorized(sess, Role.ENGINE) && !AuthzResolver.isAuthorized(sess, Role.PERUNOBSERVER) <END> && !AuthzResolver.isAuthorized(sess, Role.SELF, member) && !AuthzResolver.isAuthorized(sess, Role.VOOBSERVER, member)) { throw new PrivilegeException(sess, "getAllowedResources"); } getPerunBl().getMembersManagerBl().checkMemberExists(sess, member); return getResourcesManagerBl().getAllowedResources(sess, member); }</code><technical_language>omit check PERUNADMIN role here, of check true for user. Check PERUNOBSERVER stays of course</technical_language>

Target:
public List<Resource> getAllowedResources(PerunSession sess, Member member) throws InternalErrorException, MemberNotExistsException, PrivilegeException { Utils.checkPerunSession(sess); if (!AuthzResolver.isAuthorized(sess, Role.VOADMIN, member) && !AuthzResolver.isAuthorized(sess, Role.VOOBSERVER, member) && !AuthzResolver.isAuthorized(sess, Role.ENGINE) && !AuthzResolver.isAuthorized(sess, Role.PERUNOBSERVER) && !AuthzResolver.isAuthorized(sess, Role.SELF, member)) { throw new PrivilegeException(sess, "getAllowedResources"); } getPerunBl().getMembersManagerBl().checkMemberExists(sess, member); return getResourcesManagerBl().getAllowedResources(sess, member); }
Source:
<code>public List<ImmutableBitSet> getKeys() { <START> return null; <END> }</code><technical_language>consider giving empty list instead of null</technical_language>

Target:
public List<ImmutableBitSet> getKeys() { return Collections.emptyList(); }
Source:
<code>protected void resample() { double[] logWeights = new double[particles.size()]; boolean[] alreadySampled = new boolean[particles.size()]; double maxLogWeight = Double.NEGATIVE_INFINITY; double sumWeights = 0; double[] normalizedWeights = new double[particles.size()]; List<Particle> newParticles = new ArrayList<Particle>(); for (int i = 0; i < particles.size(); i++) { logWeights[i] = particles.get(i).getLatestLogWeight(); maxLogWeight = Math.max(maxLogWeight, logWeights[i]); } if (maxLogWeight == Double.NEGATIVE_INFINITY) { throw new IllegalArgumentException("All particles have zero weight"); } for (int i = 0; i < particles.size(); i++) { normalizedWeights[i] = Math.exp(logWeights[i] - maxLogWeight); if (i > 0) normalizedWeights[i] += normalizedWeights[i - 1]; } sumWeights = normalizedWeights[particles.size() - 1]; double ratio = sumWeights / numParticles; <START> double basis = 0, sampleKey; <END> int selection = 0; for (int i = 0; i < numParticles; i++) { sampleKey = basis + Util.random() * ratio; basis += ratio; while (normalizedWeights[selection] < sampleKey) ++selection; if (!alreadySampled[selection]) { newParticles.add(particles.get(selection)); alreadySampled[selection] = true; } else { newParticles.add(particles.get(selection).copy()); } } particles = newParticles; }</code><technical_language>put in lines</technical_language>

Target:
protected void resample() { double[] logWeights = new double[particles.size()]; boolean[] alreadySampled = new boolean[particles.size()]; double maxLogWeight = Double.NEGATIVE_INFINITY; double sumWeights = 0; double[] normalizedWeights = new double[particles.size()]; List<Particle> newParticles = new ArrayList<Particle>(); for (int i = 0; i < particles.size(); i++) { logWeights[i] = particles.get(i).getLatestLogWeight(); maxLogWeight = Math.max(maxLogWeight, logWeights[i]); } if (maxLogWeight == Double.NEGATIVE_INFINITY) { throw new IllegalArgumentException("All particles have zero weight"); } for (int i = 0; i < particles.size(); i++) { normalizedWeights[i] = Math.exp(logWeights[i] - maxLogWeight); if (i > 0) normalizedWeights[i] += normalizedWeights[i - 1]; } sumWeights = normalizedWeights[particles.size() - 1]; double ratio = sumWeights / numParticles; double basis = 0; double sampleKey = 0; int selection = 0; for (int i = 0; i < numParticles; i++) { sampleKey = basis + Util.random() * ratio; basis += ratio; while (normalizedWeights[selection] < sampleKey) ++selection; if (!alreadySampled[selection]) { newParticles.add(particles.get(selection)); alreadySampled[selection] = true; } else { newParticles.add(particles.get(selection).copy()); } } particles = newParticles; }
Source:
<code>public List<FileSinkCommittable> commit(List<FileSinkCommittable> committables) { List<FileSinkCommittable> needRetry = new ArrayList<>(); for (FileSinkCommittable committable : committables) { if (committable.hasPendingFile()) { try { bucketWriter.recoverPendingFile(committable.getPendingFile()).commitAfterRecovery(); } catch (IOException e) { LOG.error("Failed to commit {}", committable.getPendingFile()); <START> needRetry.add(committable); <END> } } if (committable.hasInProgressFileToCleanup()) { try { bucketWriter.cleanupInProgressFileRecoverable(committable.getInProgressFileToCleanup()); } catch (IOException e) { LOG.error("Failed to cleanup {}", committable.getInProgressFileToCleanup()); needRetry.add(committable); } } } return needRetry; }</code><technical_language>Currently this fail operators throw exception. for simply return empty list open another JIRA a reminder, enable retry operators allow it. other option a flag supportsRetry, is false for in future enable it</technical_language>

Target:
public List<FileSinkCommittable> commit(List<FileSinkCommittable> committables) throws IOException { for (FileSinkCommittable committable : committables) { if (committable.hasPendingFile()) { bucketWriter.recoverPendingFile(committable.getPendingFile()).commitAfterRecovery(); } if (committable.hasInProgressFileToCleanup()) { bucketWriter.cleanupInProgressFileRecoverable(committable.getInProgressFileToCleanup()); } } return Collections.emptyList(); }
Source:
<code>private static Optional<Changeset> getChangeset(Component component, ScmInfo scmInfo, DefaultIssue issue) { Set<Integer> involvedLines = new HashSet<>(); DbIssues.Locations locations = issue.getLocations(); if (locations != null) { if (locations.hasTextRange()) { addLines(involvedLines, locations.getTextRange()); } for (Flow f : locations.getFlowList()) { for (Location l : f.getLocationList()) { <START> if (l.getComponentId().equals(component.getUuid())) { <END> addLines(involvedLines, l.getTextRange()); } } } if (!involvedLines.isEmpty()) { return involvedLines.stream() .map(scmInfo::getChangesetForLine) .max(Comparator.comparingLong(Changeset::getDate)); } } Changeset latestChangeset = scmInfo.getLatestChangeset(); if (latestChangeset != null) { return Optional.of(latestChangeset); } return Optional.empty(); }</code><technical_language>a safeguard null, I suggest replace condition if (Objects.equals(l.getComponentId(), component.getUuid()))</technical_language>

Target:
private static Optional<Changeset> getChangeset(Component component, ScmInfo scmInfo, DefaultIssue issue) { Set<Integer> involvedLines = new HashSet<>(); DbIssues.Locations locations = issue.getLocations(); if (locations != null) { if (locations.hasTextRange()) { addLines(involvedLines, locations.getTextRange()); } for (Flow f : locations.getFlowList()) { for (Location l : f.getLocationList()) { if (Objects.equals(l.getComponentId(), component.getUuid())) { addLines(involvedLines, l.getTextRange()); } } } if (!involvedLines.isEmpty()) { return involvedLines.stream() .map(scmInfo::getChangesetForLine) .max(Comparator.comparingLong(Changeset::getDate)); } } Changeset latestChangeset = scmInfo.getLatestChangeset(); if (latestChangeset != null) { return Optional.of(latestChangeset); } return Optional.empty(); }
Source:
<code>public static boolean wouldBeBreakpoint(final byte[] bases) { <START> if ( bases.length <= 1 ) <END> return false; else { for (int i = 0; i < bases.length; i++) { final byte base = bases[i]; if (base == '[' || base == ']') { return true; } } return false; } }</code><technical_language>Code is inconsistent in spacing/braces. consistent I add { } remove extra spaces, this line other lines duplicate this, e.g. 300 331. suggestion if (bases.length <= 1) {</technical_language>

Target:
public static boolean wouldBeBreakpoint(final byte[] bases) { if (bases.length <= 1) { return false; } for (int i = 0; i < bases.length; i++) { final byte base = bases[i]; if (base == BREAKEND_EXTENDING_LEFT || base == BREAKEND_EXTENDING_RIGHT) { return true; } } return false; }
Source:
<code>public Optional<Schedule> parse(String scheduleString) { return delegates.stream() <START> .map(NotThrowingParser::of) <END> .map(it -> it.parse(scheduleString)) .filter(Optional::isPresent).map(Optional::get) .findFirst(); }</code><technical_language>discussed elsewhere, strategy be: * If regex match => Optional.empty() * If regex matches, some extracted field wrong format => runtimeexception in this case, is uncaught hits user, i.e. do need NotThrowingParser. Do agree</technical_language>

Target:
public Optional<Schedule> parse(String scheduleString) { return delegates.stream() .map(it -> it.parse(scheduleString)) .filter(Optional::isPresent).map(Optional::get) .findFirst(); }
Source:
<code>public void closeJob(GeneralSecurityException gse) { <START> callback.onCompletion(new EncryptJobResult(null, null, null), gse); <END> }</code><technical_language>this onCompletion(null, gse)</technical_language>

Target:
public void closeJob(GeneralSecurityException gse) { callback.onCompletion(null, gse); }
Source:
<code><START> public void jobsGridPortlet_fillColumnsFirst() throws MalformedURLException { <END> createFreeStyleJob(); createFreeStyleJob(); createFreeStyleJob(); createFreeStyleJob(); DashboardView v = createDashboardView(); JobsGridPortlet jobsGridPortlet = v.addBottomPortlet(JobsGridPortlet.class); jobsGridPortlet.setNumberOfColumns(3); jobsGridPortlet.setFillColumnFirst(true); v.save(); assertThat(jobsGridPortlet.getJob(1, 3), nullValue()); assertThat(jobsGridPortlet.getJob(2, 2), notNullValue()); }</code><technical_language>simpler if MalformedURLException converted a RuntimeException in getJob method throws is required</technical_language>

Target:
public void jobsGridPortlet_fillColumnsFirst() { createFreeStyleJob(); createFreeStyleJob(); createFreeStyleJob(); createFreeStyleJob(); DashboardView v = createDashboardView(); JobsGridPortlet jobsGridPortlet = v.addBottomPortlet(JobsGridPortlet.class); jobsGridPortlet.setNumberOfColumns(3); jobsGridPortlet.setFillColumnFirst(true); v.save(); assertThat(jobsGridPortlet.getJob(1, 3), nullValue()); assertThat(jobsGridPortlet.getJob(2, 2), notNullValue()); }
Source:
<code>private void initView(Context context) { <START> View view = inflate(context, R.layout.reader_comments_post_header_view, this); <END> }</code><technical_language>view here</technical_language>

Target:
private void initView(Context context) { inflate(context, R.layout.reader_comments_post_header_view, this); }
Source:
<code>protected Channel buildChannel(final ServerConfig serverConfig, final ChannelHandler handlerAdapter) throws InterruptedException { SSLContext sslContext = serverConfig.getSSLContext(); <START> this.ssl = sslContext != null ? true : false; <END> return new ServerBootstrap() .group(execController.getEventLoopGroup()) .channel(ChannelImplDetector.getServerSocketChannelImpl()) .option(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT) .childOption(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT) .childHandler(new ChannelInitializer<SocketChannel>() { @Override protected void initChannel(SocketChannel ch) throws Exception { ChannelPipeline pipeline = ch.pipeline(); if (sslContext != null) { SSLEngine sslEngine = sslContext.createSSLEngine(); sslEngine.setUseClientMode(false); pipeline.addLast("ssl", new SslHandler(sslEngine)); } pipeline.addLast("decoder", new HttpRequestDecoder(4096, 8192, 8192, false)); pipeline.addLast("encoder", new HttpResponseEncoder()); pipeline.addLast("aggregator", new HttpObjectAggregator(serverConfig.getMaxContentLength())); pipeline.addLast("deflater", new SmartHttpContentCompressor()); pipeline.addLast("chunkedWriter", new ChunkedWriteHandler()); pipeline.addLast("adapter", handlerAdapter); } }) .bind(buildSocketAddress(serverConfig)) .sync() .channel(); }</code><technical_language>whynot this.ssl = sslContext != null</technical_language>

Target:
protected Channel buildChannel(final ServerConfig serverConfig, final ChannelHandler handlerAdapter) throws InterruptedException { SSLContext sslContext = serverConfig.getSSLContext(); this.useSsl = sslContext != null; return new ServerBootstrap() .group(execController.getEventLoopGroup()) .channel(ChannelImplDetector.getServerSocketChannelImpl()) .option(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT) .childOption(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT) .childHandler(new ChannelInitializer<SocketChannel>() { @Override protected void initChannel(SocketChannel ch) throws Exception { ChannelPipeline pipeline = ch.pipeline(); if (sslContext != null) { SSLEngine sslEngine = sslContext.createSSLEngine(); sslEngine.setUseClientMode(false); pipeline.addLast("ssl", new SslHandler(sslEngine)); } pipeline.addLast("decoder", new HttpRequestDecoder(4096, 8192, 8192, false)); pipeline.addLast("encoder", new HttpResponseEncoder()); pipeline.addLast("aggregator", new HttpObjectAggregator(serverConfig.getMaxContentLength())); pipeline.addLast("deflater", new SmartHttpContentCompressor()); pipeline.addLast("chunkedWriter", new ChunkedWriteHandler()); pipeline.addLast("adapter", handlerAdapter); } }) .bind(buildSocketAddress(serverConfig)) .sync() .channel(); }
Source:
<code>public PrimitiveToStringConversion(Class<?> sourceType) { super( sourceType ); if ( !sourceType.isPrimitive() ) { <START> throw new IllegalArgumentException( sourceType + " is not primitive type." ); <END> } }</code><technical_language>I original "is _a_ primitive type"</technical_language>

Target:
public PrimitiveToStringConversion(Class<?> sourceType) { super( sourceType ); if ( !sourceType.isPrimitive() ) { throw new IllegalArgumentException( sourceType + " is no primitive type." ); } }
Source:
<code>public void updateProjectConfig(Project project, ProjectConfig projectConfig) throws ServerException, ValueStorageException, ProjectTypeConstraintException, ForbiddenException { List<ProjectConfigDto> modules = new ArrayList<>(); for (ProjectConfig config : projectConfig.getModules()) { getModulesRecursive(config, modules); } final ProjectConfigDto projectConfigDto = DtoFactory.getInstance().createDto(ProjectConfigDto.class) .withPath(project.getPath()) .withName(project.getName()) .withModules(modules) .withSource(DtoFactory.getInstance().createDto(SourceStorageDto.class)); ProjectTypes types = new ProjectTypes(project, projectConfig.getType(), projectConfig.getMixins(), this); types.removeTransient(); projectConfigDto.setType(types.getPrimary().getId()); projectConfigDto.setDescription(projectConfig.getDescription()); ArrayList<String> ms = new ArrayList<>(); <START> ms.addAll(types.getMixins().keySet()); <END> projectConfigDto.setMixins(ms); projectConfigDto.setAttributes(projectConfig.getAttributes()); try { final VirtualFileEntry codenvyDir = project.getBaseFolder().getChild(CODENVY_DIR); if (codenvyDir == null || !codenvyDir.isFolder()) { project.getBaseFolder().createFolder(CODENVY_DIR); } } catch (ForbiddenException | ConflictException e) { throw new ServerException(e.getServiceError()); } filterAttributesRecursive(projectConfigDto, types, project.getBaseFolder()); updateProjectInWorkspace(project.getWorkspace(), projectConfigDto); }</code><technical_language>do in a single line new ArrayList<>(types.getMixins().keySet()) improves memory usage</technical_language>

Target:
public void updateProjectConfig(Project project, ProjectConfig projectConfig) throws ServerException, ValueStorageException, ProjectTypeConstraintException, ForbiddenException { List<ProjectConfigDto> modules = new ArrayList<>(); for (ProjectConfig config : projectConfig.getModules()) { getModulesRecursive(config, modules); } final ProjectConfigDto projectConfigDto = DtoFactory.getInstance().createDto(ProjectConfigDto.class) .withPath(project.getPath()) .withName(project.getName()) .withModules(modules) .withSource(DtoFactory.getInstance().createDto(SourceStorageDto.class)); ProjectTypes types = new ProjectTypes(project, projectConfig.getType(), projectConfig.getMixins(), this); types.removeTransient(); projectConfigDto.setType(types.getPrimary().getId()); projectConfigDto.setDescription(projectConfig.getDescription()); projectConfigDto.setMixins(new ArrayList<>(types.getMixins().keySet())); projectConfigDto.setAttributes(projectConfig.getAttributes()); try { final VirtualFileEntry codenvyDir = project.getBaseFolder().getChild(CODENVY_DIR); if (codenvyDir == null || !codenvyDir.isFolder()) { project.getBaseFolder().createFolder(CODENVY_DIR); } } catch (ForbiddenException | ConflictException e) { throw new ServerException(e.getServiceError()); } filterAttributesRecursive(projectConfigDto, types, project.getBaseFolder()); updateProjectInWorkspace(project.getWorkspace(), projectConfigDto); }
Source:
<code>private String sortTableColumns(String sql) { <START> int posColDef = sql.indexOf('('); <END> String colsStr = sql.substring(posColDef+1, sql.length()-1); String[] cols = colsStr.split(" *, *(?![^\\(]*\\))"); Arrays.sort(cols); return sql.substring(0, posColDef+1) + TextUtils.join(", ", cols) + ")"; }</code><technical_language>Please abbreviate variable names. code shorter, harder understand. Especially this method benefit more descriptive variable names</technical_language>

Target:
private String sortTableColumns(String sql) { int positionOfColumnDefinitions = sql.indexOf('('); String columnDefinitionsSql = sql.substring(positionOfColumnDefinitions + 1, sql.length() - 1); String[] columnDefinitions = columnDefinitionsSql.split(" *, *(?![^(]*\\))"); Arrays.sort(columnDefinitions); String sqlPrefix = sql.substring(0, positionOfColumnDefinitions + 1); String sortedColumnDefinitionsSql = TextUtils.join(", ", columnDefinitions); return sqlPrefix + sortedColumnDefinitionsSql + ")"; }
Source:
<code>private void updateEid() { Map<Integer, Integer> slotMapping = mTelephonyManager.getLogicalToPhysicalSlotMapping(); Integer physicalSlotId = slotMapping.get(mSlotId); if (physicalSlotId != null) { List<UiccCardInfo> infos = mTelephonyManager.getUiccCardsInfo(); for (UiccCardInfo info : infos) { if (info != null && info.getSlotIndex() == <START> physicalSlotId.intValue()) <END> { if (info.isEuicc()) { String eid = info.getEid(); if (!TextUtils.isEmpty(eid)) { mDialog.setText(EID_INFO_VALUE_ID, eid); } } else { mDialog.removeSettingFromScreen(EID_INFO_LABEL_ID); mDialog.removeSettingFromScreen(EID_INFO_VALUE_ID); } break; } } } }</code><technical_language>need for this, checked null. Direct == fine</technical_language>

Target:
private void updateEid() { boolean shouldHaveEid = false; String eid = null; if (mTelephonyManager.getPhoneCount() > PhoneConstants.MAX_PHONE_COUNT_SINGLE_SIM) { Map<Integer, Integer> slotMapping = mTelephonyManager.getLogicalToPhysicalSlotMapping(); Integer physicalSlotId = slotMapping.get(mSlotId); if (physicalSlotId != null) { List<UiccCardInfo> infos = mTelephonyManager.getUiccCardsInfo(); for (UiccCardInfo info : infos) { if (info.getSlotIndex() == physicalSlotId.intValue()) { if (info.isEuicc()) { shouldHaveEid = true; eid = info.getEid(); if (TextUtils.isEmpty(eid)) { eid = mEuiccManager.createForCardId(info.getCardId()).getEid(); } } break; } } } } else { if (mEuiccManager.isEnabled()) { shouldHaveEid = true; eid = mEuiccManager.getEid(); } } if (TextUtils.isEmpty(eid)) { if (!shouldHaveEid) { mDialog.removeSettingFromScreen(EID_INFO_LABEL_ID); mDialog.removeSettingFromScreen(EID_INFO_VALUE_ID); } } else { mDialog.setText(EID_INFO_VALUE_ID, eid); } }
Source:
<code>public ScanRuntimeProvider getScanRuntimeProvider(ScanContext context) { <START> boolean isBounded = numberOfRows == null; <END> return SourceFunctionProvider.of(createSource(), isBounded); }</code><technical_language>opposite</technical_language>

Target:
public ScanRuntimeProvider getScanRuntimeProvider(ScanContext context) { boolean isBounded = numberOfRows != null; return SourceFunctionProvider.of(createSource(), isBounded); }
Source:
<code>public static ModeInfo findMode(String mime, String path) { ModeInfo m = byMime.get(mime); if (m != null) { return m; } int s = path.lastIndexOf('/'); <START> int d = path.lastIndexOf('.'); <END> if (s > d) { return null; } if (byExt == null) { byExt = NativeMap.create(); for (ModeInfo mode : Natives.asList(all())) { for (String ext : Natives.asList(mode.ext())) { byExt.put(ext, mode); } } } return byExt.get(path.substring(d + 1)); }</code><technical_language>happen if d == -1? (E.g. if suffix entire basename in case this set 'd = s'.)</technical_language>

Target:
public static ModeInfo findMode(String mime, String path) { ModeInfo m = byMime.get(mime); if (m != null) { return m; } int s = path.lastIndexOf('/'); int d = path.lastIndexOf('.'); if (d == -1 || s > d) { return null; } if (byExt == null) { byExt = NativeMap.create(); for (ModeInfo mode : Natives.asList(all())) { for (String ext : Natives.asList(mode.ext())) { byExt.put(ext, mode); } } } return byExt.get(path.substring(d + 1)); }
Source:
<code>private void initializeMap() { mapView.setStyleUrl("asset://mapstyle.json"); mapView.setMyLocationTrackingMode(MyLocationTracking.TRACKING_NONE); mapView.setOnMyLocationChangeListener(new MapView.OnMyLocationChangeListener() { @Override public void onMyLocationChange(@Nullable Location location) { makeUseOfNewLocation(location); if (!firstLocationLock) { goToUserLocation(); firstLocationLock = true; } } }); mapView.setOnScrollListener(new MapView.OnScrollListener() { @Override public void onScroll() { fetchNearbyPages(); } }); mapView.setOnMarkerClickListener(new MapView.OnMarkerClickListener() { @Override public boolean onMarkerClick(@NonNull Marker marker) { <START> for (NearbyPage page : lastResult.getList()) { <END> if (page.getTitle().equals(marker.getTitle())) { PageTitle title = new PageTitle(page.getTitle(), site, page.getThumblUrl()); ((PageActivity) getActivity()).showLinkPreview(title, HistoryEntry.SOURCE_NEARBY); } } return true; } }); }</code><technical_language>I algorithm is "findMarker" "findMarkerByTitle". Consider methodizing this perfectly clear</technical_language>

Target:
private void initializeMap() { mapView.setStyleUrl("asset://mapstyle.json"); mapView.setMyLocationTrackingMode(MyLocationTracking.TRACKING_NONE); mapView.setOnMyLocationChangeListener(new MapView.OnMyLocationChangeListener() { @Override public void onMyLocationChange(@Nullable Location location) { makeUseOfNewLocation(location); if (!firstLocationLock) { goToUserLocation(); firstLocationLock = true; } } }); mapView.setOnScrollListener(new MapView.OnScrollListener() { @Override public void onScroll() { fetchNearbyPages(); } }); mapView.setOnMarkerClickListener(new MapView.OnMarkerClickListener() { @Override public boolean onMarkerClick(@NonNull Marker marker) { NearbyPage page = findNearbyPageFromMarker(marker); if (page != null) { PageTitle title = new PageTitle(page.getTitle(), site, page.getThumblUrl()); ((PageActivity) getActivity()).showLinkPreview(title, HistoryEntry.SOURCE_NEARBY); return true; } else { return false; } } }); }
Source:
<code>private double calculateVarianceOfCopyNeutralSegmentMeans(final List<ACNVModeledSegment> segments, final double meanBiasInCR) { Utils.nonNull(segments); final Variance varianceCalculator = new Variance(); return varianceCalculator.evaluate(segments.stream() <START> .filter(s -> Math.abs(s.getSegmentMeanInCRSpace() - 1 + meanBiasInCR) < 0.1) <END> .mapToDouble(s -> s.getSegmentMeanInCRSpace()).toArray()); }</code><technical_language>Do - (1 + meanBiasInCR)</technical_language>

Target:
private double calculateVarianceOfCopyNeutralSegmentMeans(final List<ACNVModeledSegment> segments, final double meanBiasInCR) { Utils.nonNull(segments); final double neutralCR = 1 + meanBiasInCR; final double[] neutralSegmentMeans = segments.stream() .mapToDouble(ACNVModeledSegment::getSegmentMeanInCRSpace) .filter(m -> Math.abs(m - neutralCR) < CLOSE_ENOUGH_TO_COPY_NEUTRAL_IN_CR).toArray(); return new Variance().evaluate(neutralSegmentMeans); }
Source:
<code>private String attachUserToSession(String authzName, ExtMap principalRecord) { DirectoryUtils.flatGroups(principalRecord); DbUser dbUser = DirectoryUtils.mapPrincipalRecordToDbUser(authzName, principalRecord); if (dbUser == null) { throw new RuntimeException("User not found in database"); <START> } <END> String engineSessionId; try { byte s[] = new byte[64]; SecureRandom.getInstance("SHA1PRNG").nextBytes(s); engineSessionId = new Base64(0).encodeToString(s); } catch (NoSuchAlgorithmException e) { throw new RuntimeException(e); } sessionDataContainer.setUser(engineSessionId, dbUser); sessionDataContainer.refresh(engineSessionId); sessionDataContainer.setPrincipalRecord(engineSessionId, principalRecord); return engineSessionId; }</code><technical_language>this is ok, for example group is SuperUser, user login if in database, id random uuid similar, care of in past</technical_language>

Target:
private String attachUserToSession(String authzName, ExtMap principalRecord) { DirectoryUtils.flatGroups(principalRecord); DbUser dbUser = new DbUser(DirectoryUtils.mapPrincipalRecordToDirectoryUser(authzName, principalRecord)); dbUser.setId(Guid.newGuid()); String engineSessionId; try { byte s[] = new byte[64]; SecureRandom.getInstance("SHA1PRNG").nextBytes(s); engineSessionId = new Base64(0).encodeToString(s); } catch (NoSuchAlgorithmException e) { throw new RuntimeException(e); } sessionDataContainer.setUser(engineSessionId, dbUser); sessionDataContainer.refresh(engineSessionId); sessionDataContainer.setPrincipalRecord(engineSessionId, principalRecord); return engineSessionId; }
Source:
<code>private Object[] mapExpandedElements(AbstractHistoryCategory[] categories, Object[] expandedElements) { HashSet<String> names = new HashSet<>(); for (Object expandedElement : expandedElements) { names.add(((DateHistoryCategory) expandedElement).getName()); } ArrayList<AbstractHistoryCategory> expandable = new ArrayList<>(); for (AbstractHistoryCategory <START> categorie : <END> categories) { if (names.contains(categorie.getName())) { expandable.add(categorie); } } return expandable.toArray(new Object[expandable.size()]); }</code><technical_language>category</technical_language>

Target:
private Object[] mapExpandedElements(AbstractHistoryCategory[] categories, Object[] expandedElements) { HashSet<String> names = new HashSet<>(); for (Object expandedElement : expandedElements) { names.add(((DateHistoryCategory) expandedElement).getName()); } ArrayList<AbstractHistoryCategory> expandable = new ArrayList<>(); for (AbstractHistoryCategory category : categories) { if (names.contains(category.getName())) { expandable.add(category); } } return expandable.toArray(new Object[expandable.size()]); }
Source:
<code>public GlueHiveMetastore(HdfsEnvironment hdfsEnvironment, GlueHiveMetastoreConfig glueConfig) { <START> this(hdfsEnvironment, glueConfig, new GlueClientFactory(glueConfig).newClient()); <END> }</code><technical_language>GlueClientFactory is here, is effectively a static method. move a static helper method in this class</technical_language>

Target:
public GlueHiveMetastore(HdfsEnvironment hdfsEnvironment, GlueHiveMetastoreConfig glueConfig) { this(hdfsEnvironment, glueConfig, createAsyncGlueClient(glueConfig)); }
Source:
<code>public static int enumToBinary(final CigarOperator e) { <START> return e.ordinal(); <END> }</code><technical_language>I is safe ordinal() for encoding decoding. means implicit decision (the order of enum definition, java converts enum class ordinals) affects cigar is encoded decoded. I is preferable written explicitly. @tfenne @lbergelson opinions</technical_language>

Target:
public static int enumToBinary(final CigarOperator e) { return e.bamEncoding; }
Source:
<code>public static BlobProperties buildBlobProperties(Map<String, Object> args) throws RestServiceException { Account account = getAccountFromArgs(args); Container container = getContainerFromArgs(args); String serviceId = getHeader(args, Headers.SERVICE_ID, true); String contentType = getHeader(args, Headers.AMBRY_CONTENT_TYPE, true); String ownerId = getHeader(args, Headers.OWNER_ID, false); long ttl = Utils.Infinite_Time; String ttlStr = getHeader(args, Headers.TTL, false); if (ttlStr != null) { try { ttl = Long.parseLong(ttlStr); if (ttl < -1) { throw new RestServiceException(Headers.TTL + "[" + ttl + "] is not valid (has to be >= -1)", RestServiceErrorCode.InvalidArgs); } } catch (NumberFormatException e) { throw new RestServiceException(Headers.TTL + "[" + ttlStr + "] could not parsed into a number", RestServiceErrorCode.InvalidArgs); } } boolean isPrivate = !container.isCacheable(); <START> return new BlobProperties(-1, serviceId, ownerId, contentType, isPrivate, ttl, account.getId(), <END> container.getId(), false); }</code><technical_language>container.isEncrypted() is passed in arg for constructing BlobProperties</technical_language>

Target:
public static BlobProperties buildBlobProperties(Map<String, Object> args) throws RestServiceException { Account account = getAccountFromArgs(args); Container container = getContainerFromArgs(args); String serviceId = getHeader(args, Headers.SERVICE_ID, true); String contentType = getHeader(args, Headers.AMBRY_CONTENT_TYPE, true); String ownerId = getHeader(args, Headers.OWNER_ID, false); long ttl = Utils.Infinite_Time; String ttlStr = getHeader(args, Headers.TTL, false); if (ttlStr != null) { try { ttl = Long.parseLong(ttlStr); if (ttl < -1) { throw new RestServiceException(Headers.TTL + "[" + ttl + "] is not valid (has to be >= -1)", RestServiceErrorCode.InvalidArgs); } } catch (NumberFormatException e) { throw new RestServiceException(Headers.TTL + "[" + ttlStr + "] could not parsed into a number", RestServiceErrorCode.InvalidArgs); } } boolean isPrivate = !container.isCacheable(); return new BlobProperties(-1, serviceId, ownerId, contentType, isPrivate, ttl, account.getId(), container.getId(), container.isEncrypted()); }
Source:
<code>public void testJWTIssuedAtFuture() throws Exception { String url = getContextBaseUrl() + "/users"; <START> NumericDate tokenIssuedAtNumericDate = NumericDate.now(); <END> tokenIssuedAtNumericDate.addSeconds(300); String token = securityTokenProvider.getToken("admin", Collections.emptyMap(), 10, tokenIssuedAtNumericDate); given().header(HttpHeaders.AUTHORIZATION, getAuthorizationHeader(token)) .header(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON_VALUE) .when() .get(url) .then() .statusCode(HttpStatus.UNAUTHORIZED.value()) .body("error", equalTo("invalid.token")); }</code><technical_language>Cosmetic: please rename this futureNumericDate</technical_language>

Target:
public void testJWTIssuedAtFuture() throws Exception { String url = getContextBaseUrl() + "/users"; NumericDate futureNumericDate = NumericDate.now(); futureNumericDate.addSeconds(300); String token = securityTokenProvider.getToken("admin", Collections.emptyMap(), 10, futureNumericDate); given().header(HttpHeaders.AUTHORIZATION, getAuthorizationHeader(token)) .header(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON_VALUE) .when() .get(url) .then() .statusCode(HttpStatus.UNAUTHORIZED.value()) .body("error", equalTo("invalid.token")); }
Source:
<code>public AbandonChangeDialog(final PatchSet.Id psi, <START> final AsyncCallback<?> callback) { <END> super(false, true); psid = psi; appCallback = callback; addStyleName("gerrit-AbandonChangeDialog"); panel = new VerticalPanel(); add(panel); panel.add(new SmallHeading(Util.C.headingAbandonMessage())); final VerticalPanel mwrap = new VerticalPanel(); mwrap.setStyleName("gerrit-AbandonMessage"); panel.add(mwrap); message = new TextArea(); message.setCharacterWidth(60); message.setVisibleLines(10); DOM.setElementPropertyBoolean(message.getElement(), "spellcheck", true); mwrap.add(message); final FlowPanel buttonPanel = new FlowPanel(); buttonPanel.setStyleName("gerrit-CommentEditor-Buttons"); panel.add(buttonPanel); sendButton = new Button(Util.C.buttonAbandonChangeSend()); sendButton.addClickListener(new ClickListener() { public void onClick(Widget sender) { sendButton.setEnabled(false); PatchUtil.DETAIL_SVC.abandonChange(message.getText().trim(), psid, new GerritCallback<VoidResult>() { public void onSuccess(VoidResult result) { if (appCallback != null) { appCallback.onSuccess(null); } hide(); } @Override public void onFailure(Throwable caught) { sendButton.setEnabled(true); super.onFailure(caught); } }); } }); buttonPanel.add(sendButton); cancelButton = new Button(Util.C.buttonAbandonChangeCancel()); cancelButton.addClickListener(new ClickListener() { public void onClick(Widget sender) { if (appCallback != null) { appCallback.onFailure(null); } hide(); } }); buttonPanel.add(cancelButton); }</code><technical_language>in constructor is fine</technical_language>

Target:
public AbandonChangeDialog(final PatchSet.Id psi, final AsyncCallback<?> callback) { super(false, true); psid = psi; appCallback = callback; addStyleName("gerrit-AbandonChangeDialog"); panel = new FlowPanel(); add(panel); panel.add(new SmallHeading(Util.C.headingAbandonMessage())); final FlowPanel mwrap = new FlowPanel(); mwrap.setStyleName("gerrit-AbandonMessage"); panel.add(mwrap); message = new TextArea(); message.setCharacterWidth(60); message.setVisibleLines(10); DOM.setElementPropertyBoolean(message.getElement(), "spellcheck", true); mwrap.add(message); final FlowPanel buttonPanel = new FlowPanel(); buttonPanel.setStyleName("gerrit-CommentEditor-Buttons"); panel.add(buttonPanel); sendButton = new Button(Util.C.buttonAbandonChangeSend()); sendButton.addClickListener(new ClickListener() { public void onClick(Widget sender) { sendButton.setEnabled(false); PatchUtil.DETAIL_SVC.abandonChange(psid, message.getText().trim(), new GerritCallback<VoidResult>() { public void onSuccess(VoidResult result) { if (appCallback != null) { appCallback.onSuccess(null); } hide(); } @Override public void onFailure(Throwable caught) { sendButton.setEnabled(true); super.onFailure(caught); } }); } }); buttonPanel.add(sendButton); cancelButton = new Button(Util.C.buttonAbandonChangeCancel()); cancelButton.addClickListener(new ClickListener() { public void onClick(Widget sender) { hide(); } }); buttonPanel.add(cancelButton); }
Source:
<code>protected void onPostExecute(Integer[] result){ <START> System.out.println("onPostExecute"); <END> if(result[0] == SUCCESS) { Toast.makeText(EncryptedSharedHealthRecordSyncTask.context, "Uploaded " + result[1] +" SHR Data items", Toast.LENGTH_SHORT).show(); } else { Toast.makeText(EncryptedSharedHealthRecordSyncTask.context, "Error Uploading SHR Data. Uploaded " + result[1] + ", Failed " + result[2], Toast.LENGTH_SHORT).show(); } syncInProgress = false; }</code><technical_language>Logging standard output</technical_language>

Target:
protected void onPostExecute(Integer[] result){ if(result[0] == SUCCESS) { Toast.makeText(EncryptedSharedHealthRecordSyncTask.context, "Uploaded " + result[1] +" SHR Data items", Toast.LENGTH_SHORT).show(); } else { Toast.makeText(EncryptedSharedHealthRecordSyncTask.context, "Error Uploading SHR Data. Uploaded " + result[1] + ", Failed " + result[2], Toast.LENGTH_SHORT).show(); } syncInProgress = false; }
Source:
<code>public String getRoomCode(String displayName) { <START> UI.doubleClick(driver.findElement(By.xpath(" END> return roomCodeTxtBox.getAttribute("value"); }</code><technical_language>please apply java conventions (spaces +) total amount of characters line</technical_language>

Target:
public String getRoomCode(String displayName) { UI.doubleClick(driver.findElement(By.xpath(" + displayName + "')and@class='ng-binding']"))); return roomCodeTxtBox.getAttribute("value"); }
Source:
<code>public boolean canEdit(Context context, Item item) throws SQLException { if (authorizeService.authorizeActionBoolean(context, item, Constants.WRITE)) { return true; } if (item.getOwningCollection() == null) { <START> if (!isAnInprogressSubmission(context, item)) { <END> return true; } else { return false; } } return collectionService.canEditBoolean(context, item.getOwningCollection(), false); }</code><technical_language>'return !isAnInprogressSubmission(context, item);'</technical_language>

Target:
public boolean canEdit(Context context, Item item) throws SQLException { if (authorizeService.authorizeActionBoolean(context, item, Constants.WRITE)) { return true; } if (item.getOwningCollection() == null) { if (!isInProgressSubmission(context, item)) { return true; } else { return false; } } return collectionService.canEditBoolean(context, item.getOwningCollection(), false); }
Source:
<code>public byte[] getFirmwareImage(final String firmwareIdentification) throws FirmwareImageFactoryException { try { URL downloadUrl = new URL(this.url + firmwareIdentification); this.checkUrl(downloadUrl); return this.download(downloadUrl); } catch (final MalformedURLException e) { <START> throw new FirmwareImageFactoryException(EXCEPTION_MSG_MALFORMED_URL + this.url + firmwareIdentification); <END> } catch (final IOException e) { throw new FirmwareImageFactoryException(EXCEPTION_MSG_FIRMWARE_NOT_RETRIEVED, e); } }</code><technical_language>include MalformedURLException cause</technical_language>

Target:
public byte[] getFirmwareImage(final String firmwareIdentification) throws FirmwareImageFactoryException { try { URL downloadUrl = new URL(this.url + firmwareIdentification); this.checkUrl(downloadUrl); return this.download(downloadUrl); } catch (final MalformedURLException e) { throw new FirmwareImageFactoryException(EXCEPTION_MSG_MALFORMED_URL + this.url + firmwareIdentification, e); } catch (final IOException e) { throw new FirmwareImageFactoryException(EXCEPTION_MSG_FIRMWARE_NOT_RETRIEVED, e); } }
Source:
<code>protected EMFModelElement doCreateFromSource(Object sourceElement, DataContextElement context) { final EObject source = EMFHelper.getEObject(sourceElement); if (null == source) { Activator.log.warn("Unable to resolve the selected element to a Table"); return null; } final IMatrixTableWidgetManager manager = MatrixHelper.getMatrixTableWidgetModelManagerFromCurrentEditor(); if(null != <START> manager) { <END> final TransactionalEditingDomain domain = TableEditingDomainUtils.getTableEditingDomain(manager.getTable()); if (null != manager && null != domain) { return new GenericUMLRelationshipMatrixModelElement(manager, domain); } } return super.doCreateFromSource(sourceElement, context); }</code><technical_language>committed</technical_language>

Target:
protected EMFModelElement doCreateFromSource(Object sourceElement, DataContextElement context) { final EObject source = EMFHelper.getEObject(sourceElement); if (null == source) { Activator.log.warn("Unable to resolve the selected element to a Table"); return null; } final IMatrixTableWidgetManager manager = MatrixHelper.getMatrixTableWidgetModelManagerFromCurrentEditor(); if (null != manager) { final TransactionalEditingDomain domain = TableEditingDomainUtils.getTableEditingDomain(manager.getTable()); if (null != domain) { return new GenericUMLRelationshipMatrixModelElement(manager, domain); } } return super.doCreateFromSource(sourceElement, context); }
Source:
<code>public void testServiceLoader() throws Exception { CompoundJdbcEventListener compoundJdbcEventListener = (CompoundJdbcEventListener) P6Core.getJdbcEventListener(); final List<JdbcEventListener> eventListeners = compoundJdbcEventListener.getEventListeners(); assertTrue(containsClass(TestJdbcEventListener.class, eventListeners)); assertFalse(containsClass(JdbcEventListener.class, eventListeners)); assertTrue(containsClass(TestLoggingEventListener.class, eventListeners)); <START> assertFalse(containsClass(LoggingEventListener.class, eventListeners)); <END> }</code><technical_language>this check important compatible, I guess. chance for calling ConnectionWrapper.wrapConnection() (as do in production code) checking instanceof returned object</technical_language>

Target:
public void testServiceLoader() throws Exception { JdbcEventListener eventListener = P6Core.getJdbcEventListener(); assertTrue(eventListener instanceof CompoundJdbcEventListener); CompoundJdbcEventListener compoundJdbcEventListener = (CompoundJdbcEventListener) eventListener; final List<JdbcEventListener> eventListeners = compoundJdbcEventListener.getEventListeners(); assertTrue(containsClass(TestJdbcEventListener.class, eventListeners)); assertFalse(containsClass(JdbcEventListener.class, eventListeners)); assertTrue(containsClass(TestLoggingEventListener.class, eventListeners)); assertFalse(containsClass(LoggingEventListener.class, eventListeners)); }