auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
public void createRecoveryKey() { Task<String> task = new RecoveryKeyCreationTask(); task.setOnScheduled(event -> { LOG.debug("Creating recovery key for {}.", vault.getDisplayablePath()); }); task.setOnSucceeded(event -> { String recoveryKey = task.getValue(); recoveryKeyProperty.set(recoveryKey); window.setScene(successScene.get()); }); task.setOnFailed(event -> { if (task.getException() instanceof InvalidPassphraseException) { Animations.createShakeWindowAnimation(window).play(); } else { LOG.error("Creation of recovery key failed.", task.getException()); errorComponent.cause(task.getException()).window(window).returnToScene(createScene.get()).build().showErrorScene(); } }); executor.submit(task); }

Target:
public void createRecoveryKey() { Task<String> task = new RecoveryKeyCreationTask(); task.setOnScheduled(event -> { LOG.debug("Creating recovery key for {}.", vault.getDisplayablePath()); }); task.setOnSucceeded(event -> { String recoveryKey = task.getValue(); recoveryKeyProperty.set(recoveryKey); window.setScene(successScene.get()); }); task.setOnFailed(event -> { if (task.getException() instanceof InvalidPassphraseException) { Animations.createShakeWindowAnimation(window).play(); } else { LOG.error("Creation of recovery key failed.", task.getException()); } }); executor.submit(task); }
Source:
private void verifyDirectMemory(DruidProcessingConfig config) { try { final long maxDirectMemory = JvmUtils.getRuntimeInfo().getDirectMemorySizeBytes(); final long memoryNeeded = (long) config.intermediateComputeSizeBytes() * (config.getNumMergeBuffers() + config.getNumThreads() + 1); if (maxDirectMemory < memoryNeeded) { throw new ProvisionException( StringUtils.format( "Not enough direct memory. Please adjust -XX:MaxDirectMemorySize, druid.processing.buffer.sizeBytes, druid.processing.numThreads, or druid.processing.numMergeBuffers: " + "maxDirectMemory[%,d], memoryNeeded[%,d] = druid.processing.buffer.sizeBytes[%,d] * (druid.processing.numMergeBuffers[%,d] + druid.processing.numThreads[%,d] + 1)", maxDirectMemory, memoryNeeded, config.intermediateComputeSizeBytes(), config.getNumMergeBuffers(), config.getNumThreads() ) ); } } catch (UnsupportedOperationException e) { log.debug("Checking for direct memory size is not support on this platform: %s", e); log.info( "Unable to determine max direct memory size. If -XX:MaxDirectMemorySize is set, make sure " + "a) -XX:MaxDirectMemorySize is set to at least [%,d] bytes (25%% of maximum heap size), or " + "b) set druid.processing.buffer.sizeBytes, such that " + "druid.processing.buffer.sizeBytes * (druid.processing.numMergeBuffers[%,d] + druid.processing.numThreads[%,d] + 1) " + "does not exceed the value of -XX:MaxDirectMemorySize", DruidProcessingConfig.computeMaxMemoryFromMaxHeapSize(), config.getNumMergeBuffers(), config.getNumThreads() ); } }

Target:
private void verifyDirectMemory(DruidProcessingConfig config) { try { final long maxDirectMemory = JvmUtils.getRuntimeInfo().getDirectMemorySizeBytes(); final long memoryNeeded = (long) config.intermediateComputeSizeBytes() * (config.getNumMergeBuffers() + config.getNumThreads() + 1); if (maxDirectMemory < memoryNeeded) { throw new ProvisionException( StringUtils.format( "Not enough direct memory. Please adjust -XX:MaxDirectMemorySize, druid.processing.buffer.sizeBytes, druid.processing.numThreads, or druid.processing.numMergeBuffers: " + "maxDirectMemory[%,d], memoryNeeded[%,d] = druid.processing.buffer.sizeBytes[%,d] * (druid.processing.numMergeBuffers[%,d] + druid.processing.numThreads[%,d] + 1)", maxDirectMemory, memoryNeeded, config.intermediateComputeSizeBytes(), config.getNumMergeBuffers(), config.getNumThreads() ) ); } } catch (UnsupportedOperationException e) { log.debug("Checking for direct memory size is not support on this platform: %s", e); log.info( "Unable to determine max direct memory size. If druid.processing.buffer.sizeBytes is explicitly configured, " + "then make sure to set -XX:MaxDirectMemorySize to at least \"druid.processing.buffer.sizeBytes * " + "(druid.processing.numMergeBuffers[%,d] + druid.processing.numThreads[%,d] + 1)\", " + "or else set -XX:MaxDirectMemorySize to at least 25%% of maximum jvm heap size.", config.getNumMergeBuffers(), config.getNumThreads() ); } }
Source:
public void run() { Message msg = null; AsyncSubscriptionImpl sub = null; ConnectionImpl nc = null; MessageHandler mcb = null; long max = 0; long delivered = 0; this.mu.lock(); while (true) { while (this.msgs.isEmpty() && !this.shutdown) { this.inWait = true; try { this.cond.await(); } catch (InterruptedException e) this.inWait = false; } if (this.msgs.isEmpty() && this.shutdown) { break; } msg = this.msgs.remove(0); sub = (AsyncSubscriptionImpl) msg.getSubscription(); nc = (ConnectionImpl) sub.getConnection(); mcb = sub.getMessageHandler(); max = sub.max; sub.pMsgs--; sub.pBytes -= (msg.getData() == null ? 0 : msg.getData().length); if (sub.closed) { continue; } delivered = ++(sub.delivered); this.mu.unlock(); if ((max == 0) || (delivered <= max)) { try { mcb.onMessage(msg); } catch (Throwable t) { } } if ((max > 0) && (delivered >= max)) { nc.mu.lock(); try { nc.removeSub(sub); } finally { nc.mu.unlock(); } } this.mu.lock(); } this.mu.unlock(); }

