auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>private static ResolvedType objectTypeArgumentToType(SignatureAttribute.ObjectType typeArgument, TypeSolver typeSolver, ResolvedTypeParametrizable typeParametrizable) { <START> if(typeArgument instanceof SignatureAttribute.ArrayType){ <END> String baseTypeName = ((SignatureAttribute.ArrayType) typeArgument).getComponentType().jvmTypeName(); ResolvedType baseType = getGenericParameterByName(baseTypeName, typeParametrizable, typeSolver); return new ResolvedArrayType(baseType); } else { String typeName = typeArgument.jvmTypeName(); return getGenericParameterByName(typeName, typeParametrizable, typeSolver); } }</code><technical_language>reuse <LINK_0></technical_language>

Target:
private static ResolvedType objectTypeArgumentToType(SignatureAttribute.ObjectType typeArgument, TypeSolver typeSolver, ResolvedTypeParametrizable typeParametrizable) { if(typeArgument instanceof SignatureAttribute.ArrayType){ return signatureTypeToType(((SignatureAttribute.ArrayType) typeArgument).getComponentType(), typeSolver, typeParametrizable); } else { String typeName = typeArgument.jvmTypeName(); return getGenericParameterByName(typeName, typeParametrizable, typeSolver); } }
Source:
<code>private void initMocks() throws JWTClientException, RemoteException { mockEventProcessorAdminServiceStub = Mockito.mock(EventProcessorAdminServiceStub.class); geoLocationProviderServiceImpl = Mockito.mock(GeoLocationProviderServiceImpl.class, Mockito.CALLS_REAL_METHODS); <START> doReturn(mockEventProcessorAdminServiceStub).when(geoLocationProviderServiceImpl).getEventProcessorAdminServiceStub(); <END> doReturn("success").when(mockEventProcessorAdminServiceStub).validateExecutionPlan(Mockito.anyString()); }</code><technical_language>more 120 characters long</technical_language>

Target:
private void initMocks() throws JWTClientException, RemoteException { mockEventProcessorAdminServiceStub = Mockito.mock(EventProcessorAdminServiceStub.class); geoLocationProviderServiceImpl = Mockito.mock(GeoLocationProviderServiceImpl.class, Mockito.CALLS_REAL_METHODS); Mockito.doReturn(mockEventProcessorAdminServiceStub). when(geoLocationProviderServiceImpl).getEventProcessorAdminServiceStub(); Mockito.doReturn("success"). when(mockEventProcessorAdminServiceStub).validateExecutionPlan(Mockito.anyString()); }
Source:
<code>Set<Watcher> triggerWatch(String path, EventType type, Set<Watcher> supress) { WatchedEvent e = new WatchedEvent(type, KeeperState.SyncConnected, path); Set<Watcher> watchers = new HashSet<>(); PathIterator pathIterator = new PathIterator(path); synchronized (this) { <START> while (pathIterator.hasNext()) { <END> String localPath = pathIterator.next(); Map<Watcher, Type> thisWatchers = watchTable.get(localPath); if (thisWatchers == null || thisWatchers.isEmpty()) { continue; } Iterator<Entry<Watcher, Type>> iterator = thisWatchers.entrySet().iterator(); while (iterator.hasNext()) { Entry<Watcher, Type> entry = iterator.next(); Type entryType = entry.getValue(); Watcher watcher = entry.getKey(); if (entryType == Type.PERSISTENT) { watchers.add(watcher); } else if (!pathIterator.atParentPath()) { watchers.add(watcher); iterator.remove(); Set<String> paths = watch2Paths.get(watcher); if (paths != null) { paths.remove(localPath); } } } if (thisWatchers.size() == 0) { watchTable.remove(localPath); } } } if (watchers.size() == 0) { if (LOG.isTraceEnabled()) { ZooTrace.logTraceMessage(LOG, ZooTrace.EVENT_DELIVERY_TRACE_MASK, "No watchers for " + path ); } return null; } for (Watcher w : watchers) { if (supress != null && supress.contains(w)) { continue; } w.process(e); } return watchers; }</code><technical_language>here, if pathIterator implements Iterable Iterator use: for (String localPath : pathIterator) { (...) }</technical_language>

Target:
Set<Watcher> triggerWatch(String path, EventType type, Set<Watcher> supress) { WatchedEvent e = new WatchedEvent(type, KeeperState.SyncConnected, path); Set<Watcher> watchers = new HashSet<>(); synchronized (this) { PathParentIterator pathParentIterator = getPathParentIterator(path); for (String localPath : pathParentIterator.asIterable()) { Map<Watcher, Type> thisWatchers = watchTable.get(localPath); if (thisWatchers == null || thisWatchers.isEmpty()) { continue; } Iterator<Entry<Watcher, Type>> iterator = thisWatchers.entrySet().iterator(); while (iterator.hasNext()) { Entry<Watcher, Type> entry = iterator.next(); Type entryType = entry.getValue(); Watcher watcher = entry.getKey(); if (entryType.isRecursive()) { if ( type != EventType.NodeChildrenChanged ) { watchers.add(watcher); } } else if (!pathParentIterator.atParentPath()) { watchers.add(watcher); if (!entryType.isPersistent()) { iterator.remove(); Set<String> paths = watch2Paths.get(watcher); if (paths != null) { paths.remove(localPath); } } } } if (thisWatchers.isEmpty()) { watchTable.remove(localPath); } } } if (watchers.isEmpty()) { if (LOG.isTraceEnabled()) { ZooTrace.logTraceMessage(LOG, ZooTrace.EVENT_DELIVERY_TRACE_MASK, "No watchers for " + path ); } return null; } for (Watcher w : watchers) { if (supress != null && supress.contains(w)) { continue; } w.process(e); } return watchers; }
Source:
<code>public CameraNode(NodeChannel channel, int period) { super(new BuggyBaseNode(channel), period, "Camera_Node"); statePub = new Publisher(channel.getStatePath()); List<Webcam> webcams; try { webcams = Webcam.getWebcams(); <START> } catch (Exception e) { END> e.printStackTrace(); new RobobuggyLogicNotification("Couldn't load webcams!", RobobuggyMessageLevel.EXCEPTION); statePub.publish(new StateMessage(NodeState.ERROR)); return; } for (Webcam webcam : webcams) { if (webcam.getName().contains("Logitech")) { this.webcam = webcam; this.webcam.setViewSize(WebcamResolution.QVGA.getSize()); this.webcam.open(); break; } } if (this.webcam == null) { new RobobuggyLogicNotification("Couldn't find Logitech webcam!", RobobuggyMessageLevel.EXCEPTION); this.webcam = Webcam.getDefault(); Webcam webcam = Webcam.getDefault(); webcam.setCustomViewSizes(new Dimension[] { WebcamResolution.QVGA.getSize(), WebcamResolution.HD720.getSize() }); webcam.setViewSize(WebcamResolution.QVGA.getSize()); } imagePublisher = new Publisher(channel.getMsgPath()); setupLoggingTrigger(); resume(); }</code><technical_language>of this in repo please (yes I I committed for sake of review)</technical_language>

