auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
public void setBadAttachmentsTest() throws Exception { MutableDocumentRevision rev_1Mut = new MutableDocumentRevision(); rev_1Mut.body = bodyOne; BasicDocumentRevision rev_1 = datastore.createDocumentFromRevision(rev_1Mut); Attachment att1 = new UnsavedFileAttachment(TestUtils.loadFixture("fixture/attachment_1.txt"), "text/plain"); Attachment att2 = new UnsavedFileAttachment(TestUtils.loadFixture("fixture/nonexistentfile"), "text/plain"); Attachment att3 = new UnsavedFileAttachment(TestUtils.loadFixture("fixture/attachment_2.txt"), "text/plain"); BasicDocumentRevision newRevision = null; try { MutableDocumentRevision rev1_mut = rev_1.mutableCopy(); rev1_mut.attachments.put(att1.name, att1); rev1_mut.attachments.put(att2.name, att2); rev1_mut.attachments.put(att3.name, att3); newRevision = datastore.updateDocumentFromRevision(rev1_mut); Assert.fail("FileNotFoundException not thrown"); } catch (AttachmentException fnfe) { datastore.runOnDbQueue(new SQLQueueCallable<Object>() { @Override public Object call(SQLDatabase db) throws Exception { Cursor c1 = db.rawQuery("select sequence from attachments;", null); Assert.assertEquals("Attachments table not empty", c1.getCount(), 0); Cursor c2 = db.rawQuery("select sequence from revs;", null); Assert.assertEquals("Revs table not empty", c2.getCount(), 1); return null; } }).get(); } }

Target:
public void setBadAttachmentsTest() throws Exception { MutableDocumentRevision rev_1Mut = new MutableDocumentRevision(); rev_1Mut.body = bodyOne; BasicDocumentRevision rev_1 = datastore.createDocumentFromRevision(rev_1Mut); Attachment att1 = new UnsavedFileAttachment(TestUtils.loadFixture("fixture/attachment_1.txt"), "text/plain"); Attachment att2 = new UnsavedFileAttachment(TestUtils.loadFixture("fixture/nonexistentfile"), "text/plain"); Attachment att3 = new UnsavedFileAttachment(TestUtils.loadFixture("fixture/attachment_2.txt"), "text/plain"); BasicDocumentRevision newRevision = null; try { MutableDocumentRevision rev1_mut = rev_1.mutableCopy(); rev1_mut.attachments.put(att1.name, att1); rev1_mut.attachments.put(att2.name, att2); rev1_mut.attachments.put(att3.name, att3); newRevision = datastore.updateDocumentFromRevision(rev1_mut); Assert.fail("FileNotFoundException not thrown"); } catch (AttachmentException ae) { datastore.runOnDbQueue(new SQLQueueCallable<Object>() { @Override public Object call(SQLDatabase db) throws Exception { Cursor c1 = db.rawQuery("select sequence from attachments;", null); Assert.assertEquals("Attachments table not empty", c1.getCount(), 0); Cursor c2 = db.rawQuery("select sequence from revs;", null); Assert.assertEquals("Revs table not empty", c2.getCount(), 1); return null; } }).get(); } }
Source:
public void initialize() { this.projectInfo = this.libraryPlaces.getProjectInfo(); this.view.init(this); this.buildExecutor.init(this.view); this.view.setTitle(libraryPlaces.getProjectInfo().getProject().getProjectName()); this.view.setContributorsCount(this.contributorsListScreen.getContributorsCount()); this.resolveAssetsCount(); this.showAssets(); newFileUploader.acceptContext(new Callback<Boolean, Void>() { @Override public void onFailure(Void reason) { } @Override public void onSuccess(Boolean result) { view.enableImportButton(); } }); }

Target:
public void initialize() { this.workspaceProject = this.libraryPlaces.getActiveWorkspaceContext(); this.view.init(this); this.buildExecutor.init(this.view); this.view.setTitle(libraryPlaces.getActiveWorkspaceContext().getMainModule().getModuleName()); this.resolveContributorsCount(); this.resolveAssetsCount(); this.showAssets(); this.view.setEditContributorsVisible(this.canEditContributors()); this.view.setAddAssetVisible(this.userCanUpdateProject()); this.view.setImportAssetVisible(this.userCanUpdateProject()); this.view.setImportAssetVisible(this.userCanUpdateProject()); this.view.setBuildEnabled(this.userCanBuildProject()); this.view.setDeployEnabled(this.userCanBuildProject()); this.view.setDeleteProjectVisible(this.userCanDeleteRepository()); newFileUploader.acceptContext(new Callback<Boolean, Void>() { @Override public void onFailure(Void reason) { view.setImportAssetVisible(false); } @Override public void onSuccess(Boolean result) { view.setImportAssetVisible(result); } }); }
Source:
public static void main(String[] args) { if (args.length < 2) { System.out.println("Please specify your access key and a voice call flow ID"); return; } final MessageBirdService wsr = new MessageBirdServiceImpl(args[0]); final MessageBirdClient messageBirdClient = new MessageBirdClient(wsr); try { System.out.println("Requesting a Voice Call Flow"); VoiceCallFlow voiceCallFlow = messageBirdClient .viewVoiceCallFlow(args[1]); System.out.println("Voice call flow retrieved "); } catch (GeneralException | UnauthorizedException exception) { exception.printStackTrace(); } }

Target:
public static void main(String[] args) { if (args.length < 2) { System.out.println("Please specify your access key and a voice call flow ID"); return; } final MessageBirdService wsr = new MessageBirdServiceImpl(args[0]); final MessageBirdClient messageBirdClient = new MessageBirdClient(wsr); try { System.out.println("Requesting a Voice Call Flow"); VoiceCallFlowResponse voiceCallFlowResponse = messageBirdClient .viewVoiceCallFlow(args[1]); System.out.println("Voice call flow retrieved "); } catch (GeneralException | UnauthorizedException | NotFoundException exception) { exception.printStackTrace(); } }
Source:
public void serviceChanged(ServiceEvent serviceEvent) { if (serviceEvent.getType() == ServiceEvent.REGISTERED) { BundleContext context = getContext(); if (context == null) { return; } try { ServiceReference<ConfigurationAdmin> configAdminRef = context.getServiceReference(ConfigurationAdmin.class); ConfigurationAdmin configAdmin = context.getService(configAdminRef); Configuration config = configAdmin.getConfiguration(ApplicationServiceImpl.class.getName()); Dictionary<String, Object> properties = config.getProperties(); LOGGER.debug("Checking the configuration file on the first run."); ApplicationConfigInstaller configInstaller = new ApplicationConfigInstaller( configFileName, this, featuresService, POST_CONFIG_START, POST_CONFIG_STOP); configInstaller.start(); config.update(properties); } catch (Exception e) { LOGGER.warn("Could not check for installer application configuration file.", e); } finally { context.removeServiceListener(this); } } }