Target:
public void run() { Message msg = null; AsyncSubscriptionImpl sub = null; ConnectionImpl nc = null; MessageHandler mcb = null; long max = 0; long delivered = 0; this.mu.lock(); while (true) { while (this.msgs.isEmpty() && !this.shutdown) { this.inWait = true; try { this.cond.await(); } catch (InterruptedException e) this.inWait = false; } if (this.msgs.isEmpty() && this.shutdown) { break; } msg = this.msgs.remove(0); sub = (AsyncSubscriptionImpl) msg.getSubscription(); if (sub.closed) { continue; } nc = sub.conn; mcb = sub.msgHandler; max = sub.max; sub.pMsgs--; sub.pBytes -= (msg.getData() == null ? 0 : msg.getData().length); delivered = ++(sub.delivered); this.mu.unlock(); if ((max == 0) || (delivered <= max)) { try { mcb.onMessage(msg); } catch (Throwable t) { } } if ((max > 0) && (delivered >= max)) { nc.mu.lock(); try { nc.removeSub(sub); } finally { nc.mu.unlock(); } } this.mu.lock(); } this.mu.unlock(); }
Source:
public void handleMessageLog(TelemetryMessageLog messageLog) { LOG.debug("Received telemetry messages", messageLog.getMessageList().size()); final List<P> flowPackets = new LinkedList<>(); final List<Flow> flows = new LinkedList<>(); try (Timer.Context ctx = logParsingTimer.time()) { for (TelemetryMessageLogEntry eachMessage : messageLog.getMessageList()) { LOG.trace("Parsing packet: {}", eachMessage); final P flowPacket = parse(eachMessage); if (flowPacket != null) { flowPackets.add(flowPacket); flows.addAll(converter.convert(flowPacket)); } } packetsPerLogHistogram.update(flowPackets.size()); } try { LOG.debug("Persisting packets, flows.", flowPackets.size(), flows.size()); final FlowSource source = new FlowSource(messageLog.getLocation(), messageLog.getSourceAddress()); flowRepository.persist(flows, source); } catch (DetailedFlowException ex) { LOG.error("Error while persisting flows: {}", ex.getMessage(), ex); for (final String logMessage: ex.getDetailedLogMessages()) { LOG.error(logMessage); } } catch (FlowException ex) { LOG.error("Error while persisting flows: {}", ex.getMessage(), ex); if (ex.getMessage().equals("Connection pool shut down")) { LOG.error("Connection pool was shut down. Cannot recover. messages are lost", messageLog.getMessageList().size()); return; } } LOG.debug("Completed processing telemetry messages.", messageLog.getMessageList().size()); }

Target:
public void handleMessageLog(TelemetryMessageLog messageLog) { LOG.debug("Received telemetry messages", messageLog.getMessageList().size()); final List<P> flowPackets = new LinkedList<>(); final List<Flow> flows = new LinkedList<>(); try (Timer.Context ctx = logParsingTimer.time()) { for (TelemetryMessageLogEntry eachMessage : messageLog.getMessageList()) { LOG.trace("Parsing packet: {}", eachMessage); final P flowPacket = parse(eachMessage); if (flowPacket != null) { flowPackets.add(flowPacket); flows.addAll(converter.convert(flowPacket)); } } packetsPerLogHistogram.update(flowPackets.size()); } try { LOG.debug("Persisting packets, flows.", flowPackets.size(), flows.size()); final FlowSource source = new FlowSource(messageLog.getLocation(), messageLog.getSourceAddress()); flowRepository.persist(flows, source); } catch (DetailedFlowException ex) { LOG.error("Error while persisting flows: {}", ex.getMessage(), ex); for (final String logMessage: ex.getDetailedLogMessages()) { LOG.error(logMessage); } } catch(UnrecoverableFlowException ex) { LOG.error("Error while persisting flows. Cannot recover: {}. messages are lost.", ex.getMessage(), messageLog.getMessageList().size(), ex); return; } catch (FlowException ex) { LOG.error("Error while persisting flows: {}", ex.getMessage(), ex); } LOG.debug("Completed processing telemetry messages.", messageLog.getMessageList().size()); }
Source:
public void execute(CommandLine options) throws Exception { super.execute(options); String[] args = options.getArgs(); String input = args[0]; ParquetReader<SimpleRecord> reader = null; try { PrintWriter writer = new PrintWriter(Main.out, true); reader = ParquetReader.builder(new SimpleReadSupport(), new Path(input)).build(); ParquetMetadata metadata = ParquetFileReader.readFooter(new Configuration(), new Path(input)); JsonRecordFormatter.JsonGroupFormatter formatter = JsonRecordFormatter.fromSchema(metadata.getFileMetaData().getSchema()); for (SimpleRecord value = reader.read(); value != null; value = reader.read()) { if (options.hasOption('j')) { writer.write(formatter.formatRecord(value)); } else { value.prettyPrint(writer); } writer.println(); } } catch (Throwable ex) { ex.printStackTrace(); } finally { if (reader != null) { try { reader.close(); } catch (Exception ex) { } } } }

Target:
public void execute(CommandLine options) throws Exception { super.execute(options); String[] args = options.getArgs(); String input = args[0]; ParquetReader<SimpleRecord> reader = null; try { PrintWriter writer = new PrintWriter(Main.out, true); reader = ParquetReader.builder(new SimpleReadSupport(), new Path(input)).build(); ParquetMetadata metadata = ParquetFileReader.readFooter(new Configuration(), new Path(input)); JsonRecordFormatter.JsonGroupFormatter formatter = JsonRecordFormatter.fromSchema(metadata.getFileMetaData().getSchema()); for (SimpleRecord value = reader.read(); value != null; value = reader.read()) { if (options.hasOption('j')) { writer.write(formatter.formatRecord(value)); } else { value.prettyPrint(writer); } writer.println(); } } finally { if (reader != null) { try { reader.close(); } catch (Exception ex) { } } } }
Source:
public boolean setChecked(Object element, boolean state) { if (fObjects.containsKey(element)) { if (!state || (fCheckboxTreeViewer.testFindItem(element) != null)) { fObjects.put(element, state); } } return fCheckboxTreeViewer.setChecked(element, state); }

Target:
public boolean setChecked(Object element, boolean state) { boolean checkable = fCheckboxTreeViewer.setChecked(element, state); if (!state) { fObjects.remove(element); } else if (checkable) { fObjects.add(element); } return checkable; }
Source:
private static ServiceTracker<LoggerFactory, Logger> openLoggerTracker() { try { ServiceTracker<LoggerFactory, Logger> tracker = new ServiceTracker<>( FrameworkUtil.getBundle(ResourceBundleHelper.class).getBundleContext(), LoggerFactory.class, new ServiceTrackerCustomizer<LoggerFactory, Logger>() { @Override public Logger addingService(ServiceReference<LoggerFactory> reference) { LoggerFactory factory = reference.getBundle().getBundleContext().getService(reference); if (factory != null) { return factory.getLogger(ResourceBundleHelper.class); } return null; } @Override public void modifiedService(ServiceReference<LoggerFactory> reference, Logger service) { } @Override public void removedService(ServiceReference<LoggerFactory> reference, Logger service) { } }); tracker.open(); return tracker; } catch (Throwable t) { return null; } }