Target:
public CameraNode(NodeChannel channel, int period) { super(new BuggyBaseNode(channel), period, "Camera_Node"); statePub = new Publisher(channel.getStatePath()); List<Webcam> webcams; try { webcams = Webcam.getWebcams(); } catch (WebcamException e) { e.printStackTrace(); new RobobuggyLogicNotification("Couldn't load webcams!", RobobuggyMessageLevel.EXCEPTION); statePub.publish(new StateMessage(NodeState.ERROR)); return; } for (Webcam webcam : webcams) { if (webcam.getName().contains("Logitech")) { this.webcam = webcam; this.webcam.setViewSize(WebcamResolution.QVGA.getSize()); this.webcam.open(); break; } } if (this.webcam == null) { new RobobuggyLogicNotification("Couldn't find Logitech webcam!", RobobuggyMessageLevel.EXCEPTION); this.webcam = Webcam.getDefault(); Webcam webcam = Webcam.getDefault(); webcam.setCustomViewSizes(new Dimension[] { WebcamResolution.QVGA.getSize(), WebcamResolution.HD720.getSize() }); webcam.setViewSize(WebcamResolution.QVGA.getSize()); } imagePublisher = new Publisher(channel.getMsgPath()); setupLoggingTrigger(); resume(); }
Source:
<code>private String getTokenFromHeader(HttpServletRequest request) { String token = null; String headerValue = request.getHeader(SsoConstants.HEADER_AUTHORIZATION); if (headerValue != null && headerValue.startsWith(BEARER)) { token = <START> headerValue.substring("Bearer".length()).trim(); <END> } return token; }</code><technical_language>s/"Bearer"/BEARER</technical_language>

Target:
private String getTokenFromHeader(HttpServletRequest request) { String token = null; String headerValue = request.getHeader(SsoConstants.HEADER_AUTHORIZATION); if (headerValue != null && headerValue.startsWith(BEARER)) { token = headerValue.substring(BEARER.length()).trim(); } return token; }
Source:
<code>public void run(String[] args) throws IOException { CmdLineParser parser = new CmdLineParser(this); parser.setUsageWidth(80); try { parser.parseArgument(args); } catch (CmdLineException e) { System.err.println(VERSION); System.err.println(e.getMessage()); System.err.println("java Fastq_liftOver [options...] arguments..."); parser.printUsage(System.err); System.err.println(); return; } long tStart = System.currentTimeMillis(); MapBlocks mapBlocks = new MapBlocks(mapFile); if (fastqType.equals("dwgsim")) { <START> final File outFile = (outFiles != null && outFiles.size() == 1) ? outFiles.get(0) : null; END> log.info("fastqFiles " + fastqFiles.get(0).getName() + " " + fastqFiles.get(1).getName()); doLiftOverDwgsimFastqMap(mapBlocks, getOutStream(outFiles.get(0), compress), getOutStream(outFiles.get(1), compress)); } if (fastqType.equals("art")) { log.info("fastqFiles " + fastqFiles.get(0).getName() + " " + fastqFiles.get(1).getName()); log.info("alnFiles " + alnFiles.get(0).getName() + " " + alnFiles.get(1).getName()); log.info("outFiles " + outFiles.get(0).getName() + " " + outFiles.get(1).getName()); doLiftOverArtFastqMap(mapBlocks, getOutStream(outFiles.get(0), compress), getOutStream(outFiles.get(1), compress)); } log.info("Conversion took " + (System.currentTimeMillis() - tStart) / 1e3 + " seconds."); }</code><technical_language>Remove it. some point I forgot remove code restructuring</technical_language>

Target:
public void run(String[] args) throws IOException { CmdLineParser parser = new CmdLineParser(this); parser.setUsageWidth(80); try { parser.parseArgument(args); } catch (CmdLineException e) { System.err.println(VERSION); System.err.println(e.getMessage()); System.err.println("java Fastq_liftOver [options...] arguments..."); parser.printUsage(System.err); System.err.println(); return; } long tStart = System.currentTimeMillis(); MapBlocks mapBlocks = new MapBlocks(mapFile); if (fastqType.equals("dwgsim")) { log.info("fastqFiles " + fastqFiles.get(0).getName() + " " + fastqFiles.get(1).getName()); doLiftOverDwgsimFastqMap(mapBlocks, getOutStream(outFiles.get(0), compress), getOutStream(outFiles.get(1), compress)); } if (fastqType.equals("art")) { log.info("fastqFiles " + fastqFiles.get(0).getName() + " " + fastqFiles.get(1).getName()); log.info("alnFiles " + alnFiles.get(0).getName() + " " + alnFiles.get(1).getName()); log.info("outFiles " + outFiles.get(0).getName() + " " + outFiles.get(1).getName()); doLiftOverArtFastqMap(mapBlocks, getOutStream(outFiles.get(0), compress), getOutStream(outFiles.get(1), compress)); } log.info("Conversion took " + (System.currentTimeMillis() - tStart) / 1e3 + " seconds."); }
Source:
<code>public void deleteWithId() throws Exception { dao.deleteAccount(ACCOUNT_ID_WITH_ID); <START> verify(mockHibernateHelper).deleteById(HibernateAccount.class, ACCOUNT_ID); <END> }</code><technical_language>Is worth adding a check *don't* re-query Hibernate for account</technical_language>

Target:
public void deleteWithId() throws Exception { dao.deleteAccount(ACCOUNT_ID_WITH_ID); verify(mockHibernateHelper).deleteById(HibernateAccount.class, ACCOUNT_ID); verify(mockHibernateHelper, never()).queryGet(any(), any(), any(), any()); }
Source:
<code><START> public final void doInit() { <END> if (this.selector instanceof AbstractMessageProcessingSelector) { ((AbstractMessageProcessingSelector) this.selector).setConversionService(this.getConversionService()); } if (this.selector instanceof BeanFactoryAware) { ((BeanFactoryAware) this.selector).setBeanFactory(this.getBeanFactory()); } }</code><technical_language>is public final</technical_language>