Target:
public void serviceChanged(ServiceEvent serviceEvent) { if (serviceEvent.getType() == ServiceEvent.REGISTERED) { BundleContext context = getContext(); try { ServiceReference<ConfigurationAdmin> configAdminRef = context.getServiceReference(ConfigurationAdmin.class); ConfigurationAdmin configAdmin = context.getService(configAdminRef); Configuration config = configAdmin.getConfiguration(ApplicationServiceImpl.class.getName()); Dictionary<String, Object> properties = config.getProperties(); LOGGER.debug("Checking the configuration file on the first run."); ApplicationConfigInstaller configInstaller = new ApplicationConfigInstaller( configFileName, this, featuresService, POST_CONFIG_START, POST_CONFIG_STOP); configInstaller.start(); config.update(properties); } catch (Exception e) { LOGGER.warn("Could not check for installer application configuration file.", e); } finally { context.removeServiceListener(this); } } }
Source:
private static boolean isGetter(Method method) { String name = method.getName(); if (!name.startsWith("get")) return false; if (name.length() == 3) return false; if (name.equals("getClass")) return false; if (void.class.equals(method.getReturnType())) return false; if (method.getParameterTypes().length != 0) return false; return true; }

Target:
private static boolean isGetter(Method method) { String name = method.getName(); if (!name.startsWith("get")) { return false; } if (name.length() == 3) { return false; } if (name.equals("getClass")) { return false; } if (void.class.equals(method.getReturnType())) { return false; } if (method.getParameterTypes().length != 0) { return false; } return true; }
Source:
public GraphQLObjectType(String name, String description, List<GraphQLFieldDefinition> fieldDefinitions, List<GraphQLOutputType> interfaces, ObjectTypeDefinition definition) { assertValidName(name); assertNotNull(fieldDefinitions, "fieldDefinitions can't be null"); assertNotNull(interfaces, "interfaces can't be null"); assertNotNull(interfaces, "unresolvedInterfaces can't be null"); this.name = name; this.description = description; this.interfaces = interfaces; this.definition = definition; buildDefinitionMap(fieldDefinitions); }

Target:
public GraphQLObjectType(String name, String description, List<GraphQLFieldDefinition> fieldDefinitions, List<GraphQLOutputType> interfaces, ObjectTypeDefinition definition) { assertValidName(name); assertNotNull(fieldDefinitions, "fieldDefinitions can't be null"); assertNotNull(interfaces, "interfaces can't be null"); this.name = name; this.description = description; this.interfaces = interfaces; this.definition = definition; buildDefinitionMap(fieldDefinitions); }
Source:
public void trackShowTranscript(String videoId, Double currentTime, String courseId, String unitUrl) { final FirebaseEvent event = new FirebaseEvent(Events.SHOW_TRANSCRIPT, videoId, Values.TRANSCRIPT_SHOWN, currentTime); event.setCourseContext(courseId, unitUrl, Values.VIDEOPLAYER); tracker.logEvent(event.getName(), event.getBundle()); ; }

Target:
public void trackShowTranscript(String videoId, Double currentTime, String courseId, String unitUrl) { final FirebaseEvent event = new FirebaseEvent(Events.SHOW_TRANSCRIPT, videoId, Values.TRANSCRIPT_SHOWN, currentTime); event.setCourseContext(courseId, unitUrl, Values.VIDEOPLAYER); tracker.logEvent(event.getName(), event.getBundle()); }
Source:
public VdcActionParametersBase getParameters(Host incoming, VDS entity) { VdsStatic updated = getMapper(modelType, VdsStatic.class).map(incoming, entity.getStaticData()); UpdateVdsActionParameters updateParams = new UpdateVdsActionParameters(updated, "root", "", false); if (incoming.isSetOverrideIptables()) { updateParams.setOverrideFirewall(incoming.isOverrideIptables()); } return updateParams; }

Target:
public VdcActionParametersBase getParameters(Host incoming, VDS entity) { VdsStatic updated = getMapper(modelType, VdsStatic.class).map(incoming, entity.getStaticData()); UpdateVdsActionParameters updateParams = new UpdateVdsActionParameters(updated, "", false); if (incoming.isSetOverrideIptables()) { updateParams.setOverrideFirewall(incoming.isOverrideIptables()); } return updateParams; }
Source:
public static String getConfiguredHashAlgorithm(Configuration conf) { return conf.get(CRYPTO_KEY_HASH_ALGORITHM_CONF_KEY, CRYPTO_KEY_HASH_ALGORITHM_CONF_DEFAULT).trim(); }

Target:
public static String getConfiguredHashAlgorithm(Configuration conf) { return conf.getTrimmed(CRYPTO_KEY_HASH_ALGORITHM_CONF_KEY, CRYPTO_KEY_HASH_ALGORITHM_CONF_DEFAULT); }
Source:
public void writeToAllNonTxStores(MarshalledEntry marshalledEntry, AccessMode accessMode) { storesMutex.readLock().lock(); try { writers.stream().filter(canPerform(accessMode)).forEach(writer -> writer.write(marshalledEntry)); } finally { storesMutex.readLock().unlock(); } }

Target:
public void writeToAllNonTxStores(MarshalledEntry marshalledEntry, AccessMode accessMode) { storesMutex.readLock().lock(); try { nonTxWriters.stream() .filter(writer -> accessMode.canPerform(configMap.get(writer))) .forEach(writer -> writer.write(marshalledEntry)); } finally { storesMutex.readLock().unlock(); } }
Source:
public boolean isMirroringEnabled() { return fMirroringEnabled; }

Target:
public final boolean isMirroringEnabled() { return fMirroringEnabled; }
Source:
public Builder setAdUiElements(Set<UiElement> adUiElements) { this.adUiElements = Assertions.checkNotNull(adUiElements); return this; }