Target:
private static ServiceTracker<LoggerFactory, Logger> openLoggerTracker() { try { BundleContext context = FrameworkUtil.getBundle(ResourceBundleHelper.class).getBundleContext(); ServiceTracker<LoggerFactory, Logger> tracker = new ServiceTracker<>( context, LoggerFactory.class, new ServiceTrackerCustomizer<LoggerFactory, Logger>() { @Override public Logger addingService(ServiceReference<LoggerFactory> reference) { LoggerFactory factory = context.getService(reference); if (factory != null) { return factory.getLogger(ResourceBundleHelper.class); } return null; } @Override public void modifiedService(ServiceReference<LoggerFactory> reference, Logger service) { } @Override public void removedService(ServiceReference<LoggerFactory> reference, Logger service) { context.ungetService(reference); } }); tracker.open(); return tracker; } catch (Throwable t) { return null; } }
Source:
public OracleServer(Environment env) throws Exception { this.env = env; stampsHistogram = env.getSharedResources().getMetricRegistry().histogram(FluoConfiguration.FLUO_PREFIX + ".oracle.server.stamps"); this.cnxnListener = new CuratorCnxnListener(); this.maxTsPath = ZookeeperPath.ORACLE_MAX_TIMESTAMP; this.curTsPath = ZookeeperPath.ORACLE_CUR_TIMESTAMP; this.oraclePath = ZookeeperPath.ORACLE_SERVER; TimerTask tt = new TimerTask() { @Override public void run() { long lastTs = currentTs-1; if (isLeader && (zkTs != lastTs)) { try { curatorFramework.setData().forPath(curTsPath, LongUtil.toByteArray(lastTs)); } catch (Exception e) { throw new IllegalStateException(e); } zkTs = lastTs; } } }; timer = new Timer("Oracle timestamp timer", true); timer.schedule(tt, ZookeeperUtil.ZK_UPDATE_PERIOD_MS, ZookeeperUtil.ZK_UPDATE_PERIOD_MS); }

Target:
public OracleServer(Environment env) throws Exception { this.env = env; stampsHistogram = env.getSharedResources().getMetricRegistry().histogram(MetricNames.ORACLE_SERVER_STAMPS); this.cnxnListener = new CuratorCnxnListener(); this.maxTsPath = ZookeeperPath.ORACLE_MAX_TIMESTAMP; this.curTsPath = ZookeeperPath.ORACLE_CUR_TIMESTAMP; this.oraclePath = ZookeeperPath.ORACLE_SERVER; TimerTask tt = new TimerTask() { @Override public void run() { long lastTs = currentTs-1; if (isLeader && (zkTs != lastTs)) { try { curatorFramework.setData().forPath(curTsPath, LongUtil.toByteArray(lastTs)); } catch (Exception e) { throw new IllegalStateException(e); } zkTs = lastTs; } } }; timer = new Timer("Oracle timestamp timer", true); timer.schedule(tt, ZookeeperUtil.ZK_UPDATE_PERIOD_MS, ZookeeperUtil.ZK_UPDATE_PERIOD_MS); }
Source:
public void testClientCanConnectBothSecureAndUnsecure() throws Exception { System.clearProperty(NettyServerCnxnFactory.PORT_UNIFICATION_KEY); System.clearProperty(ZKClientConfig.SECURE_CLIENT); final int SERVER_COUNT = 3; final int[] clientPorts = new int[SERVER_COUNT]; int[] secureClientPorts = new int[SERVER_COUNT]; MainThread[] mt = startThreeNodeSSLCluster(clientPorts, secureClientPorts); for (int i = 0; i < SERVER_COUNT; i++) { ZKClientConfig secureClientConfig = new ZKClientConfig(); secureClientConfig.setProperty(ZKClientConfig.SECURE_CLIENT, "true"); ZooKeeper zkSecure = ClientBase.createZKClient("127.0.0.1:" + secureClientPorts[i], TIMEOUT, secureClientConfig); zkSecure.create("/test", "".getBytes(), ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT); ZKClientConfig unsecureClientConfig = new ZKClientConfig(); unsecureClientConfig.setProperty(ZKClientConfig.SECURE_CLIENT, "false"); ZooKeeper zkUnsecure = ClientBase.createZKClient("127.0.0.1:" + clientPorts[i], TIMEOUT, unsecureClientConfig); zkUnsecure.delete("/test", -1); zkSecure.close(); zkUnsecure.close(); } for (int i = 0; i < mt.length; i++) { mt[i].shutdown(); } }

Target:
public void testClientCanConnectBothSecureAndUnsecure() throws Exception { System.clearProperty(NettyServerCnxnFactory.PORT_UNIFICATION_KEY); System.clearProperty(ZKClientConfig.SECURE_CLIENT); final int SERVER_COUNT = 3; final int[] clientPorts = new int[SERVER_COUNT]; int[] secureClientPorts = new int[SERVER_COUNT]; MainThread[] mt = startThreeNodeSSLCluster(clientPorts, secureClientPorts); for (int i = 0; i < SERVER_COUNT; i++) { ZKClientConfig secureClientConfig = new ZKClientConfig(); secureClientConfig.setProperty(ZKClientConfig.SECURE_CLIENT, "true"); ZooKeeper zkSecure = ClientBase.createZKClient("127.0.0.1:" + secureClientPorts[i], TIMEOUT, secureClientConfig); zkSecure.create("/test", "".getBytes(), ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT); assertTrue(zkSecure.isSSL()); ZKClientConfig unsecureClientConfig = new ZKClientConfig(); unsecureClientConfig.setProperty(ZKClientConfig.SECURE_CLIENT, "false"); ZooKeeper zkUnsecure = ClientBase.createZKClient("127.0.0.1:" + clientPorts[i], TIMEOUT, unsecureClientConfig); zkUnsecure.delete("/test", -1); assertFalse(zkUnsecure.isSSL()); zkSecure.close(); zkUnsecure.close(); } for (int i = 0; i < mt.length; i++) { mt[i].shutdown(); } }
Source:
@Test public void testAliasUnnestArrayPlanWithSingleColumn() { final String sql = "select d.deptno, employee.empno\n" + "from dept_nested_expanded as d,\n" + " UNNEST(d.employees) as t(employee)"; sql(sql).conformance(SqlConformanceEnum.PRESTO).decorrelate(false).ok(); }

Target:
@Test public void testAliasUnnestArrayPlanWithSingleColumn() { final String sql = "select d.deptno, employee.empno\n" + "from dept_nested_expanded as d,\n" + " UNNEST(d.employees) as t(employee)"; sql(sql).conformance(SqlConformanceEnum.PRESTO).ok(); }
Source:
@NonNull List<PageTitle> langLinks() { List<PageTitle> result = new ArrayList<>(); if (pages == null || pages.get(0).langLinks() == null) { return result; } for (MwQueryPage.LangLink link : pages.get(0).langLinks()) { PageTitle title = new PageTitle(link.title(), WikiSite.forLanguageCode(link.lang())); result.add(title); } return result; }