Target:
protected void doInit() { if (this.selector instanceof AbstractMessageProcessingSelector) { ((AbstractMessageProcessingSelector) this.selector).setConversionService(this.getConversionService()); } if (this.selector instanceof BeanFactoryAware) { ((BeanFactoryAware) this.selector).setBeanFactory(this.getBeanFactory()); } }
Source:
<code>public void refreshAllElementsVisibility(final DDiagram diagram) { deactivateCache(); activateCache(); Session session = SessionManager.INSTANCE.getSession(((DSemanticDiagram) diagram).getTarget()); DiagramMappingsManager mappingManager = DiagramMappingsManagerRegistry.INSTANCE.getDiagramMappingsManager(session, diagram); NotificationUtil.sendNotification(diagram, Notification.Kind.START, Notification.REFRESH_VISIBILITY_ON_DIAGRAM); DslCommonPlugin.PROFILER.startWork(SiriusTasksKey.IS_VISIBLE_KEY); for (final DDiagramElement diagramElement : diagram.getDiagramElements()) { boolean visibility = <START> computeVisibility(mappingManager, diagram, diagramElement); <END> if (visibility != diagramElement.isVisible()) { diagramElement.setVisible(computeVisibility(mappingManager, diagram, diagramElement)); } } DslCommonPlugin.PROFILER.stopWork(SiriusTasksKey.IS_VISIBLE_KEY); NotificationUtil.sendNotification(diagram, Notification.Kind.STOP, Notification.REFRESH_VISIBILITY_ON_DIAGRAM); deactivateCache(); }</code><technical_language>computeVisibility() free. effect of avoiding a notification is worth it</technical_language>

Target:
public void refreshAllElementsVisibility(final DDiagram diagram) { deactivateCache(); activateCache(); Session session = SessionManager.INSTANCE.getSession(((DSemanticDiagram) diagram).getTarget()); DiagramMappingsManager mappingManager = DiagramMappingsManagerRegistry.INSTANCE.getDiagramMappingsManager(session, diagram); NotificationUtil.sendNotification(diagram, Notification.Kind.START, Notification.REFRESH_VISIBILITY_ON_DIAGRAM); DslCommonPlugin.PROFILER.startWork(SiriusTasksKey.IS_VISIBLE_KEY); for (final DDiagramElement diagramElement : diagram.getDiagramElements()) { boolean visibility = computeVisibility(mappingManager, diagram, diagramElement); if (visibility != diagramElement.isVisible()) { diagramElement.setVisible(visibility); } } DslCommonPlugin.PROFILER.stopWork(SiriusTasksKey.IS_VISIBLE_KEY); NotificationUtil.sendNotification(diagram, Notification.Kind.STOP, Notification.REFRESH_VISIBILITY_ON_DIAGRAM); deactivateCache(); }
Source:
<code>private <T> T executeToJsonObjectWithRetry(final HttpConnection connection, Class<T> c) throws CouchException { InputStream is = this.executeToInputStreamWithRetry(connection); InputStreamReader isr = new InputStreamReader(is); try { T json = new JSONHelper().fromJson(isr, c); return json; } finally { <START> try { <END> is.close(); } catch (Exception e) { ; } } }</code><technical_language>IOUtils.close()</technical_language>

Target:
private <T> T executeToJsonObjectWithRetry(final HttpConnection connection, Class<T> c) throws CouchException { InputStream is = this.executeToInputStreamWithRetry(connection); InputStreamReader isr = new InputStreamReader(is); try { T json = new JSONHelper().fromJson(isr, c); return json; } finally { IOUtils.closeQuietly(is); } }
Source:
<code>public void normalClearFromDataStoreWithWriterOnDataStore() { configureServers(true, true); client1.invoke(this::initClientCache); client2.invoke(this::initClientCache); accessor.invoke(() -> feed(false)); verifyServerRegionSize(NUM_ENTRIES); dataStore3.invoke(() -> getRegion(false).clear()); verifyServerRegionSize(0); verifyCacheListenerTriggerCount(dataStore3); assertThat(dataStore1.invoke(getWriterClears)).isEqualTo(0); assertThat(dataStore2.invoke(getWriterClears)).isEqualTo(0); assertThat(dataStore3.invoke(getWriterClears)).isEqualTo(1); assertThat(accessor.invoke(getWriterClears)).isEqualTo(0); dataStore3.invoke(() -> { Region region = getRegion(false); <START> region.destroyRegion(); <END> }); assertThat(dataStore1.invoke(getWriterDestroys)).isEqualTo(0); assertThat(dataStore2.invoke(getWriterDestroys)).isEqualTo(0); assertThat(dataStore3.invoke(getWriterDestroys)).isEqualTo(1); assertThat(accessor.invoke(getWriterDestroys)).isEqualTo(0); }</code><technical_language>test is region destroy name suggests is for clear. tests region destroy, clear</technical_language>

Target:
public void normalClearFromDataStoreWithWriterOnDataStore() { configureServers(true, true); client1.invoke(this::initClientCache); client2.invoke(this::initClientCache); accessor.invoke(() -> feed(false)); verifyServerRegionSize(NUM_ENTRIES); dataStore3.invoke(() -> getRegion(false).clear()); verifyServerRegionSize(0); dataStore3.invoke(() -> { Region region = getRegion(false); region.destroyRegion(); }); assertThat(dataStore1.invoke(getWriterDestroys)).isEqualTo(dataStore1.invoke(getWriterClears)) .isEqualTo(0); assertThat(dataStore2.invoke(getWriterDestroys)).isEqualTo(dataStore2.invoke(getWriterClears)) .isEqualTo(0); assertThat(dataStore3.invoke(getWriterDestroys)).isEqualTo(dataStore3.invoke(getWriterClears)) .isEqualTo(1); assertThat(accessor.invoke(getWriterDestroys)).isEqualTo(accessor.invoke(getWriterClears)) .isEqualTo(0); }
Source:
<code>public static CodeBlock join(Iterable<CodeBlock> codeBlocks, String separator) { Collection<CodeBlock> collection; if (codeBlocks instanceof Collection) { collection = (Collection<CodeBlock>) codeBlocks; } else { collection = new ArrayList<>(); <START> codeBlocks.forEach(collection::add); <END> } return collection.stream().collect(joining(separator)); }</code><technical_language>StreamSupport.stream(codeBlocks.spliterator(), false) create a stream iterable instead of making a copy</technical_language>