Target:
public Builder setAdUiElements(Set<UiElement> adUiElements) { this.adUiElements = new HashSet<>(Assertions.checkNotNull(adUiElements)); return this; }
Source:
private static String getProxyType(String protocol) { protocol = protocol.trim().toLowerCase(Locale.ENGLISH); String type; if (protocol != null) { throw new IllegalArgumentException("unknown proxy protocol: " + protocol); } else switch (protocol) { case "http": type = IProxyData.HTTP_PROXY_TYPE; break; case "https": type = IProxyData.HTTPS_PROXY_TYPE; break; case "socks4": case "socks_5": type = IProxyData.SOCKS_PROXY_TYPE; break; default: throw new IllegalArgumentException("unknown proxy protocol: " + protocol); } return type; }

Target:
private static String getProxyType(String protocol) { protocol = protocol.trim().toLowerCase(Locale.ENGLISH); String type; if (protocol == null) { throw new IllegalArgumentException("unknown proxy protocol: " + protocol); } switch (protocol) { case "http": type = IProxyData.HTTP_PROXY_TYPE; break; case "https": type = IProxyData.HTTPS_PROXY_TYPE; break; case "socks4": case "socks_5": type = IProxyData.SOCKS_PROXY_TYPE; break; default: throw new IllegalArgumentException("unknown proxy protocol: " + protocol); } return type; }
Source:
public void stop() { LogManager.d(TAG, "stop called"); mScanningEnabled = false; if (mScanCyclerStarted) { scanLeDevice(false); LogManager.d(TAG, "forcing scanning to stop even for devices capable of multiple detections per cycle"); stopScan(); } else { LogManager.d(TAG, "scanning already stopped"); } }

Target:
public void stop() { LogManager.d(TAG, "stop called"); mScanningEnabled = false; if (mScanCyclerStarted) { scanLeDevice(false); } else { LogManager.d(TAG, "scanning already stopped"); } }
Source:
public Contents toContents() throws RuntimeException { if(isPrefix()) { throw new RuntimeException("Could not create Contents"); } final Contents contents = new Contents(); contents.setETag(eTag); contents.setKey(key); contents.setLastModified(lastModified); contents.setOwner(owner); contents.setSize(size); contents.setStorageClass(storageClass); return contents; }

Target:
public Contents toContents() throws RuntimeException { if (isPrefix()) { throw new UnabledToConvertToContentsException("Could not create a Contents"); } final Contents contents = new Contents(); contents.setETag(eTag); contents.setKey(key); contents.setLastModified(lastModified); contents.setOwner(owner); contents.setSize(size); contents.setStorageClass(storageClass); return contents; }
Source:
public FunctionReference(MethodHandle handle, String[] parameterNames) { if (handle == null) { throw new IllegalArgumentException("A method handle cannot be null"); } this.handle = handle; if (parameterNames != null) { this.parameterNames = Arrays.copyOf(parameterNames, parameterNames.length); } else { this.parameterNames = new String[0]; } }

Target:
public FunctionReference(MethodHandle handle, String[] parameterNames) { if (handle == null) { throw new IllegalArgumentException("A method handle cannot be null"); } this.handle = handle; this.parameterNames = parameterNames; }
Source:
public List<ChannelDef> getChannels() { return channels; }

Target:
public List<ChannelDef> getChannels() { return Collections.unmodifiableList(channels); }
Source:
public static String eval(String toEval) throws CoreException { IEclipsePreferences node = DefaultScope.INSTANCE .getNode(IRPMConstants.RPM_CORE_ID); String rpmCmd = node.get(IRPMConstants.RPM_CMD, ""); List<String> command = new ArrayList<String>(); command.add(rpmCmd); command.add("--eval"); command.add(toEval); IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); ISelection selection = page.getSelection(); if(selection instanceof ITreeSelection){ Object element = ((ITreeSelection)selection).getFirstElement(); if(element instanceof IFile){ IProject project = ((IFile)element).getProject(); if(project.getLocationURI().toString().contains(":")) { try { return Utils.runCommandToString(project, command.toArray(new String[command.size()])); } catch (IOException e) { throw new CoreException(new Status(IStatus.ERROR, IRPMConstants.RPM_CORE_ID, e.getMessage(), e)); } } } } try { return Utils.runCommandToString(command.toArray(new String[command.size()])); } catch (IOException e) { throw new CoreException(new Status(IStatus.ERROR, IRPMConstants.RPM_CORE_ID, e.getMessage(), e)); } }

Target:
public static String eval(String toEval) throws CoreException { IEclipsePreferences node = DefaultScope.INSTANCE .getNode(IRPMConstants.RPM_CORE_ID); String rpmCmd = node.get(IRPMConstants.RPM_CMD, ""); List<String> command = new ArrayList<String>(); command.add(rpmCmd); command.add("--eval"); command.add(toEval); try { return Utils.runCommandToString(command.toArray(new String[command.size()])); } catch (IOException e) { throw new CoreException(new Status(IStatus.ERROR, IRPMConstants.RPM_CORE_ID, e.getMessage(), e)); } }
Source:
public void closedLow(boolean closedLow) { this.closedLow = closedLow == true; }

Target:
public void closedLow(boolean closedLow) { this.closedLow = closedLow; }
Source:
private static long convert(final String capacity, final MemoryUnit designatedUnit) { long number = parseCapacityValue(capacity); MemoryUnit currentUnit = parseCapacityUnit(capacity); long bytes = Math.multiplyExact(number, currentUnit.getFactor()); if ( bytes % designatedUnit.getFactor() == 0L ) { return bytes / designatedUnit.getFactor(); } return 0L; }

Target:
private static long convert(final String capacity, final MemoryUnit designatedUnit) { long number = parseCapacityValue(capacity); MemoryUnit currentUnit = parseCapacityUnit(capacity); long bytes = Math.multiplyExact(number, currentUnit.getFactor()); if ( bytes % designatedUnit.getFactor() == 0L ) { return bytes / designatedUnit.getFactor(); } LOGGER.warn("Could not convert capacity: to unit {}", capacity, designatedUnit); return 0L; }
Source:
public void createGroupInAwsRegion(ComputeServiceContext computeServiceContext, String region) { AWSEC2Api ec2Client = computeServiceContext.unwrapApi(AWSEC2Api.class); String sgId = ec2Client.getSecurityGroupApi().get().createSecurityGroupInRegionAndReturnId("us-east-1", "br-JBoss-appId123-entId123-uid1234-sg", "security group for XXX"); ec2Client.getSecurityGroupApi().get().authorizeSecurityGroupIngressInRegion("us-east-1", sgId, ipPerms); }