Target:
@NonNull List<PageTitle> langLinks() { List<PageTitle> result = new ArrayList<>(); if (pages == null || pages.isEmpty() || pages.get(0).langLinks() == null) { return result; } for (MwQueryPage.LangLink link : pages.get(0).langLinks()) { PageTitle title = new PageTitle(link.title(), WikiSite.forLanguageCode(link.lang())); result.add(title); } return result; }
Source:
public void uncaughtException(Thread t, Throwable e) { if (e instanceof OperationCanceledException) { } else { if (diagnostic != null) { diagnostic.add(BasicDiagnostic.toDiagnostic(e)); } else { EMFCompareIDEUIPlugin.getDefault().log(e); } } }

Target:
public void uncaughtException(Thread t, Throwable e) { if (e instanceof OperationCanceledException) { } else if (diagnostic != null) { diagnostic.add(BasicDiagnostic.toDiagnostic(e)); } else { EMFCompareIDEUIPlugin.getDefault().log(e); } }
Source:
private void filterExplosionBlocks(EntityExplodeEvent event, StateFlag flag, WorldConfiguration wcfg, RegionManager mgr){ Iterator<Block> it = event.blockList().iterator(); while(it.hasNext()){ if (!mgr.getApplicableRegions(toVector(it.next())).allows(flag)) { it.remove(); if (wcfg.explosionFlagCancellation) { event.setCancelled(true); break; } } } }

Target:
private void filterExplosionBlocks(EntityExplodeEvent event, StateFlag flag, WorldConfiguration wcfg, RegionManager mgr){ Iterator<Block> it = event.blockList().iterator(); while (it.hasNext()){ if (!mgr.getApplicableRegions(toVector(it.next())).allows(flag)) { if (!wcfg.useExplosionBlockFiltering || wcfg.explosionFlagCancellation) { if (wcfg.explosionFlagCancellation) { event.setCancelled(true); } else { event.blockList().clear(); } break; } it.remove(); } } }
Source:
public List<String> getOptionsNoSupport() { return optionsNoSupport; }

Target:
public List<String> getOptionsNoSupport() { return Collections.unmodifiableList(this.optionsNoSupport); }
Source:
private synchronized Thread getOwnerThread(final ReentrantLock lock) throws Exception{ final Method method = lock.getClass().getDeclaredMethod("getOwner"); if(!method.isAccessible()){ method.setAccessible(true); } return Thread.class.cast(method.invoke(lock)); }

Target:
private Thread getOwnerThread(final ReentrantLock lock) throws NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { final Method method = lock.getClass().getDeclaredMethod("getOwner"); if(!method.isAccessible()){ method.setAccessible(true); } return Thread.class.cast(method.invoke(lock)); }
Source:
public void test() throws Exception { if (isJumpInstruction(testInput.opcode)) { test_jumps(); return; } BytecodeCFGBuilder.BytecodeCFG cfg; if (Instructions.TYPE_INSN.contains(testInput.opcode)) { cfg = new Instructions() .visitTypeInsn(testInput.opcode, MoreObjects.firstNonNull(testInput.type, "SomeType")) .cfg(); } else { cfg = new Instructions().cfg(testInput.opcode, testInput.operandOrVar); } assertThat(cfg.blocks.size()).isEqualTo(2); if(expected == null) { expected = inst(testInput.opcode); } BytecodeCFGBuilder.Instruction actual = cfg.blocks.get(1).instructions.get(0); assertThat(isEquivalentInstruction(actual, expected)).isTrue(); }

Target:
public void test() throws Exception { if (isJumpInstruction(testInput.opcode)) { test_jumps(); return; } BytecodeCFGBuilder.BytecodeCFG cfg = new Instructions().cfg(testInput.opcode, testInput.operandOrVar, testInput.type); assertThat(cfg.blocks.size()).isEqualTo(2); if(expected == null) { expected = inst(testInput.opcode); } BytecodeCFGBuilder.Instruction actual = cfg.blocks.get(1).instructions.get(0); assertThat(isEquivalentInstruction(actual, expected)).isTrue(); }
Source:
protected void release(boolean wait, boolean writer) { final int refCount = this.refCount.decrementAndGet(); if (refCount == 0 && storage != null && canRelease(writer)) { assert (next != null); final Runnable storer = getStorer(data, readingOffset, writingOffset, storage); if (future != null && future.cancel(false)) { logger.debug("Block future is cancelled", this); } final int numberOfInMemBlockPermits = DataList.this.numberOfInMemBlockPermits.get(); if (wait && numberOfInMemBlockPermits == 0) { future = null; storer.run(); } else if (numberOfInMemBlockPermits < MAX_COUNT_OF_INMEM_BLOCKS / 2) { future = storageExecutor.submit(storer); } else { future = null; } } else { logger.debug("Holding in memory due to references.", this, refCount); } }

Target:
protected void release(boolean wait, boolean writer) { final int refCount = this.refCount.decrementAndGet(); if (canEvict(refCount, writer)) { assert (next != null); final Runnable storer = getStorer(data, readingOffset, writingOffset, storage); if (future != null && future.cancel(false)) { logger.debug("Block future is cancelled", this); } final int numberOfInMemBlockPermits = DataList.this.numberOfInMemBlockPermits.get(); if (wait && numberOfInMemBlockPermits == 0) { future = null; storer.run(); } else if (numberOfInMemBlockPermits < MAX_COUNT_OF_INMEM_BLOCKS / 2) { future = storageExecutor.submit(storer); } else { future = null; } } }
Source:
public static PartnerMotionTimeSeries create(final List<TrackerMotion> leftMotions, final List<TrackerMotion> rightMotions) { final DateTime leftStart = TrackerMotionTimeSeries.alignedStartTime(leftMotions); final DateTime rightStart = TrackerMotionTimeSeries.alignedStartTime(rightMotions); final DateTime leftEnd = TrackerMotionTimeSeries.alignedEndTime(leftMotions); final DateTime rightEnd = TrackerMotionTimeSeries.alignedEndTime(rightMotions); final DateTime start; if (leftStart.isBefore(rightStart)) { start = leftStart; } else { start = rightStart; } final DateTime end; if (leftEnd.isAfter(rightEnd)) { end = leftEnd; } else { end = rightEnd; } final TrackerMotionTimeSeries leftTimeSeries = TrackerMotionTimeSeries.create(leftMotions, start, end); final TrackerMotionTimeSeries rightTimeSeries = TrackerMotionTimeSeries.create(rightMotions, start, end); return new PartnerMotionTimeSeries(leftTimeSeries, rightTimeSeries); }