Target:
public static CodeBlock join(Iterable<CodeBlock> codeBlocks, String separator) { return StreamSupport.stream(codeBlocks.spliterator(), false).collect(joining(separator)); }
Source:
<code>public Image getBaseImage(DirectoryItems imageDirectory) { String category = (Crew.ROOT_PORTRAIT.equals(getCategory())) ? "" : getCategory(); String filename = getFileName(); if ((category == null) || (filename == null) || Crew.PORTRAIT_NONE.equals(filename)) { <START> filename = "default.gif"; <END> } Image portrait = null; try { portrait = (Image) imageDirectory.getItem(category, filename); if (portrait == null) { portrait = (Image) imageDirectory.getItem("", "default.gif"); } } catch (Exception e) { MegaMek.getLogger().error(getClass(), "setPortrait", e); } return portrait; }</code><technical_language>Good candidate for a constant/static of sorts</technical_language>

Target:
public Image getBaseImage(DirectoryItems imageDirectory) { String category = (Crew.ROOT_PORTRAIT.equals(getCategory())) ? "" : getCategory(); String filename = getFileName(); if ((category == null) || (filename == null) || Crew.PORTRAIT_NONE.equals(filename)) { filename = DEFAULT_PORTRAIT_FILENAME; } Image portrait = null; try { portrait = (Image) imageDirectory.getItem(category, filename); if (portrait == null) { portrait = (Image) imageDirectory.getItem("", DEFAULT_PORTRAIT_FILENAME); } } catch (Exception e) { MegaMek.getLogger().error(getClass(), "setPortrait", e); } return portrait; }
Source:
<code>private static Stream<StructuralElement> treeStream(StructuralElement tree) { return Stream.concat(Stream.of(tree), tree instanceof IncludedStructuralElement <START> ? ((IncludedStructuralElement) tree).getChildren().stream().flatMap(child -> treeStream(child)) <END> : Stream.empty()); }</code><technical_language>please replace lambda method reference</technical_language>

Target:
private static Stream<StructuralElement> treeStream(StructuralElement tree) { List<StructuralElement> result = new ArrayList<>(); result.add(tree); if (tree instanceof IncludedStructuralElement) { for (StructuralElement child : ((IncludedStructuralElement) tree).getChildren()) { result.addAll(treeStream(child).collect(Collectors.toList())); } } return result.stream(); }
Source:
<code>void shutdown() { LOG.info("Shutting down BookieNettyServer"); isRunning.set(false); allChannels.close().awaitUninterruptibly(); if (eventLoopGroup != null) { eventLoopGroup.shutdownGracefully(); } if (jvmEventLoopGroup != null) { jvmEventLoopGroup.shutdownGracefully(); <START> LocalBookiesRegistry.registerLocalBookieAddress(bookieAddress); <END> } authProviderFactory.close(); }</code><technical_language>Shoudn't this unregister? a I expect want unregister shutdown afterwards</technical_language>

Target:
void shutdown() { LOG.info("Shutting down BookieNettyServer"); isRunning.set(false); allChannels.close().awaitUninterruptibly(); if (eventLoopGroup != null) { eventLoopGroup.shutdownGracefully(); } if (jvmEventLoopGroup != null) { LocalBookiesRegistry.unregisterLocalBookieAddress(bookieAddress); jvmEventLoopGroup.shutdownGracefully(); } authProviderFactory.close(); }
Source:
<code>protected StreamTask( Environment environment, @Nullable TimerService timerService, Thread.UncaughtExceptionHandler uncaughtExceptionHandler, StreamTaskActionExecutor actionExecutor, TaskMailbox mailbox) throws Exception { super(environment); this.configuration = new StreamConfig(getTaskConfiguration()); this.recordWriter = createRecordWriterDelegate(configuration, environment); this.actionExecutor = Preconditions.checkNotNull(actionExecutor); this.mailboxProcessor = new MailboxProcessor(this::processInput, mailbox, actionExecutor); this.asyncExceptionHandler = new StreamTaskAsyncExceptionHandler(environment); this.asyncOperationsThreadPool = Executors.newCachedThreadPool( new ExecutorThreadFactory("AsyncOperations", uncaughtExceptionHandler)); this.stateBackend = createStateBackend(); this.subtaskCheckpointCoordinator = new SubtaskCheckpointCoordinatorImpl( stateBackend.createCheckpointStorage(getEnvironment().getJobID()), <START> getName(), <END> getCancelables(), getAsyncOperationsThreadPool(), getEnvironment(), this); if (timerService == null) { ThreadFactory timerThreadFactory = new DispatcherThreadFactory(TRIGGER_THREAD_GROUP, "Time Trigger for " + getName()); this.timerService = new SystemProcessingTimeService(this::handleTimerException, timerThreadFactory); } else { this.timerService = timerService; } }</code><technical_language>nit: get environment argument instead of getEnvironment(), for getAsyncOperationsThreadPool()</technical_language>

Target:
protected StreamTask( Environment environment, @Nullable TimerService timerService, Thread.UncaughtExceptionHandler uncaughtExceptionHandler, StreamTaskActionExecutor actionExecutor, TaskMailbox mailbox) throws Exception { super(environment); this.configuration = new StreamConfig(getTaskConfiguration()); this.recordWriter = createRecordWriterDelegate(configuration, environment); this.actionExecutor = Preconditions.checkNotNull(actionExecutor); this.mailboxProcessor = new MailboxProcessor(this::processInput, mailbox, actionExecutor); this.asyncExceptionHandler = new StreamTaskAsyncExceptionHandler(environment); this.asyncOperationsThreadPool = Executors.newCachedThreadPool( new ExecutorThreadFactory("AsyncOperations", uncaughtExceptionHandler)); this.stateBackend = createStateBackend(); this.subtaskCheckpointCoordinator = new SubtaskCheckpointCoordinatorImpl( stateBackend.createCheckpointStorage(getEnvironment().getJobID()), getName(), actionExecutor, getCancelables(), getAsyncOperationsThreadPool(), getEnvironment(), this, false); if (timerService == null) { ThreadFactory timerThreadFactory = new DispatcherThreadFactory(TRIGGER_THREAD_GROUP, "Time Trigger for " + getName()); this.timerService = new SystemProcessingTimeService(this::handleTimerException, timerThreadFactory); } else { this.timerService = timerService; } }
Source:
<code>public ImageTicketInformation getTicket(Guid ticketUUID) { BasicHttpRequest request = new BasicHttpRequest( "GET", TICKETS_URI + ticketUUID, HttpVersion.HTTP_1_1); <START> String responseContent; <END> try (DefaultBHttpClientConnection conn = getConnection()) { HttpEntity response = executeRequest(request, conn); BufferedReader reader = new BufferedReader(new InputStreamReader(response.getContent())); responseContent = reader.lines().collect(Collectors.joining()); consumeResponse(response); } catch (IOException e) { throw new RuntimeException(e.getMessage(), e); } return ImageTicketInformationHelper.fromJson(responseContent); }</code><technical_language>move try block</technical_language>