Target:
public void createGroupInAwsRegion(ComputeServiceContext computeServiceContext, String region) { AWSEC2Api ec2Client = computeServiceContext.unwrapApi(AWSEC2Api.class); String sgId = ec2Client.getSecurityGroupApi().get().createSecurityGroupInRegionAndReturnId(region, getName(), "Brooklyn-managed security group "+getName()); ec2Client.getSecurityGroupApi().get().authorizeSecurityGroupIngressInRegion(region, sgId, ipPerms); }
Source:
protected void runAutonomous() throws InterruptedException, AutonomousModeOverException { pickupContainer(nudge.get()); DriveCode.octocanumShifting.set(true); strafe(STRAFE_RIGHT, leftStrafeTime.get()); DriveCode.octocanumShifting.set(false); drive(autoZoneDistance.get()); depositContainer(); drive(-autoZoneDistance.get()); }

Target:
protected void runAutonomous() throws InterruptedException, AutonomousModeOverException { pickupContainer(nudge.get()); DriveCode.octocanumShifting.set(true); strafe(STRAFE_LEFT, leftStrafeTime.get()); DriveCode.octocanumShifting.set(false); drive(autoZoneDistance.get()); depositContainer(); drive(-autoZoneDistance.get()); }
Source:
public void testCreateDirectories() throws IOException { Path testBaseDirectoryPath = Paths.get("src/test/resources"); Path firstDirectoryOfTestPath = testBaseDirectoryPath.resolve("several"); if (Files.isDirectory(firstDirectoryOfTestPath)) { TreeDeleter.deltree(firstDirectoryOfTestPath); } String testBaseDirectoryURI = testBaseDirectoryPath.toUri().toString(); String createDirectories = "several/directories/can/be/created/at/once"; new FileService().createDirectories(URI.create(testBaseDirectoryURI + createDirectories)); assertTrue(Files.isDirectory(firstDirectoryOfTestPath.resolve("directories/can/be/created/at/once"))); TreeDeleter.deltree(firstDirectoryOfTestPath); }

Target:
public void testCreateDirectories() throws IOException { ServiceManager.getFileService().createDirectories(URI.create("several/directories/can/be/created/at/once")); assertTrue(ServiceManager.getFileService().isDirectory(URI.create(SEVERAL))); cleanUp(); }
Source:
public void execute() throws FluoCommandException { config(); }

Target:
public void execute() throws FluoCommandException { FluoConfiguration config = getConfig(); CommandUtil.verifyAppInitialized(config); try (FluoAdmin admin = FluoFactory.newAdmin(config)) { for (Map.Entry<String, String> entry : admin.getApplicationConfig().toMap().entrySet()) { System.out.println(entry.getKey() + " = " + entry.getValue()); } } }
Source:
public PigSchemaConverter(boolean columnIndexAccess) { this.columnIndexAccess = columnIndexAccess; }

Target:
public PigSchemaConverter(boolean columnIndexAccess) { this.columnAccess = columnIndexAccess?new ColumnIndexAccess():new ColumnNameAccess(); }
Source:
private static Map<String, Symbol> getModuleSymbols(String moduleName, String categoryPath, Map<String, Set<Symbol>> initialSymbols) { ModuleDescription moduleDescription = getResourceForModule(moduleName, categoryPath); if (moduleDescription == null) { return Collections.emptyMap(); } PythonFile file = new TypeShedPythonFile(moduleDescription.resource, moduleDescription.fileName); AstNode astNode = PythonParser.create().parse(file.content()); FileInput fileInput = new PythonTreeMaker().fileInput(astNode); new SymbolTableBuilder(moduleDescription.packageName, file, initialSymbols).visitFileInput(fileInput); fileInput.accept(new ReturnTypeVisitor()); return fileInput.globalVariables().stream() .map(symbol -> { ((SymbolImpl) symbol).removeUsages(); return symbol; }) .filter(s -> s.fullyQualifiedName() != null && s.fullyQualifiedName().startsWith(moduleName)) .collect(Collectors.toMap(Symbol::fullyQualifiedName, Function.identity())); }

Target:
private static Map<String, Symbol> getModuleSymbols(String moduleName, String categoryPath, Map<String, Set<Symbol>> initialSymbols) { ModuleDescription moduleDescription = getResourceForModule(moduleName, categoryPath); if (moduleDescription == null) { return Collections.emptyMap(); } PythonFile file = new TypeShedPythonFile(moduleDescription.resource, moduleDescription.fileName); AstNode astNode = PythonParser.create().parse(file.content()); FileInput fileInput = new PythonTreeMaker().fileInput(astNode); new SymbolTableBuilder(moduleDescription.packageName, file, ProjectLevelSymbolTable.from(initialSymbols)).visitFileInput(fileInput); fileInput.accept(new ReturnTypeVisitor()); return fileInput.globalVariables().stream() .map(symbol -> { ((SymbolImpl) symbol).removeUsages(); return symbol; }) .filter(s -> s.fullyQualifiedName() != null) .collect(Collectors.toMap(Symbol::fullyQualifiedName, Function.identity(), AmbiguousSymbolImpl::create)); }
Source:
protected IndentLevel getIndentImpl() { if (getParent() instanceof MethodCallHandler) { return getParent().getSuggestedChildIndent(this); } DetailAST parent = getMainAst().getParent(); if (getParent() instanceof NewHandler) { isLambdaCorrectlyIndented = false; parent = parent.getParent(); } IndentLevel level = new IndentLevel(getLineStart(parent)); final DetailAST firstChild = getMainAst().getFirstChild(); if (getLineStart(firstChild) == expandedTabsColumnNo(firstChild)) { level = new IndentLevel(level, getIndentCheck().getLineWrappingIndentation()); } return level; }