Target:
public static PartnerMotionTimeSeries create(final List<TrackerMotion> leftMotions, final List<TrackerMotion> rightMotions) { final DateTime leftStart = TrackerMotionTimeSeries.alignedStartTime(leftMotions); final DateTime rightStart = TrackerMotionTimeSeries.alignedStartTime(rightMotions); final DateTime leftEnd = TrackerMotionTimeSeries.alignedEndTime(leftMotions); final DateTime rightEnd = TrackerMotionTimeSeries.alignedEndTime(rightMotions); final DateTime start = leftStart.isBefore(rightStart) ? leftStart : rightStart; final DateTime end = leftEnd.isAfter(rightEnd) ? leftEnd : rightEnd; final TrackerMotionTimeSeries leftTimeSeries = TrackerMotionTimeSeries.create(leftMotions, start, end); final TrackerMotionTimeSeries rightTimeSeries = TrackerMotionTimeSeries.create(rightMotions, start, end); return new PartnerMotionTimeSeries(leftTimeSeries, rightTimeSeries); }
Source:
private Object createPropertyValueFromString(final String value) { if (mostRecentlyCreatedProperty == null) { return new LayoutOptionProxy(value); } else { return mostRecentlyCreatedProperty.parseValue(value); } }

Target:
private Object createPropertyValueFromString(final String value) { return new LayoutOptionProxy(value); }
Source:
public Mapper process(ProcessorContext context, TypeElement mapperTypeElement, Mapper mapper) { this.typeFactory = context.getTypeFactory(); String componentModel = MapperConfiguration.getInstanceOn( mapperTypeElement ).componentModel( context.getOptions() ); if ( !getComponentModelIdentifier().equalsIgnoreCase( componentModel ) ) { return mapper; } for ( Annotation typeAnnotation : getTypeAnnotations( mapper ) ) { mapper.addAnnotation( typeAnnotation ); } if ( !requiresGenerationOfDecoratorClass() ) { mapper.removeDecorator(); } else if ( mapper.getDecorator() != null ) { adjustDecorator( mapper ); } List<Annotation> annotations = getMapperReferenceAnnotations(); List<MapperReference> referencedMappers = mapper.getReferencedMappers(); ListIterator<MapperReference> iterator = mapper.getReferencedMappers().listIterator(); while ( iterator.hasNext() ) { MapperReference reference = iterator.next(); iterator.remove(); iterator.add( replacementMapperReference( reference, annotations ) ); } Decorator decorator = mapper.getDecorator(); if ( !referencedMappers.isEmpty() || decorator != null ) { AnnotatedConstructor annotatedConstructor = buildAnnotatedConstructorForMapper( mapper ); if ( !annotatedConstructor.getMapperReferences().isEmpty() ) { mapper.setConstructor( annotatedConstructor ); } if ( decorator != null ) { AnnotatedConstructor decoratorConstructor = buildAnnotatedConstructorForDecorator( decorator ); if ( !decoratorConstructor.getMapperReferences().isEmpty() ) { decorator.setConstructor( decoratorConstructor ); } } } return mapper; }

Target:
public Mapper process(ProcessorContext context, TypeElement mapperTypeElement, Mapper mapper) { this.typeFactory = context.getTypeFactory(); MapperConfiguration mapperConfiguration = MapperConfiguration.getInstanceOn( mapperTypeElement ); String componentModel = mapperConfiguration.componentModel( context.getOptions() ); InjectionStrategyPrism injectionStrategy = mapperConfiguration.getInjectionStrategy(); if ( !getComponentModelIdentifier().equalsIgnoreCase( componentModel ) ) { return mapper; } for ( Annotation typeAnnotation : getTypeAnnotations( mapper ) ) { mapper.addAnnotation( typeAnnotation ); } if ( !requiresGenerationOfDecoratorClass() ) { mapper.removeDecorator(); } else if ( mapper.getDecorator() != null ) { adjustDecorator( mapper, injectionStrategy ); } List<Annotation> annotations = getMapperReferenceAnnotations(); ListIterator<MapperReference> iterator = mapper.getReferencedMappers().listIterator(); while ( iterator.hasNext() ) { MapperReference reference = iterator.next(); iterator.remove(); iterator.add( replacementMapperReference( reference, annotations, injectionStrategy ) ); } if ( injectionStrategy == InjectionStrategyPrism.CONSTRUCTOR ) { buildConstructors( mapper ); } return mapper; }
Source:
public void copyValues() { if (batchSize == 0) { return; } verify(decodedBlock != null); int[] positions = getPositions(); verify(positionsOffset + batchSize - 1 < positions.length && positions[positionsOffset] >= 0 && positions[positionsOffset + batchSize - 1] < decodedBlock.getPositionCount()); appendValuesToBuffer(); appendNulls(); bufferedPositionCount += batchSize; }

Target:
public void copyValues() { if (batchSize == 0) { return; } appendValuesToBuffer(); appendNulls(); bufferedPositionCount += batchSize; }
Source:
public PullFromServerException(List<FormStatus> forms, Throwable cause) { super("Failure pulling forms from server. FormIds: " + forms.stream().map(f -> f.getFormDefinition().getFormId()).collect(joining(", ")), cause); }

Target:
PullFromServerException(List<FormStatus> forms, Throwable cause) { super(buildMessage(forms), cause); }
Source:
public int size() { return this.getAllEvents().size(); }

Target:
public int size() { return primaryKeyData.size(); }
Source:
public String getBody() { return body == null ? null : Ascii.truncate(body, 20000, "..."); }

Target:
public String getBody() { return body == null ? null : Ascii.truncate(body, GithubIssueClient.REPORT_BODY_MAX_LENGTH, "..."); }
Source:
public void testAggregateRealm() throws Exception { KernelServices services = super.createKernelServicesBuilder(new TestEnvironment()).setSubsystemXmlResource("realms-test.xml").build(); if (!services.isSuccessfulBoot()) { Assert.fail(services.getBootError().toString()); } ServiceName serviceName = Capabilities.SECURITY_REALM_RUNTIME_CAPABILITY.getCapabilityServiceName("AggregateRealm"); SecurityRealm securityRealm = (SecurityRealm) services.getContainer().getService(serviceName).getValue(); Assert.assertNotNull(securityRealm); }