Target:
public ImageTicketInformation getTicket(Guid ticketUUID) { BasicHttpRequest request = new BasicHttpRequest( "GET", TICKETS_URI + ticketUUID, HttpVersion.HTTP_1_1); String responseContent; try (DefaultBHttpClientConnection conn = getConnection()) { HttpEntity response = executeRequest(request, conn); BufferedReader reader = new BufferedReader(new InputStreamReader(response.getContent())); responseContent = reader.lines().collect(Collectors.joining()); EntityUtils.consume(response); } catch (IOException e) { throw new RuntimeException(e.getMessage(), e); } return ImageTicketInformationHelper.fromJson(responseContent); }
Source:
<code>public String value() { <START> return statusMsg.toUpperCase(); <END> }</code><technical_language>defined upper case - so, do need run "toUpperCase"</technical_language>

Target:
public String value() { return statusMsg; }
Source:
<code>protected void abortOnBadSetup(@NonNull IJavaProject javaProject, @Nullable ProjectState projectState) throws AbortBuildException, CoreException { IProject iProject = javaProject.getProject(); Sdk sdk = Sdk.getCurrent(); if (sdk == null) { throw new AbortBuildException(); } if (projectState == null) { projectState = Sdk.getProjectState(javaProject.getProject()); } IAndroidTarget target = projectState.getTarget(); if (target == null) { throw new AbortBuildException(); } if (sdk.checkAndLoadTargetData(target, javaProject) != LoadStatus.LOADED) { throw new AbortBuildException(); } mBuildToolInfo = projectState.getBuildToolInfo(); if (mBuildToolInfo == null) { mBuildToolInfo = sdk.getLatestBuildTool(); if (mBuildToolInfo == null) { AdtPlugin.printBuildToConsole(BuildVerbosity.VERBOSE, iProject, <START> "No Build Tool available"); <END> throw new AbortBuildException(); } else { AdtPlugin.printBuildToConsole(BuildVerbosity.VERBOSE, iProject, String.format("Using default Build Tools revision %s", mBuildToolInfo.getRevision()) ); } } stopOnMarker(iProject, AdtConstants.MARKER_TARGET, IResource.DEPTH_ZERO, false ); stopOnMarker(iProject, AdtConstants.MARKER_ADT, IResource.DEPTH_ZERO, false ); }</code><technical_language>I if users understand "Build Tool" -- Eclipse is a build tool. "No \"Build Tools\" package installed; SDK Manager install it"</technical_language>

Target:
protected void abortOnBadSetup(@NonNull IJavaProject javaProject, @Nullable ProjectState projectState) throws AbortBuildException, CoreException { IProject iProject = javaProject.getProject(); Sdk sdk = Sdk.getCurrent(); if (sdk == null) { throw new AbortBuildException(); } if (projectState == null) { projectState = Sdk.getProjectState(javaProject.getProject()); } IAndroidTarget target = projectState.getTarget(); if (target == null) { throw new AbortBuildException(); } if (sdk.checkAndLoadTargetData(target, javaProject) != LoadStatus.LOADED) { throw new AbortBuildException(); } mBuildToolInfo = projectState.getBuildToolInfo(); if (mBuildToolInfo == null) { mBuildToolInfo = sdk.getLatestBuildTool(); if (mBuildToolInfo == null) { AdtPlugin.printBuildToConsole(BuildVerbosity.VERBOSE, iProject, "No \"Build Tools\" package available; use SDK Manager to install one."); throw new AbortBuildException(); } else { AdtPlugin.printBuildToConsole(BuildVerbosity.VERBOSE, iProject, String.format("Using default Build Tools revision %s", mBuildToolInfo.getRevision()) ); } } stopOnMarker(iProject, AdtConstants.MARKER_TARGET, IResource.DEPTH_ZERO, false ); stopOnMarker(iProject, AdtConstants.MARKER_ADT, IResource.DEPTH_ZERO, false ); }
Source:
<code>public boolean equals(Object o) { <START> Page other = (Page) o; <END> return getTitle().equals(other.getTitle()) && getSections().equals(other.getSections()); }</code><technical_language>this throw a runtime exception if other object a Page</technical_language>

Target:
public boolean equals(Object o) { if (!(o instanceof Page)) { return false; } Page other = (Page) o; return getTitle().equals(other.getTitle()) && getSections().equals(other.getSections()); }
Source:
<code>public Integer mergingUpdate(Collection<Statement> insertStatements, Collection<String> valueSet, Collection<String> refSet) { log.trace("Running Merging Update"); long startQuery = System.currentTimeMillis(); final ContentResponse response; try { ResponseHandler<Integer> responseHandler = UPDATE_COUNT_RESPONSE; response = retryer.call(() -> { OutputStreamContentProvider content = new OutputStreamContentProvider(); Request request = makeMergingUpdateRequest(content, valueSet, refSet, responseHandler.acceptHeader()); FutureResponseListener listener = new FutureResponseListener(request); try (OutputStream output = content.getOutputStream()) { request.send(listener); OutputStreamWriter sw = new OutputStreamWriter(output, StandardCharsets.UTF_8); TurtleWriter w = new TurtleWriter(sw); try { w.startRDF(); for (Statement st: insertStatements) { w.handleStatement(st); } w.endRDF(); } <START> catch (RDFHandlerException <END> e) { throw new RuntimeException("Error writing insertStatements", e); } } return listener.get(); } ); if (response.getStatus() != OK_200) { throw new ContainedException("Non-200 response from triple store: " + response + " body=\n" + response.getContentAsString()); } log.debug("Completed in ms", System.currentTimeMillis() - startQuery); return responseHandler.parse(response); } catch (ExecutionException | RetryException | IOException e) { throw new FatalException("Error accessing triple store", e); } }</code><technical_language>Is this nested try-catch needed? merge outer one</technical_language>