Target:
protected IndentLevel getIndentImpl() { if (getParent() instanceof MethodCallHandler) { return getParent().getSuggestedChildIndent(this); } DetailAST parent = getMainAst().getParent(); if (getParent() instanceof NewHandler) { parent = parent.getParent(); } IndentLevel level = new IndentLevel(getLineStart(parent)); final DetailAST firstChild = getMainAst().getFirstChild(); if (getLineStart(firstChild) == expandedTabsColumnNo(firstChild)) { level = new IndentLevel(level, getIndentCheck().getLineWrappingIndentation()); } return level; }
Source:
private TypeSpec getNullSharedTriggers(TypeName sharedTriggersInterfaceType) { TypeSpec.Builder nullSharedTriggersClassBuilder = TypeSpec.classBuilder("NullSharedTriggers") .addModifiers(Modifier.PUBLIC, Modifier.ABSTRACT, Modifier.STATIC) .addSuperinterface(sharedTriggersInterfaceType); for (Entry<String, TableDefinition> entry : definitions.entrySet()) { String name = entry.getKey(); TableDefinition tableDefinition = entry.getValue(); String tableName = getTableName(name); TypeName rowType = ClassName.get(packageName, tableName + "." + name + "Row"); TypeName columnType = ClassName.get(packageName, tableName + "." + name + "ColumnValue"); if (!tableDefinition.toTableMetadata().getColumns().hasDynamicColumns()) { columnType = ParameterizedTypeName.get( ClassName.get(packageName, tableName + "." + name + "NamedColumnValue"), WildcardTypeName.subtypeOf(Object.class)); } MethodSpec putMethod = MethodSpec.methodBuilder("put" + name) .addAnnotation(Override.class) .addModifiers(Modifier.PUBLIC) .addParameter( ParameterizedTypeName.get( ClassName.get(Multimap.class), rowType, WildcardTypeName.subtypeOf(columnType) ), "newRows") .addComment("do nothing") .build(); nullSharedTriggersClassBuilder .addMethod(putMethod); } return nullSharedTriggersClassBuilder.build(); }

Target:
private TypeSpec getNullSharedTriggers(TypeName sharedTriggersInterfaceType) { TypeSpec.Builder nullSharedTriggersClassBuilder = TypeSpec.classBuilder("NullSharedTriggers") .addModifiers(Modifier.PUBLIC, Modifier.ABSTRACT, Modifier.STATIC) .addSuperinterface(sharedTriggersInterfaceType); for (Entry<String, TableDefinition> entry : definitions.entrySet()) { String name = entry.getKey(); TableDefinition tableDefinition = entry.getValue(); String tableName = getTableName(name); ClassName tableType = ClassName.get(packageName, tableName); TypeName rowType = tableType.nestedClass(name + "Row"); TypeName columnType = tableType.nestedClass(name + "ColumnValue"); if (!tableDefinition.toTableMetadata().getColumns().hasDynamicColumns()) { columnType = ParameterizedTypeName.get( ClassName.get(packageName, tableName + "." + name + "NamedColumnValue"), WildcardTypeName.subtypeOf(Object.class)); } MethodSpec putMethod = MethodSpec.methodBuilder("put" + name) .addAnnotation(Override.class) .addModifiers(Modifier.PUBLIC) .addParameter( ParameterizedTypeName.get( ClassName.get(Multimap.class), rowType, WildcardTypeName.subtypeOf(columnType) ), "newRows") .addComment("do nothing") .build(); nullSharedTriggersClassBuilder .addMethod(putMethod); } return nullSharedTriggersClassBuilder.build(); }
Source:
private static Group createGroup(final Composite parent, final String name) { Group group = new Group(parent, SWT.NONE); group.setText(name); GridLayout layout = new GridLayout(1, true); layout.marginHeight = 5; layout.marginWidth = 5; group.setLayout(layout); GridData data = new GridData(SWT.FILL, SWT.FILL, true, true); group.setLayoutData(data); return group; }

Target:
private static Group createGroup(final Composite parent, final String name) { final Group group = new Group(parent, SWT.NONE); group.setText(name); final GridLayout layout = new GridLayout(1, true); layout.marginHeight = 5; layout.marginWidth = 5; group.setLayout(layout); final GridData data = new GridData(SWT.FILL, SWT.FILL, true, true); group.setLayoutData(data); return group; }
Source:
PutManager(ClusterMap clusterMap, ResponseHandler responseHandler, NotificationSystem notificationSystem, RouterConfig routerConfig, NonBlockingRouterMetrics routerMetrics, OperationCompleteCallback operationCompleteCallback, ReadyForPollCallback readyForPollCallback, int index, Time time) { this.clusterMap = clusterMap; this.responseHandler = responseHandler; this.notificationSystem = notificationSystem; this.routerConfig = routerConfig; this.routerMetrics = routerMetrics; this.operationCompleteCallback = operationCompleteCallback; this.readyForPollCallback = readyForPollCallback; this.chunkArrivalListener = new ByteBufferAsyncWritableChannel.ChannelEventListener() { @Override public void onEvent(ByteBufferAsyncWritableChannel.EventType e) { synchronized (chunkFillerSynchronizer) { areChunksAvailableForFilling = true; if (isChunkFillerThreadAsleep) { chunkFillerSynchronizer.notify(); } } } }; this.time = time; putOperations = Collections.newSetFromMap(new ConcurrentHashMap<PutOperation, Boolean>()); correlationIdToPutOperation = new HashMap<Integer, PutOperation>(); chunkFillerThread = Utils.newThread("ChunkFillerThread-" + index, new ChunkFiller(), true); chunkFillerThread.start(); routerMetrics.initializePutManagerMetrics(chunkFillerThread); }