Target:
public void testAggregateRealm() throws Exception { KernelServices services = super.createKernelServicesBuilder(new TestEnvironment()).setSubsystemXmlResource("realms-test.xml").build(); if (!services.isSuccessfulBoot()) { Assert.fail(services.getBootError().toString()); } ServiceName serviceName = Capabilities.SECURITY_REALM_RUNTIME_CAPABILITY.getCapabilityServiceName("AggregateRealmOne"); SecurityRealm securityRealm = (SecurityRealm) services.getContainer().getService(serviceName).getValue(); Assert.assertNotNull(securityRealm); RealmIdentity identity1 = securityRealm.getRealmIdentity(fromName("firstUser")); Assert.assertTrue(identity1.exists()); Assert.assertEquals(3, identity1.getAuthorizationIdentity().getAttributes().size()); Assert.assertEquals("[Jane]", identity1.getAuthorizationIdentity().getAttributes().get("firstName").toString()); Assert.assertEquals("[Doe]", identity1.getAuthorizationIdentity().getAttributes().get("lastName").toString()); Assert.assertEquals("[Employee, Manager, Admin]", identity1.getAuthorizationIdentity().getAttributes().get("roles").toString()); identity1.dispose(); }
Source:
public Page getOutput() { if (probe == null && pageBuilder.isEmpty()) { return null; } checkState(lookupSourceProvider != null, "Input has been accepted before lookup source provided"); try (LookupSourceProvider.LookupSourceLease lookupSourceLease = lookupSourceProvider.leaseLookupSource()) { return getOutput(lookupSourceLease.getLookupSource()); } }

Target:
public Page getOutput() { if (!spillInProgress.isDone()) { return null; } checkSuccess(spillInProgress, "spilling failed"); if (probe == null && pageBuilder.isEmpty() && !finishing) { return null; } if (!tryFetchLookupSourceProvider()) { return null; } if (probe == null && finishing && !unspilling) { verify(partitionedConsumption == null, "partitioned consumption already started"); partitionedConsumption = lookupSourceFactory.finishProbeOperator(lookupJoinsCount); unspilling = true; } if (probe == null && unspilling && !finished) { tryUnspillNext(); } if (probe != null) { processProbe(); } if (pageBuilder.isFull() || (!pageBuilder.isEmpty() && probe == null && finished)) { Page page = pageBuilder.build(); pageBuilder.reset(); return page; } return null; }
Source:
public ExprEval apply(List<Expr> args, Expr.ObjectBinding bindings) { if (args.size() == 0) { return ExprEval.of(null); } else { final StringBuilder builder = new StringBuilder(Strings.nullToEmpty(args.get(0).eval(bindings).asString())); for (int i = 1; i < args.size(); i++) { final String s = args.get(i).eval(bindings).asString(); if (s != null) { builder.append(s); } else { return ExprEval.of(null); } } return ExprEval.of(builder.toString()); } }

Target:
public ExprEval apply(List<Expr> args, Expr.ObjectBinding bindings) { if (args.size() == 0) { return ExprEval.of(null); } else { String first = NullHandling.nullToEmptyIfNeeded(args.get(0).eval(bindings).asString()); if (first == null) { return ExprEval.of(null); } final StringBuilder builder = new StringBuilder(first); for (int i = 1; i < args.size(); i++) { final String s = NullHandling.nullToEmptyIfNeeded(args.get(i).eval(bindings).asString()); if (s == null) { return ExprEval.of(null); } else { builder.append(s); } } return ExprEval.of(builder.toString()); } }
Source:
public void testBinaryDictionaryFallBack() throws IOException { int slabSize = 100; int maxDictionaryByteSize = 50; final ValuesWriter cw = newPlainBinaryDictionaryValuesWriter(maxDictionaryByteSize, slabSize); int fallBackThreshold = maxDictionaryByteSize; int dataSize=0; for (long i = 0; i < 100; i++) { Binary binary = Binary.fromString("str" + i); cw.writeBytes(binary); dataSize += (binary.length() + 4); if (dataSize < fallBackThreshold) { assertEquals(PLAIN_DICTIONARY, cw.getEncoding()); } else { assertEquals(PLAIN, cw.getEncoding()); } } ValuesReader reader = new BinaryPlainValuesReader(); reader.initFromPage(100, cw.getBytes().toByteBuffer(), 0); for (long i = 0; i < 100; i++) { assertEquals(Binary.fromString("str" + i).toStringUsingUTF8(), reader.readBytes().toStringUsingUTF8()); } cw.reset(); assertEquals(0, cw.getBufferedSize()); }

Target:
public void testBinaryDictionaryFallBack() throws IOException { int slabSize = 100; int maxDictionaryByteSize = 50; final ValuesWriter cw = newPlainBinaryDictionaryValuesWriter(maxDictionaryByteSize, slabSize); int fallBackThreshold = maxDictionaryByteSize; int dataSize=0; for (long i = 0; i < 100; i++) { Binary binary = Binary.fromString("str" + i); cw.writeBytes(binary); dataSize += (binary.length() + 4); if (dataSize < fallBackThreshold) { assertEquals(PLAIN_DICTIONARY, cw.getEncoding()); } else { assertEquals(PLAIN, cw.getEncoding()); } } ValuesReader reader = new BinaryPlainValuesReader(); reader.initFromPage(100, cw.getBytes().toByteBuffer(), 0); for (long i = 0; i < 100; i++) { assertEquals(Binary.fromString("str" + i), reader.readBytes()); } cw.reset(); assertEquals(0, cw.getBufferedSize()); }
Source:
private void addSourceDirs(IClasspathDescriptor classpath, IProject project, List<String> sourceRoots, IPath outputPath, IPath[] inclusion, IPath[] exclusion, String sourceEncoding, IProgressMonitor monitor, boolean isTest) throws CoreException { for(int i = 0; i < sourceRoots.size(); i++ ) { IFolder sourceFolder = getFolder(project, sourceRoots.get(i)); if(sourceFolder == null) { continue; } sourceFolder.refreshLocal(IResource.DEPTH_ZERO, monitor); if(sourceFolder.exists() && !sourceFolder.getProject().equals(project)) { continue; } if(sourceFolder.exists()) { sourceFolder.setDefaultCharset(sourceEncoding, monitor); } IClasspathEntryDescriptor enclosing = getEnclosingEntryDescriptor(classpath, sourceFolder.getFullPath()); if(enclosing == null || getEntryDescriptor(classpath, sourceFolder.getFullPath()) != null) { log.info("Adding source folder " + sourceFolder.getFullPath()); IClasspathEntryDescriptor descriptor = classpath.addSourceEntry(sourceFolder.getFullPath(), outputPath, inclusion, exclusion, true ); if(isTest) { descriptor.setClasspathAttribute(IClasspathEntryDescriptor.ATTRIBUTENAME_TEST, IClasspathEntryDescriptor.ATTRIBUTEVALUE_TRUE); } } else { log.info("Not adding source folder " + sourceFolder.getFullPath() + " because it overlaps with " + enclosing.getPath()); } } }