Target:
public Integer mergingUpdate(Collection<Statement> insertStatements, Collection<String> valueSet, Collection<String> refSet) { log.trace("Running Merging Update"); long startQuery = System.currentTimeMillis(); final ContentResponse response; try { ResponseHandler<Integer> responseHandler = UPDATE_COUNT_RESPONSE; response = retryer.call(() -> { OutputStreamContentProvider content = new OutputStreamContentProvider(); Request request = makeMergingUpdateRequest(content, valueSet, refSet, responseHandler.acceptHeader()); FutureResponseListener listener = new FutureResponseListener(request); try (OutputStream output = content.getOutputStream()) { request.send(listener); OutputStreamWriter sw = new OutputStreamWriter(output, StandardCharsets.UTF_8); TurtleWriter w = new TurtleWriter(sw); w.startRDF(); for (Statement st: insertStatements) { w.handleStatement(st); } w.endRDF(); } catch (RDFHandlerException e) { throw new RuntimeException("Error writing insertStatements", e); } return listener.get(); } ); if (response.getStatus() != OK_200) { throw new ContainedException("Non-200 response from triple store: " + response + " body=\n" + response.getContentAsString()); } log.debug("Completed in ms", System.currentTimeMillis() - startQuery); return responseHandler.parse(response); } catch (ExecutionException | RetryException | IOException e) { throw new FatalException("Error accessing triple store", e); } }
Source:
<code>void initiate(ByteBuf toSend, int entryLength) { if (callbackTriggered) { return; } if (timeoutSec > -1) { this.timeout = lh.bk.getBookieClient().scheduleTimeout(this, timeoutSec, TimeUnit.SECONDS); } this.requestTimeNanos = MathUtils.nowInNano(); this.toSend = toSend; this.toSend.retain(); this.entryLength = entryLength; DistributionSchedule.WriteSet writeSet = lh.distributionSchedule.getWriteSet(entryId); <START> for (int i = 0; i < writeSet.size(); i++) { <END> sendWriteRequest(writeSet.get(i)); } writeSet.recycle(); }</code><technical_language>try { ... } finally { writeSet.recycle(); }</technical_language>

Target:
void initiate(ByteBuf toSend, int entryLength) { if (callbackTriggered) { return; } if (timeoutSec > -1) { this.timeout = lh.bk.getBookieClient().scheduleTimeout(this, timeoutSec, TimeUnit.SECONDS); } this.requestTimeNanos = MathUtils.nowInNano(); this.toSend = toSend; this.toSend.retain(); this.entryLength = entryLength; DistributionSchedule.WriteSet writeSet = lh.distributionSchedule.getWriteSet(entryId); try { for (int i = 0; i < writeSet.size(); i++) { sendWriteRequest(writeSet.get(i)); } } finally { writeSet.recycle(); } }
Source:
<code>public void serializeStatsSnapshotTest() throws IOException { Long val = 100L; Map<String, StatsSnapshot> subMap = new HashMap<>(); subMap.put("first", new StatsSnapshot(40L, null)); subMap.put("second", new StatsSnapshot(60L, null)); StatsSnapshot snapshot = new StatsSnapshot(val, subMap); String result = new ObjectMapper().writeValueAsString(snapshot); <START> assertThat(result, containsString("first")); <END> assertThat(result, containsString("second")); assertThat(result, not(containsString("subMap"))); assertThat(result, not(containsString("null"))); }</code><technical_language>Messages in asserts helpful understand happening</technical_language>

Target:
public void serializeStatsSnapshotTest() throws IOException { Long val = 100L; Map<String, StatsSnapshot> subMap = new HashMap<>(); subMap.put("first", new StatsSnapshot(40L, null)); subMap.put("second", new StatsSnapshot(60L, null)); StatsSnapshot snapshot = new StatsSnapshot(val, subMap); String result = new ObjectMapper().writeValueAsString(snapshot); assertThat("Result should contain \"first\" keyword and associated entry", result, containsString("first")); assertThat("Result should contain \"second\" keyword and associated entry", result, containsString("second")); assertThat("Result should not contain \"subMap\" keyword", result, not(containsString("subMap"))); assertThat("Result should ignore any null fields", result, not(containsString("null"))); }
Source:
<code>public byte[] readRawReplayData(Path replayFile) { logger.debug("Reading replay file: {}", replayFile); Optional<String> replayData = Files.lines(replayFile).skip(1).findFirst(); if (replayData.isPresent()) { <START> return QtCompress.qUncompress(BaseEncoding.base64().decode(replayData.get())); <END> } throw new IOException(String.format("Failed to extract replay data from replay file: {}", replayFile)); }</code><technical_language>this QtCompres.qUncompress decompress stuff right? <LINK_0> Do need shift 4 bytes</technical_language>

Target:
public byte[] readRawReplayData(Path replayFile) { logger.debug("Reading replay file: {}", replayFile); try (Stream<String> stream = Files.lines(replayFile)) { return stream .skip(1) .findFirst() .map(base64String -> noCatch(() -> QtCompress.qUncompress(BaseEncoding.base64().decode(base64String)))) .orElseThrow(() -> new IOException(String.format("Failed to extract replay data from replay file: {}", replayFile))); } }
Source:
<code>public void beforeSession(TestSession session) { super.beforeSession(session); String udid = String.valueOf(session.getSlot().getCapabilities().get("udid")); if (STF.isSTFRequired(session.getSlot().getCapabilities(), session.getRequestedCapabilities())) { STF.reserveDevice(udid); } if (!StringUtils.isEmpty(udid)) { session.getRequestedCapabilities().put("slotCapabilities", getSlotCapabilities(session, udid)); session.put("Device", udid); <START> LOGGER.info("Extracted udid:".concat(udid)); <END> LOGGER.info("Session:".concat(session.toString())); } }</code><technical_language>pls, remove loggers</technical_language>