Target:
PutManager(ClusterMap clusterMap, ResponseHandler responseHandler, NotificationSystem notificationSystem, RouterConfig routerConfig, NonBlockingRouterMetrics routerMetrics, OperationCompleteCallback operationCompleteCallback, ReadyForPollCallback readyForPollCallback, int index, Time time) { this.clusterMap = clusterMap; this.responseHandler = responseHandler; this.notificationSystem = notificationSystem; this.routerConfig = routerConfig; this.routerMetrics = routerMetrics; this.operationCompleteCallback = operationCompleteCallback; this.readyForPollCallback = readyForPollCallback; this.chunkArrivalListener = new ByteBufferAsyncWritableChannel.ChannelEventListener() { @Override public void onEvent(ByteBufferAsyncWritableChannel.EventType e) { synchronized (chunkFillerSynchronizer) { chunkFillerThreadMaySleep = false; if (isChunkFillerThreadAsleep) { chunkFillerSynchronizer.notify(); } } } }; this.time = time; putOperations = Collections.newSetFromMap(new ConcurrentHashMap<PutOperation, Boolean>()); correlationIdToPutOperation = new HashMap<Integer, PutOperation>(); chunkFillerThread = Utils.newThread("ChunkFillerThread-" + index, new ChunkFiller(), true); chunkFillerThread.start(); routerMetrics.initializePutManagerMetrics(chunkFillerThread); }
Source:
public ActionResult<ItemStack> onItemRightClick(@Nonnull ItemStack stack, World world, EntityPlayer player, EnumHand hand) { if(ToolHelper.isBroken(stack)) { return ActionResult.newResult(EnumActionResult.FAIL, stack); } RayTraceResult trace = this.rayTrace(world, player, false); if(trace == null || trace.typeOfHit != RayTraceResult.Type.BLOCK) { return ActionResult.newResult(EnumActionResult.PASS, stack); } int fortune = EnchantmentHelper.getEnchantmentLevel(Enchantments.FORTUNE, stack); BlockPos origin = trace.getBlockPos().offset(trace.sideHit); if(!harvestBlock(stack, world, player, origin, fortune)) { return ActionResult.newResult(EnumActionResult.PASS, stack); } for(BlockPos pos : ((IAoeTool) this).getAOEBlocks(stack, player.worldObj, player, origin)) { harvestBlock(stack, world, player, pos, fortune); } player.worldObj.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_PLAYER_ATTACK_SWEEP, player.getSoundCategory(), 1.0F, 1.0F); player.spawnSweepParticles(); return ActionResult.newResult(player.worldObj.isRemote ? EnumActionResult.PASS : EnumActionResult.SUCCESS, stack); }

Target:
public ActionResult<ItemStack> onItemRightClick(@Nonnull ItemStack stack, World world, EntityPlayer player, EnumHand hand) { if(ToolHelper.isBroken(stack)) { return ActionResult.newResult(EnumActionResult.FAIL, stack); } RayTraceResult trace = this.rayTrace(world, player, true); if(trace == null || trace.typeOfHit != RayTraceResult.Type.BLOCK) { return ActionResult.newResult(EnumActionResult.PASS, stack); } int fortune = EnchantmentHelper.getEnchantmentLevel(Enchantments.FORTUNE, stack); BlockPos origin = trace.getBlockPos(); IBlockState state = world.getBlockState(origin); if(!ToolHelper.isToolEffective2(stack, state) || state.getBlockHardness(world, origin) > 0) { return ActionResult.newResult(EnumActionResult.PASS, stack); } for(BlockPos pos : this.getAOEBlocks(stack, player.worldObj, player, origin)) { harvestCrop(stack, world, player, pos, fortune); } harvestCrop(stack, world, player, origin, fortune); player.worldObj.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_PLAYER_ATTACK_SWEEP, player.getSoundCategory(), 1.0F, 1.0F); player.spawnSweepParticles(); return ActionResult.newResult(player.worldObj.isRemote ? EnumActionResult.PASS : EnumActionResult.SUCCESS, stack); }
Source:
public boolean hasColumns() { return !storageFields.isEmpty(); }

Target:
public final boolean hasColumns() { return !storageFields.isEmpty(); }
Source:
public void errorFlowAndRetries() throws Exception { delayHandler.setDefaultDelay(10); delayHandler.setRetryDelay(15); startDelayerHandler(); Message<?> message = MessageBuilder.withPayload("test").build(); final CountDownLatch latch = new CountDownLatch(1); delayHandler.setDelayedMessageErrorChannel((m, t) -> { if (StaticMessageHeaderAccessor.getDeliveryAttempt(m).get() < 4) { throw new RuntimeException("fail"); } latch.countDown(); return true; }); delayHandler.setOutputChannel((m, t) -> { throw new RuntimeException("fail"); }); input.send(message); }

Target:
public void errorFlowAndRetries() throws Exception { delayHandler.setDefaultDelay(10); delayHandler.setRetryDelay(15); startDelayerHandler(); Message<?> message = MessageBuilder.withPayload("test") .setHeader("foo", new AtomicInteger()) .build(); final CountDownLatch latch = new CountDownLatch(1); final AtomicInteger count = new AtomicInteger(); delayHandler.setDelayedMessageErrorChannel((m, t) -> { count.incrementAndGet(); int deliveries = StaticMessageHeaderAccessor.getDeliveryAttempt(m).get(); ((MessagingException) m.getPayload()).getFailedMessage().getHeaders().get("foo", AtomicInteger.class) .incrementAndGet(); if (deliveries < 3) { throw new RuntimeException("fail"); } else if (deliveries == 3) { return false; } else { latch.countDown(); return true; } }); delayHandler.setOutputChannel((m, t) -> { throw new MessagingException(m); }); input.send(message); assertTrue(latch.await(10, TimeUnit.SECONDS)); Thread.sleep(50); assertThat(count.get(), equalTo(4)); assertThat(TestUtils.getPropertyValue(this.delayHandler, "deliveries", Map.class).size(), equalTo(0)); }
Source:
public void testDispatch() throws InterruptedException { DebugPlugin debugPlugin = new DebugPlugin(); StaticPluginLocator<? extends DAGExecutionPlugin> locator = new StaticPluginLocator<>(debugPlugin); ApexPluginDispatcher pluginManager = new DefaultApexPluginDispatcher(locator, new StramTestSupport.TestAppContext(new Attribute.AttributeMap.DefaultAttributeMap()), null, null); pluginManager.init(new Configuration()); pluginManager.dispatch(STRAM_EVENT, new StramEvent(StramEvent.LogLevel.DEBUG) { @Override public String getType() { return "TestEvent"; } }); pluginManager.dispatch(COMMIT_EVENT, new Long(1234)); pluginManager.dispatch(HEARTBEAT, new StreamingContainerUmbilicalProtocol.ContainerHeartbeat()); debugPlugin.waitForEventDelivery(); pluginManager.stop(); Assert.assertEquals(1, debugPlugin.getEventCount()); Assert.assertEquals(1, debugPlugin.getHeartbeatCount()); Assert.assertEquals(1, debugPlugin.getCommitCount()); }