Target:
private void addSourceDirs(IClasspathDescriptor classpath, IProject project, List<String> sourceRoots, IPath outputPath, IPath[] inclusion, IPath[] exclusion, String sourceEncoding, IProgressMonitor monitor, boolean isTest) throws CoreException { for(int i = 0; i < sourceRoots.size(); i++ ) { IFolder sourceFolder = getFolder(project, sourceRoots.get(i)); if(sourceFolder == null) { continue; } sourceFolder.refreshLocal(IResource.DEPTH_ZERO, monitor); if(sourceFolder.exists() && !sourceFolder.getProject().equals(project)) { continue; } if(sourceFolder.exists()) { sourceFolder.setDefaultCharset(sourceEncoding, monitor); } IClasspathEntryDescriptor enclosing = getEnclosingEntryDescriptor(classpath, sourceFolder.getFullPath()); if(enclosing == null || getEntryDescriptor(classpath, sourceFolder.getFullPath()) != null) { log.info("Adding source folder " + sourceFolder.getFullPath()); IClasspathEntryDescriptor descriptor = classpath.addSourceEntry(sourceFolder.getFullPath(), outputPath, inclusion, exclusion, true ); descriptor.setClasspathAttribute(IClasspathManager.TEST_ATTRIBUTE, isTest ? "true" : null); } else { log.info("Not adding source folder " + sourceFolder.getFullPath() + " because it overlaps with " + enclosing.getPath()); } } }
Source:
private IncomingPhoneNumber getIncomingPhoneNumber(final String selector, Object parameter) { final SqlSession session = sessions.openSession(); String inboundPhoneNumber = null; try { final Map<String, Object> result = session.selectOne(namespace + selector, parameter); if (result != null ) { return toIncomingPhoneNumber(result); } if(!(parameter instanceof Sid)){ inboundPhoneNumber = parameter.toString().replace("+1", ""); logger.warn(" Inbound phoneNumber : " + inboundPhoneNumber ); return checkIncomingPhoneNumberRegexMatch(selector, inboundPhoneNumber); } }finally { session.close(); } return null; }

Target:
private IncomingPhoneNumber getIncomingPhoneNumber(final String selector, Object parameter) { final SqlSession session = sessions.openSession(); String inboundPhoneNumber = null; try { final Map<String, Object> result = session.selectOne(namespace + selector, parameter); if (result != null ) { return toIncomingPhoneNumber(result); } if(!(parameter instanceof Sid)){ if (logger.isInfoEnabled()) { logger.info("About to check for REGEX incoming phone number for phoneNumber : " + inboundPhoneNumber); } return checkIncomingPhoneNumberRegexMatch(selector, inboundPhoneNumber); } }finally { session.close(); } return null; }
Source:
public List<NoteInfo> list(AuthenticationInfo subject) throws IOException { List<NoteInfo> noteInfos = new ArrayList<>(); for (FileStatus status : fs.globStatus(new Path(notebookDir, "*/note.json"))) { NoteInfo noteInfo = new NoteInfo(status.getPath().getParent().getName(), "", null); noteInfos.add(noteInfo); } return noteInfos; }

Target:
public List<NoteInfo> list(AuthenticationInfo subject) throws IOException { return callHdfsOperation(new HdfsOperation<List<NoteInfo>>() { @Override public List<NoteInfo> call() throws IOException { List<NoteInfo> noteInfos = new ArrayList<>(); for (FileStatus status : fs.globStatus(new Path(notebookDir, "*/note.json"))) { NoteInfo noteInfo = new NoteInfo(status.getPath().getParent().getName(), "", null); noteInfos.add(noteInfo); } return noteInfos; } }); }
Source:
public NettyServerDeployer(NettyConfig nettyConfig, NettyMetrics nettyMetrics, RestRequestHandlerController requestHandlerController) { this.nettyConfig = nettyConfig; this.nettyMetrics = nettyMetrics; this.requestHandlerController = requestHandlerController; bossGroup = new NioEventLoopGroup(nettyConfig.getBossThreadCount()); workerGroup = new NioEventLoopGroup(nettyConfig.getWorkerThreadCount()); }

Target:
public NettyServerDeployer(NettyConfig nettyConfig, NettyMetrics nettyMetrics, RestRequestHandlerController requestHandlerController) { this.nettyConfig = nettyConfig; this.nettyMetrics = nettyMetrics; this.requestHandlerController = requestHandlerController; bossGroup = new NioEventLoopGroup(nettyConfig.nettyServerBossThreadCount); workerGroup = new NioEventLoopGroup(nettyConfig.nettyServerWorkerThreadCount); }
Source:
private String getInstituteForInstructor(Instructor instructor, List<Account> allAccounts) { if (instructor.getGoogleId() == null) { return null; } String googleId = instructor.getGoogleId(); for (Account account : allAccounts) { if (account.getGoogleId() == googleId && account.getInstitute() != null) { return account.getInstitute(); } } return null; }

Target:
private String getInstituteForInstructor(Instructor instructor, List<Account> allAccounts) { if (instructor.getGoogleId() == null) { return null; } return getInstituteFromGoogleId(instructor.getGoogleId(), allAccounts); }
Source:
public Vertex convertToVertex(final Graph graph, final String vertexName) { return graphProvider.traversal(graph).V().has("name", vertexName).toList().get(0); }

Target:
public Vertex convertToVertex(final Graph graph, final String vertexName) { return graph.traversal().V().has("name", vertexName).toList().get(0); }
Source:
private boolean illegalForRest(String v) { return v.contains(",") || v.contains("="); }

Target:
private boolean illegalForRest(String v) { if (StringUtils.isNotEmpty(v)) { return v.contains(",") || v.contains("="); } return false; }
Source:
private String getIdentifiersFromRequest(ProvideAndRegisterDocumentSetRequestType request) { String result = ""; if (request == null) { LOG.error("Incoming ProvideAndRegisterDocumentSetRequestType was null"); return null; } if (request.getSubmitObjectsRequest() == null) { LOG.error("Incoming ProvideAndRegisterDocumentSetRequestType metadata was null"); return null; } LOG.debug(request.getSubmitObjectsRequest().getRegistryObjectList().getIdentifiable()); RegistryObjectListType object = request.getSubmitObjectsRequest().getRegistryObjectList(); for (int x = 0; x < object.getIdentifiable().size(); x++) { LOG.debug(object.getIdentifiable().get(x).getName()); if (object.getIdentifiable().get(x).getDeclaredType().equals(RegistryPackageType.class)) { RegistryPackageType registryPackage = (RegistryPackageType) object.getIdentifiable().get(x).getValue(); LOG.debug(registryPackage.getSlot().size()); for (int y = 0; y < registryPackage.getExternalIdentifier().size(); y++) { String test = registryPackage.getExternalIdentifier().get(y).getName().getLocalizedString().get(0) .getValue(); if (test.equals("XDSSubmissionSet.patientId")) { result = registryPackage.getExternalIdentifier().get(y).getValue(); } } } } return result; }