Target:
public void beforeSession(TestSession session) { super.beforeSession(session); String udid = String.valueOf(session.getSlot().getCapabilities().get("udid")); if (STF.isSTFRequired(session.getSlot().getCapabilities(), session.getRequestedCapabilities())) { STF.reserveDevice(udid); } if (!StringUtils.isEmpty(udid)) { session.getRequestedCapabilities().put("slotCapabilities", getSlotCapabilities(session, udid)); } }
Source:
<code>public void should_get_all_tag_names() throws Exception { List<String> tagsNames = tags.allNames(); assertEquals(5, tagsNames.size()); assertEquals(csharp.getName(), tagsNames.get(0)); assertEquals(cplus.getName(), tagsNames.get(1)); assertEquals(weirdCharacters.getName(), tagsNames.get(2)); assertEquals(java.getName(), tagsNames.get(3)); <START> assertEquals(ruby.getName(), tagsNames.get(4)); <END> }</code><technical_language>hamcrest matchers easier read here. like: assertThat(tagNames, Matchers.containsInAnyOrder(java.getName(), ruby.getName()....)</technical_language>

Target:
public void should_get_all_tag_names() throws Exception { List<String> tagsNames = tags.allNames(); assertEquals(5, tagsNames.size()); assertThat(tagsNames, Matchers.containsInAnyOrder( csharp.getName(), cplus.getName(), weirdCharacters.getName(), java.getName(),ruby.getName())); }
Source:
<code>public void testCopy() throws Exception { RaParser parser = new RaParser(); InputStream is1 = JCA10TestCase.class.getClassLoader(). getResourceAsStream("../../resources/test/spec/ra-1.0.xml"); assertNotNull(is1); XMLInputFactory inputFactory = XMLInputFactory.newInstance(); inputFactory.setProperty(XMLInputFactory.SUPPORT_DTD, Boolean.FALSE); XMLStreamReader xsr1 = inputFactory.createXMLStreamReader(is1); Connector c1 = parser.parse(xsr1); assertNotNull(c1); is1.close(); Connector c2 = c1.copy(); <START> assertEquals(c1, c2); <END> }</code><technical_language>I for good measure assert c1 != c2 a pointer level, toString's</technical_language>

Target:
public void testCopy() throws Exception { RaParser parser = new RaParser(); InputStream is1 = JCA10TestCase.class.getClassLoader(). getResourceAsStream("../../resources/test/spec/ra-1.0.xml"); assertNotNull(is1); XMLInputFactory inputFactory = XMLInputFactory.newInstance(); inputFactory.setProperty(XMLInputFactory.SUPPORT_DTD, Boolean.FALSE); XMLStreamReader xsr1 = inputFactory.createXMLStreamReader(is1); Connector c1 = parser.parse(xsr1); assertNotNull(c1); is1.close(); Connector c2 = c1.copy(); assertEquals(c1, c2); assertFalse(c1 == c2); assertEquals(c1.toString(), c2.toString()); }
Source:
<code>public JDBCFieldConverter createConverter(LogicalType type) { LogicalTypeRoot root = type.getTypeRoot(); if (root == LogicalTypeRoot.ARRAY) { ArrayType arrayType = (ArrayType) type; LogicalTypeRoot elemType = arrayType.getElementType().getTypeRoot(); if (elemType == LogicalTypeRoot.VARBINARY) { return v -> { PgArray pgArray = (PgArray) v; Object[] in = (Object[]) pgArray.getArray(); Object[] out = new Object[in.length]; for (int i = 0; i < in.length; i++) { out[i] = ((PGobject) in[i]).getValue().getBytes(); } return out; }; } else { return v -> ((PgArray) v).getArray(); } <START> } else { <END> return createPrimitiveConverter(type); } }</code><technical_language>add default conversion for ARRAY in AbstractJDBCRowConverter? Currently, put java.sql.Array Row is correct</technical_language>

Target:
public JDBCFieldConverter createConverter(LogicalType type) { LogicalTypeRoot root = type.getTypeRoot(); if (root == LogicalTypeRoot.ARRAY) { ArrayType arrayType = (ArrayType) type; if (LogicalTypeChecks.hasFamily(arrayType.getElementType(), LogicalTypeFamily.BINARY_STRING)) { return v -> { PgArray pgArray = (PgArray) v; Object[] in = (Object[]) pgArray.getArray(); Object[] out = new Object[in.length]; for (int i = 0; i < in.length; i++) { out[i] = ((PGobject) in[i]).getValue().getBytes(); } return out; }; } else { return v -> ((PgArray) v).getArray(); } } else { return createPrimitiveConverter(type); } }
Source:
<code>public AnnotateCommand() { Options o = CommandLineHelper.getCommonOptions(); o.addOption("A", "annotation-file", true, "add annotation from a file"); o.addOption("O", "ontology-iri", true, "set the ontology IRI"); o.addOption("V", "version-iri", true, "set the ontology version IRI"); o.addOption("i", "input", true, "convert ontology from a file"); o.addOption("I", "input-iri", true, "convert ontology from an IRI"); o.addOption("o", "output", true, "save ontology to a file"); options = o; Option a = new Option("R", "remove-annotations", true, "remove all annotations on the ontology"); a.setOptionalArg(true); o.addOption(a); a = new Option("a", "annotate ontology with PROP VALUE"); a.setLongOpt("annotation"); a.setArgs(2); options.addOption(a); a = new Option("k", "annotate ontology with PROP IRI"); a.setLongOpt("link-annotation"); a.setArgs(2); options.addOption(a); a = new Option("l", "annotate ontology with PROP VALUE LANG"); a.setLongOpt("language-annotation"); a.setArgs(3); options.addOption(a); a = new Option("t", "annotate ontology with PROP VALUE LANG"); a.setLongOpt("typed-annotation"); a.setArgs(3); options.addOption(a); <START> a = new Option("x", "annotate all axioms in the ontology " + "with PROP VALUE"); <END> a.setLongOpt("axiom-annotation"); a.setArgs(3); options.addOption(a); }</code><technical_language>"with PROP TYPE"</technical_language>

Target:
public AnnotateCommand() { Options o = CommandLineHelper.getCommonOptions(); o.addOption("A", "annotation-file", true, "add annotation from a file"); o.addOption("O", "ontology-iri", true, "set the ontology IRI"); o.addOption("V", "version-iri", true, "set the ontology version IRI"); o.addOption("i", "input", true, "convert ontology from a file"); o.addOption("I", "input-iri", true, "convert ontology from an IRI"); o.addOption("o", "output", true, "save ontology to a file"); options = o; Option a = new Option("R", "remove-annotations", true, "remove all annotations on the ontology"); a.setOptionalArg(true); o.addOption(a); a = new Option("a", "annotate ontology with PROP VALUE"); a.setLongOpt("annotation"); a.setArgs(2); options.addOption(a); a = new Option("k", "annotate ontology with PROP IRI"); a.setLongOpt("link-annotation"); a.setArgs(2); options.addOption(a); a = new Option("l", "annotate ontology with PROP VALUE LANG"); a.setLongOpt("language-annotation"); a.setArgs(3); options.addOption(a); a = new Option("t", "annotate ontology with PROP VALUE TYPE"); a.setLongOpt("typed-annotation"); a.setArgs(3); options.addOption(a); a = new Option("x", "annotate all axioms in the ontology " + "with PROP VALUE"); a.setLongOpt("axiom-annotation"); a.setArgs(3); options.addOption(a); }
Source:
<code>public void removeMessage(String reason) { waitForElementByCss("div.msg-toolbar"); executeScript("document.getElementsByClassName(\"buttons\")[1].style.display = \"block\""); waitForElementByElement(moreButton); mouseOver(moreButtonCss); executeScript("document.querySelectorAll(\"div.msg-toolbar nav.wikia-menu-button.secondary.combined\")[0].click()"); mouseOver(".WikiaMenuElement .remove-message"); jQueryNthElemClick(".WikiaMenuElement .remove-message", 0); waitForElementByElement(removeCloseMessageOverLay); waitForElementByElement(removeCloseMessageConfirmButton); <START> if (Global.BROWSER.equals("IE")) { <END> WebElement removeMessageReasonParent = getParentElement(removeCloseMessageReason); clickAndWait(removeMessageReasonParent); removeMessageReasonParent.sendKeys(reason); clickAndWait(removeCloseMessageConfirmButton); } else { removeCloseMessageReason.sendKeys(reason); clickAndWait(removeCloseMessageConfirmButton); } waitForElementByElement(removeMessageConfirmation); driver.navigate().refresh(); PageObjectLogging.log("removeMessage", "message is removed", true, driver); }</code><technical_language>try avoid code for</technical_language>

Target:
public void removeMessage(String reason) { waitForElementByElement(msgToolbar); setStyle(".buttons", "1", "block"); waitForElementByElement(moreButton); mouseOver(moreButtonCss); jQueryClick(msgToolbarNav); mouseOver(".WikiaMenuElement .remove-message"); jQueryNthElemClick(".WikiaMenuElement .remove-message", 0); waitForElementByElement(removeCloseOverLay); waitForElementByElement(removeCloseConfirmButton); if (Global.BROWSER.equals("IE")) { WebElement removeMessageReasonParent = getParentElement(removeCloseReason); clickAndWait(removeMessageReasonParent); removeMessageReasonParent.sendKeys(reason); click(removeCloseConfirmButton); } else { removeCloseReason.sendKeys(reason); click(removeCloseConfirmButton); } waitForElementByElement(removeMessageConfirmation); driver.navigate().refresh(); PageObjectLogging.log("removeMessage", "message is removed", true, driver); }
Source:
<code>public ChangeInfo apply(ChangeResource req, final AbandonInput input) throws AuthException, RestApiException, UpdateException, OrmException { if (!req.getControl().canAbandon()) { throw new AuthException("abandon not permitted"); } <START> Op op = new Op(input); <END> try (BatchUpdate u = batchUpdateFactory.create(dbProvider.get(), req.getChange().getProject(), TimeUtil.nowTs())) { u.addOp(req.getControl(), op).execute(); } return json.format(op.change); }</code><technical_language>optional: sense rename AbandonOperation</technical_language>

Target:
public ChangeInfo apply(ChangeResource req, final AbandonInput input) throws AuthException, RestApiException, UpdateException, OrmException { if (!req.getControl().canAbandon()) { throw new AuthException("abandon not permitted"); } change = abandon(control, input.message, caller.getAccount()); return json.create(ChangeJson.NO_OPTIONS).format(change); }
Source:
<code>private void testDisabledOutputPaging() throws Exception { consoleWriter.println("/subsystem=elytron:read-resource-description(recursive=true)"); Assert.assertFalse(consoleWriter.checkError()); <START> String window = queue.poll(100, TimeUnit.SECONDS); <END> Assert.assertNotNull(window); checkWithRegex(window, promptPattern); Assert.assertTrue(Pattern.compile("^\\{.*^\\}", Pattern.MULTILINE | Pattern.DOTALL) .matcher(window).find()); }</code><technical_language>100 seconds is 1 order of magnitude more. a lot. doubling 20s enough? instead org.jboss.as.test.shared.TimeoutUtil#adjust adjust time of this test</technical_language>

Target:
private void testDisabledOutputPaging() throws Exception { consoleWriter.println("/subsystem=elytron:read-resource-description(recursive=true)"); Assert.assertFalse(consoleWriter.checkError()); String window = queue.poll(TimeoutUtil.adjust(20), TimeUnit.SECONDS); Assert.assertNotNull(window); checkWithRegex(window, promptPattern); Assert.assertTrue(Pattern.compile("^\\{.*^\\}", Pattern.MULTILINE | Pattern.DOTALL) .matcher(window).find()); }
Source:
<code>private void checkFunctionDeclaration(SubscriptionContext ctx) { FunctionDef functionDef = (FunctionDef) ctx.syntaxNode(); Tree ancestor = TreeUtils.firstAncestorOfKind(functionDef, Tree.Kind.FUNCDEF, Tree.Kind.CLASSDEF); <START> if ((ancestor == null || ancestor.getKind().equals(Tree.Kind.FUNCDEF)) && shouldReportIssue(functionDef.name(), functionDef)) { <END> ctx.addIssue(functionDef.name(), String.format(MESSAGE, "function")); } ParameterList parameterList = functionDef.parameters(); if (parameterList != null) { for (Parameter parameter : parameterList.nonTuple()) { Name parameterName = parameter.name(); if (parameterName != null && isBuiltInName(parameterName)) { ctx.addIssue(parameterName, String.format(MESSAGE, "parameter")); } } } }</code><technical_language>FunctionDef::isMethodDefinition avoid compute yourself</technical_language>

Target:
private void checkFunctionDeclaration(SubscriptionContext ctx) { FunctionDef functionDef = (FunctionDef) ctx.syntaxNode(); if (!functionDef.isMethodDefinition() && shouldReportIssue(functionDef.name())) { ctx.addIssue(functionDef.name(), String.format(MESSAGE, "function")); } }
Source:
<code>public StreamsTaskCounter(String id) { this.emitted = new AtomicLong(0); this.received = new AtomicLong(0); this.errors = new AtomicLong(0); this.totalTime = new AtomicLong(0); this.maxTime = -1; <START> try { <END> ObjectName name = new ObjectName(String.format(NAME_TEMPLATE, id)); MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); mbs.registerMBean(this, name); } catch (MalformedObjectNameException | InstanceAlreadyExistsException | MBeanRegistrationException | NotCompliantMBeanException e) { LOGGER.error("Failed to register MXBean : {}", e); throw new RuntimeException(e); } }</code><technical_language>this block reused, chance abstracted out a common interface</technical_language>

Target:
public StreamsTaskCounter(String id) { this.emitted = new AtomicLong(0); this.received = new AtomicLong(0); this.errors = new AtomicLong(0); this.totalTime = new AtomicLong(0); this.maxTime = -1; ComponentUtils.registerLocalMBean(String.format(NAME_TEMPLATE, id), this); }