Target:
public void testDispatch() throws InterruptedException { DebugPlugin debugPlugin = new DebugPlugin(); StaticPluginLocator<? extends DAGExecutionPlugin> locator = new StaticPluginLocator<>(debugPlugin); ApexPluginDispatcher pluginManager = new DefaultApexPluginDispatcher(locator, new StramTestSupport.TestAppContext(new Attribute.AttributeMap.DefaultAttributeMap()), null, null); pluginManager.init(new Configuration()); pluginManager.dispatch(STRAM_EVENT, new StramEvent(StramEvent.LogLevel.DEBUG) { @Override public String getType() { return "TestEvent"; } }); pluginManager.dispatch(COMMIT_EVENT, new Long(1234)); pluginManager.dispatch(HEARTBEAT, new StreamingContainerUmbilicalProtocol.ContainerHeartbeat()); debugPlugin.waitForEventDelivery(10); pluginManager.stop(); Assert.assertEquals(1, debugPlugin.getEventCount()); Assert.assertEquals(1, debugPlugin.getHeartbeatCount()); Assert.assertEquals(1, debugPlugin.getCommitCount()); }
Source:
public void set(double speed) { LogKitten.v("Motor " + getName() + " @ " + speed); double newSpeed = speedModifier.modify(speed); lastSpeed = newSpeed; for (CustomSpeedController motor : motors) { motor.set(newSpeed); } }

Target:
public void set(double speed) { LogKitten.v("Motor " + getName() + " @ " + speed); double newSpeed = speedModifier.modify(speed); lastSpeed = newSpeed; for (SpeedController motor : motors) { motor.set(newSpeed); } }
Source:
public Object[] getElements(Object inputElement) { List<RepositoryTreeNode> nodes = new ArrayList<>(); List<String> directories = new ArrayList<>(); RepositoryUtil repositoryUtil = Activator.getDefault() .getRepositoryUtil(); boolean useRepositoryGroups = showUnbornHead; RepositoryGroups groups = new RepositoryGroups(); if (inputElement instanceof Collection) { for (Object next : ((Collection) inputElement)) { if (next instanceof RepositoryTreeNode) { nodes.add((RepositoryTreeNode) next); } else if (next instanceof String) { directories.add((String) next); } } } else if (inputElement instanceof IWorkspaceRoot) { directories.addAll(repositoryUtil.getConfiguredRepositories()); } for (String directory : directories) { try { File gitDir = new File(directory); if (gitDir.exists()) { if (!useRepositoryGroups || !groups.belongsToGroup(directory)) { RepositoryNode rNode = new RepositoryNode(null, repositoryCache.lookupRepository(gitDir)); nodes.add(rNode); } } else repositoryUtil.removeDir(gitDir); } catch (IOException e) { } } if (useRepositoryGroups) { for (RepositoryGroup group : groups.getGroups()) { nodes.add(new RepositoryGroupNode(null, group)); } } Collections.sort(nodes); return nodes.toArray(); }

Target:
public Object[] getElements(Object inputElement) { List<RepositoryTreeNode> nodes = new ArrayList<>(); List<String> directories = new ArrayList<>(); RepositoryUtil repositoryUtil = Activator.getDefault() .getRepositoryUtil(); RepositoryGroups groups = new RepositoryGroups(); if (inputElement instanceof Collection) { for (Object next : ((Collection) inputElement)) { if (next instanceof RepositoryTreeNode) { nodes.add((RepositoryTreeNode) next); } else if (next instanceof String) { directories.add((String) next); } } } else if (inputElement instanceof IWorkspaceRoot) { directories.addAll(repositoryUtil.getConfiguredRepositories()); } nodes.addAll( getRepositoryNodes(repositoryUtil, groups, null, directories)); if (showRepositoryGroups) { for (RepositoryGroup group : groups.getGroups()) { nodes.add(new RepositoryGroupNode(group)); } } Collections.sort(nodes); return nodes.toArray(); }
Source:
private static CheckpointBarrierHandler createCheckpointBarrierHandler( StreamConfig config, IntStream numberOfInputChannelsPerGate, ChannelStateWriter channelStateWriter, String taskName, InputGate[] channelIndexToInputGate, Map<InputGate, Integer> inputGateToChannelIndexOffset, AbstractInvokable toNotifyOnCheckpoint) { switch (config.getCheckpointMode()) { case EXACTLY_ONCE: return config.isUnalignedCheckpointsEnabled() ? new AlternatingCheckpointBarrierHandler( new CheckpointBarrierAligner( taskName, channelIndexToInputGate, inputGateToChannelIndexOffset, toNotifyOnCheckpoint), new CheckpointBarrierUnaligner( numberOfInputChannelsPerGate.toArray(), channelStateWriter, taskName, toNotifyOnCheckpoint), toNotifyOnCheckpoint) : new CheckpointBarrierAligner( taskName, channelIndexToInputGate, inputGateToChannelIndexOffset, toNotifyOnCheckpoint); case AT_LEAST_ONCE: return new CheckpointBarrierTracker(numberOfInputChannelsPerGate.sum(), toNotifyOnCheckpoint); default: throw new UnsupportedOperationException("Unrecognized Checkpointing Mode: " + config.getCheckpointMode()); } }

Target:
private static CheckpointBarrierHandler createCheckpointBarrierHandler( StreamConfig config, IntStream numberOfInputChannelsPerGate, ChannelStateWriter channelStateWriter, String taskName, InputGate[] channelIndexToInputGate, Map<InputGate, Integer> inputGateToChannelIndexOffset, AbstractInvokable toNotifyOnCheckpoint) { switch (config.getCheckpointMode()) { case EXACTLY_ONCE: if (config.isUnalignedCheckpointsEnabled()) { return new AlternatingCheckpointBarrierHandler( new CheckpointBarrierAligner( taskName, channelIndexToInputGate, inputGateToChannelIndexOffset, toNotifyOnCheckpoint), new CheckpointBarrierUnaligner( numberOfInputChannelsPerGate.toArray(), channelStateWriter, taskName, toNotifyOnCheckpoint), toNotifyOnCheckpoint); } return new CheckpointBarrierAligner( taskName, channelIndexToInputGate, inputGateToChannelIndexOffset, toNotifyOnCheckpoint); case AT_LEAST_ONCE: return new CheckpointBarrierTracker(numberOfInputChannelsPerGate.sum(), toNotifyOnCheckpoint); default: throw new UnsupportedOperationException("Unrecognized Checkpointing Mode: " + config.getCheckpointMode()); } }
Source:
public void updateVisibility() { messageLabel.setVisible(false); externalLabel.setVisible(ApplicationModeHelper.isModeSupported(ApplicationMode.VirtOnly)); onPhysicalNetworkChange(); }