Target:
private String getIdentifiersFromRequest(ProvideAndRegisterDocumentSetRequestType request) { String result = ""; if (request == null) { LOG.error("Incoming ProvideAndRegisterDocumentSetRequestType was null"); return null; } if (request.getSubmitObjectsRequest() == null) { LOG.error("Incoming ProvideAndRegisterDocumentSetRequestType metadata was null"); return null; } LOG.debug("List of All Identifiable Registry Object(s) on Identifiers Form Request {}", request.getSubmitObjectsRequest().getRegistryObjectList().getIdentifiable()); RegistryObjectListType object = request.getSubmitObjectsRequest().getRegistryObjectList(); for (int x = 0; x < object.getIdentifiable().size(); x++) { LOG.debug("Name of Identifiable Registry Object on Identifiers Form Request {}", object.getIdentifiable().get(x).getName()); if (object.getIdentifiable().get(x).getDeclaredType().equals(RegistryPackageType.class)) { RegistryPackageType registryPackage = (RegistryPackageType) object.getIdentifiable().get(x).getValue(); LOG.debug("Slot(s) in registry Package is {}", registryPackage.getSlot().size()); for (int y = 0; y < registryPackage.getExternalIdentifier().size(); y++) { String test = registryPackage.getExternalIdentifier().get(y).getName().getLocalizedString().get(0) .getValue(); if (test.equals("XDSSubmissionSet.patientId")) { result = registryPackage.getExternalIdentifier().get(y).getValue(); } } } } return result; }
Source:
public void save(BrixNode node) { node.setProperty("email", configuration.getEmail()); node.setProperty("feedbackEmailLabel", configuration.getFeedbackEmailLabel()); node.setProperty("feedbackMessageLabel", configuration.getFeedbackMessageLabel()); node.setProperty("feedbackSubmittedMessage", configuration.getFeedbackSubmittedMessage()); }

Target:
public void save(BrixNode node) { configuration.save(node); }
Source:
public void markRequestException(Exception e) { String errorMessage = e.getMessage().replaceAll(REGEX, "."); metricsRegistry.meter(errorNamespace(metricNamespace, e, errorMessage)).mark(); }

Target:
public void markRequestException(Exception e) { metricsRegistry.meter(errorNamespace(metricNamespace, e, null)).mark(); }
Source:
public static <K, V> List<Pair<K, V>> zip( final List<? extends K> ks, final List<? extends V> vs, boolean strict) { final int size; if (strict) { if (ks.size() != vs.size()) { throw new IllegalArgumentException( "The size of two lists to be combined is required to be equal."); } size = ks.size(); } else { size = Math.min(ks.size(), vs.size()); } return new ZipList<>(ks, vs, size); }

Target:
public static <K, V> List<Pair<K, V>> zip( final List<? extends K> ks, final List<? extends V> vs, boolean strict) { final int kSize = ks.size(); final int vSize = vs.size(); final int size; if (strict) { if (kSize != vSize) { throw new IllegalArgumentException( "The size of two lists to be combined is required to be equal. " + "The size of the first list is " + kSize + ", while the size of the second list is " + vSize + "."); } size = kSize; } else { size = Math.min(kSize, vSize); } return new ZipList<>(ks, vs, size); }
Source:
public static boolean highIODevice( Path pathOnDevice, boolean defaultHunch ) { if ( SystemUtils.IS_OS_MAC ) { return true; } if ( SystemUtils.IS_OS_LINUX ) { try { FileStore fileStore = Files.getFileStore( pathOnDevice ); String name = fileStore.name(); if ( name.equals( "tmpfs" ) || name.equals( "hugetlbfs" ) ) { return true; } if ( name.startsWith( "/dev/nvme" ) ) { return true; } Path device = Paths.get( name ).toRealPath(); Path deviceName = device.getName( device.getNameCount() - 1 ); Path sysblock = Paths.get( "/sys/block" ); Path rotational = sysblock.resolve( deviceName ).resolve( "queue" ).resolve( "rotational" ); if ( Files.exists( rotational ) ) { return readFirstCharacter( rotational ) == '0'; } else { String namePart = deviceName.toString(); int len = namePart.length(); while ( Character.isDigit( namePart.charAt( len - 1 ) ) ) { len--; } namePart = namePart.substring( 0, len ); rotational = sysblock.resolve( namePart ).resolve( "queue" ).resolve( "rotational" ); if ( Files.exists( rotational ) ) { return readFirstCharacter( rotational ) == '0'; } } } catch ( Exception e ) { return defaultHunch; } } return defaultHunch; }

Target:
public static boolean highIODevice( Path pathOnDevice, boolean defaultHunch ) { if ( SystemUtils.IS_OS_MAC ) { return true; } if ( SystemUtils.IS_OS_LINUX ) { try { FileStore fileStore = Files.getFileStore( pathOnDevice ); String name = fileStore.name(); if ( name.equals( "tmpfs" ) || name.equals( "hugetlbfs" ) ) { return true; } if ( name.startsWith( "/dev/nvme" ) ) { return true; } Path device = Paths.get( name ).toRealPath(); Path deviceName = device.getName( device.getNameCount() - 1 ); Path rotational = rotationalPathFor( deviceName ); if ( Files.exists( rotational ) ) { return readFirstCharacter( rotational ) == '0'; } else { String namePart = deviceName.toString(); int len = namePart.length(); while ( Character.isDigit( namePart.charAt( len - 1 ) ) ) { len--; } deviceName = Paths.get( namePart.substring( 0, len ) ); rotational = rotationalPathFor( deviceName ); if ( Files.exists( rotational ) ) { return readFirstCharacter( rotational ) == '0'; } } } catch ( Exception e ) { return defaultHunch; } } return defaultHunch; }
Source:
private static String getEnumOptions(Attribute attr) { return attr.getEnumOptions() != null ? StringUtils.join(attr.getEnumOptions(), ",") : ""; }

Target:
private static String getEnumOptions(Attribute attr) { return attr.getEnumOptions() != null ? String.join(",", attr.getEnumOptions()) : ""; }
Source:
private boolean allReadyCoupledWithOtherDevice(final SmartMeter coupledDevice, final MbusChannelElementsResponseDto mbusChannelElementsResponseDto) { final int channel = mbusChannelElementsResponseDto.getChannel(); return channel == coupledDevice.getChannel(); }

Target:
private boolean allReadyCoupledWithOtherDevice(final SmartMeter coupledDevice, final MbusChannelElementsResponseDto mbusChannelElementsResponseDto) { final Short channel = mbusChannelElementsResponseDto.getChannel(); return channel != null && channel.equals(coupledDevice.getChannel()); }