Target:
public void updateVisibility() { messageLabel.setVisible(false); externalLabel.setVisible(ApplicationModeHelper.isModeSupported(ApplicationMode.VirtOnly)); physicalNetworkLabel.setVisible(false); }
Source:
public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; ListenerSubscription other = (ListenerSubscription) obj; if (indexer == null) { if (other.indexer != null) return false; } else if (!indexer.equals(other.indexer)) return false; if (listener == null) { if (other.listener != null) return false; } else if (!listener.equals(other.listener)) return false; return true; }

Target:
public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; ListenerSubscription other = (ListenerSubscription) obj; return Objects.equals(listener, other.listener) && Objects.equals(indexer, other.indexer); }
Source:
public ClientConfiguration getClientConfiguration() { return clientConfiguration; }

Target:
public ClientConfiguration getClientConfiguration() { return new ClientConfiguration(clientConfiguration); }
Source:
public GrillSessionHandle openSession(String username, String password, Map<String, String> configuration) throws GrillException { GrillSessionHandle sessionid = super.openSession(username, password, configuration); String auxJars = getSession(sessionid).getSessionConf().get(GrillConfConstants.AUX_JARS); if (StringUtils.isNotBlank(auxJars)) { LOG.info("Adding aux jars:" + auxJars); for (String jar : StringUtils.split(auxJars, ",")) { addResource(sessionid, "jar", jar); } } return sessionid; }

Target:
public GrillSessionHandle openSession(String username, String password, Map<String, String> configuration) throws GrillException { GrillSessionHandle sessionid = super.openSession(username, password, configuration); String[] auxJars = getSession(sessionid).getSessionConf().getStrings(GrillConfConstants.AUX_JARS); if (auxJars != null) { LOG.info("Adding aux jars:" + auxJars); for (String jar : auxJars) { addResource(sessionid, "jar", jar); } } return sessionid; }
Source:
private String getName(HiveColumnHandle[] expectedColumns) { return Stream.of(expectedColumns) .map(HiveColumnHandle::getName) .collect(Collectors.joining(",")); }

Target:
private String getName(HiveColumnHandle[] expectedColumns) { return Stream.of(expectedColumns) .map(HiveColumnHandle::getName) .collect(joining(",")); }
Source:
public CapraWordRequirement(XWPFParagraph paragraph, File officeFile, int objectID) { String rText = ""; String rId = ""; CTP pCtp = paragraph.getCTP(); Document doc; try { doc = loadXMLFromString(pCtp.toString()); } catch (Exception e) { e.printStackTrace(); return; } NodeList nodeList = doc.getElementsByTagName(wordFieldTag); if (nodeList.getLength() > 0) { String[] parts = nodeList.item(0).getTextContent().split(splitFieldRegex); if (Arrays.asList(parts).contains(fieldName) && parts.length > 2) { rText = paragraph.getText(); rId = parts[2].trim(); } } rText = rText.replaceAll(replaceRegex, " ").trim(); if (!rText.isEmpty()) { String pUri = CapraOfficeObject.createUri(officeFile.getAbsolutePath(), rId); this.setData(rText); this.setUri(pUri); } }

Target:
public CapraWordRequirement(XWPFParagraph paragraph, File officeFile, int objectID) { String rText = ""; String rId = ""; CTP pCtp = paragraph.getCTP(); Document doc; try { doc = loadXMLFromString(pCtp.toString()); } catch (Exception e) { e.printStackTrace(); return; } NodeList nodeList = doc.getElementsByTagName(wordFieldTag); if (nodeList.getLength() > 0) { String[] parts = nodeList.item(0).getTextContent().split(splitFieldRegex); if (Arrays.asList(parts).contains(fieldName) && parts.length > 2) { rText = paragraph.getText(); rId = parts[2].trim(); } } rText = rText.replaceAll(replaceRegex, " ").trim(); if (!rText.isEmpty()) { String pUri = CapraOfficeObject.createUri(officeFile, rId); this.setData(rText); this.setUri(pUri); } }
Source:
public static void evict(Configuration conf, Request request) { if (!HiveConf.getBoolVar(conf, HiveConf.ConfVars.LLAP_IO_PROACTIVE_EVICTION_ENABLED)) { return; } try { LlapRegistryService llapRegistryService = LlapRegistryService.getClient(conf); Collection<LlapServiceInstance> instances = llapRegistryService.getInstances().getAll(); if (instances.size() == 0) { return; } ExecutorService executorService = Executors.newCachedThreadPool(); for (LlapServiceInstance instance : instances) { Task task = new Task(conf, instance, request); executorService.execute(task); } } catch (IOException e) { throw new RuntimeException(e); } }

Target:
public static void evict(Configuration conf, Request request) { if (!HiveConf.getBoolVar(conf, HiveConf.ConfVars.LLAP_IO_PROACTIVE_EVICTION_ENABLED)) { return; } try { LlapRegistryService llapRegistryService = LlapRegistryService.getClient(conf); Collection<LlapServiceInstance> instances = llapRegistryService.getInstances().getAll(); if (instances.size() == 0) { return; } LOG.info("Requesting proactive LLAP cache eviction."); if (LOG.isDebugEnabled()) { LOG.debug(request.toString()); } for (LlapServiceInstance instance : instances) { EvictionRequestTask task = new EvictionRequestTask(conf, instance, request); EXECUTOR.execute(task); } } catch (IOException e) { throw new RuntimeException(e); } }
Source:
public String toString() { return "OperatingSystem{" + "id='" + id + '\'' + ", softwareLicense=" + softwareLicense + ", operatingSystemReferenceCode=" + operatingSystemReferenceCode + ", passwords=" + passwords + '}'; }

Target:
public String toString() { return Objects.toStringHelper(this) .add("id", id) .add("softwareLicense", softwareLicense) .add("operatingSystemReferenceCode", operatingSystemReferenceCode) .add("passwords", passwords) .toString(); }