auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
public static void beforeClass() throws IOException { SWTBotUtils.initialize(); SWTBotPreferences.TIMEOUT = 20000; SWTBotPreferences.KEYBOARD_LAYOUT = "EN_US"; fLogger.removeAllAppenders(); fLogger.addAppender(new ConsoleAppender(new SimpleLayout(), ConsoleAppender.SYSTEM_OUT)); fBot = new SWTWorkbenchBot(); SWTBotUtils.closeView("welcome", fBot); SWTBotUtils.switchToPerspective(KERNEL_PERSPECTIVE_ID); SWTBotUtils.createProject(TRACE_PROJECT_NAME); String tracePath = FileLocator.toFileURL(CtfTestTrace.ARM_64_BIT_HEADER.getTraceURL()).getPath(); SWTBotUtils.openTrace(TRACE_PROJECT_NAME, tracePath, KERNEL_TRACE_TYPE); SWTBotUtils.activateEditor(fBot, CtfTestTrace.ARM_64_BIT_HEADER.getTraceURL().getPath().replaceAll("/", "")); Assume.assumeNotNull(tracePath); }

Target:
public static void beforeClass() throws IOException { SWTBotUtils.initialize(); SWTBotPreferences.TIMEOUT = 20000; SWTBotPreferences.KEYBOARD_LAYOUT = "EN_US"; fLogger.removeAllAppenders(); fLogger.addAppender(new ConsoleAppender(new SimpleLayout(), ConsoleAppender.SYSTEM_OUT)); fBot = new SWTWorkbenchBot(); SWTBotUtils.closeView("welcome", fBot); SWTBotUtils.switchToPerspective(KERNEL_PERSPECTIVE_ID); SWTBotUtils.createProject(TRACE_PROJECT_NAME); String tracePath = FileLocator.toFileURL(CtfTestTrace.ARM_64_BIT_HEADER.getTraceURL()).getPath(); SWTBotUtils.openTrace(TRACE_PROJECT_NAME, tracePath, KERNEL_TRACE_TYPE); SWTBotUtils.activateEditor(fBot, CtfTestTrace.ARM_64_BIT_HEADER.getTraceURL().getPath().replaceAll("/", "")); }
Source:
private boolean patternMatchesAny(Pattern pattern, List<String> content) { if (pattern != null) { for (String str : content) { if (pattern.matcher(str).find()) { return true; } } } return false; }

Target:
private static boolean patternMatchesAny(Pattern pattern, List<String> content) { if (pattern != null) { for (String str : content) { if (pattern.matcher(str).find()) { return true; } } } return false; }
Source:
public void process() { PerformanceMonitor.startActivity("rendering/copyImageToScreen"); FINAL.bindTexture(); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); renderFullscreenQuad(); PerformanceMonitor.endActivity(); }

Target:
public void process() { PerformanceMonitor.startActivity("rendering/copyImageToScreen"); FINAL.bindTexture(); renderFullscreenQuad(); PerformanceMonitor.endActivity(); }
Source:
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setTitle("RxAndroid Samples"); setContentView(R.layout.samples_menu_activity); }

Target:
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.samples_menu_activity); ArrayAdapter<String> menuAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1); menuAdapter.addAll(MenuItems.titles); ListView listView = (ListView) findViewById(android.R.id.list); listView.setAdapter(menuAdapter); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { startActivity(MenuItems.intentForSample(SamplesMenuActivity.this, position)); } }); }
Source:
public PapyrusStereotypedElementItemProviderDecorator(ComposeableAdapterFactory adapterFactory) { super(adapterFactory); labelProviderService = new LabelProviderServiceImpl(); try { labelProviderService.startService(); } catch (ServiceException ex) { Activator.getDefault().getLog().log( new Status(IStatus.WARNING, Activator.PLUGIN_ID, "Unable to start Papyrus Label Provider Service", ex)); } }

Target:
public PapyrusStereotypedElementItemProviderDecorator(ComposeableAdapterFactory adapterFactory) { super(adapterFactory); }
Source:
AstNode parse( final DdlTokenStream tokens, final AstNode parentNode ) throws ParsingException { boolean view = true; DdlStatement stmt = null; SchemaElementType schemaElementType = null; if (tokens.canConsume(DdlStatement.CREATE_FOREIGN_TABLE.tokens())) { stmt = DdlStatement.CREATE_FOREIGN_TABLE; view = false; schemaElementType = SchemaElementType.FOREIGN; } else if (tokens.canConsume(DdlStatement.CREATE_VIEW.tokens()) || tokens.canConsume(DdlStatement.CREATE_VIRTUAL_VIEW.tokens())) { stmt = DdlStatement.CREATE_VIEW; schemaElementType = SchemaElementType.VIRTUAL; } else { throw new TeiidDdlParsingException(tokens, "Unparsable create table|view statement"); } assert (stmt != null) : "Create table|view statement is null"; final String id = parseIdentifier(tokens); final AstNode tableNode = getNodeFactory().node(id, parentNode, (view ? TeiidDdlLexicon.CreateTable.VIEW_STATEMENT : TeiidDdlLexicon.CreateTable.TABLE_STATEMENT)); tableNode.setProperty(TeiidDdlLexicon.SchemaElement.TYPE, schemaElementType.toDdl()); parseTableBody(tokens, tableNode); if (tokens.hasNext() && tokens.canConsume(TeiidReservedWord.AS.toDdl())) { if (!parseQueryExpression(tokens, tableNode)) { throw new TeiidDdlParsingException(tokens, "Unparsable create table statement"); } } return tableNode; }

Target:
AstNode parse( final DdlTokenStream tokens, final AstNode parentNode ) throws ParsingException { boolean view = true; DdlStatement stmt = null; SchemaElementType schemaElementType = null; if (tokens.canConsume(DdlStatement.CREATE_FOREIGN_TABLE.tokens())) { stmt = DdlStatement.CREATE_FOREIGN_TABLE; view = false; schemaElementType = SchemaElementType.FOREIGN; } else if (tokens.canConsume(DdlStatement.CREATE_VIEW.tokens()) || tokens.canConsume(DdlStatement.CREATE_VIRTUAL_VIEW.tokens())) { stmt = DdlStatement.CREATE_VIEW; schemaElementType = SchemaElementType.VIRTUAL; } else { throw new TeiidDdlParsingException(tokens, "Unparsable create table or view statement"); } assert (stmt != null) : "Create table or view statement is null"; final String id = parseIdentifier(tokens); final AstNode tableNode = getNodeFactory().node(id, parentNode, (view ? TeiidDdlLexicon.CreateTable.VIEW_STATEMENT : TeiidDdlLexicon.CreateTable.TABLE_STATEMENT)); tableNode.setProperty(TeiidDdlLexicon.SchemaElement.TYPE, schemaElementType.toDdl()); parseTableBody(tokens, tableNode); if (tokens.hasNext() && tokens.canConsume(TeiidReservedWord.AS.toDdl())) { if (!parseQueryExpression(tokens, tableNode)) { throw new TeiidDdlParsingException(tokens, "Unparsable create table statement"); } } return tableNode; }
Source:
public void setGlobalEntries(IAntClasspathEntry[] entries) { if (fUserGlobalEntry == null) { String name = AntPreferencesMessages.ClasspathModel_3; fUserGlobalEntry = createGlobalEntry(entries, name, true, true, GLOBAL_USER); } else { fUserGlobalEntry.removeAll(); for (IAntClasspathEntry entrie : entries) { fUserGlobalEntry.addEntry(new ClasspathEntry(entrie, fUserGlobalEntry)); } } }

Target:
public void setGlobalEntries(IAntClasspathEntry[] entries) { if (fUserGlobalEntry == null) { String name = AntPreferencesMessages.ClasspathModel_3; fUserGlobalEntry = createGlobalEntry(entries, name, true, true, GLOBAL_USER); } else { fUserGlobalEntry.removeAll(); for (IAntClasspathEntry entry : entries) { fUserGlobalEntry.addEntry(new ClasspathEntry(entry, fUserGlobalEntry)); } } }
Source:
private void exportFilesAsList() throws SemanticException, IOException { if (dataPathList.isEmpty()) { return; } boolean done = false; int repeat = 0; while (!done) { try (BufferedWriter writer = writer()) { for (Path dataPath : dataPathList) { writeFilesList(listFilesInDir(dataPath), writer, AcidUtils.getAcidSubDir(dataPath)); } done = true; } catch (IOException e) { repeat++; logger.info("writeFilesList failed with exception : " + e.getMessage() + " for " + repeat + " time"); if (repeat >= MAX_IO_ERROR_RETRY) { logger.error("exporting data files in dir : " + dataPathList + " to " + exportRootDataDir + " failed"); throw e; } try { logger.info(" sleep for 100 milliseconds before retry " + (repeat)); Thread.sleep(100); } catch (InterruptedException timerEx) { logger.info("thread sleep interrupted", timerEx.getMessage()); } dataFileSystem = dataPathList.get(0).getFileSystem(hiveConf); exportFileSystem = exportRootDataDir.getFileSystem(hiveConf); exportFileSystem.deleteOnExit(new Path(exportRootDataDir, EximUtil.FILES_NAME)); } } }

Target:
private void exportFilesAsList() throws SemanticException, IOException, LoginException { if (dataPathList.isEmpty()) { return; } boolean done = false; int repeat = 0; while (!done) { try (BufferedWriter writer = writer()) { for (Path dataPath : dataPathList) { writeFilesList(listFilesInDir(dataPath), writer, AcidUtils.getAcidSubDir(dataPath)); } done = true; } catch (IOException e) { repeat++; logger.info("writeFilesList failed", e); if (repeat >= FileUtils.MAX_IO_ERROR_RETRY) { logger.error("exporting data files in dir : " + dataPathList + " to " + exportRootDataDir + " failed"); throw e; } int sleepTime = FileUtils.getSleepTime(repeat - 1); logger.info(" sleep for milliseconds for retry num ", sleepTime , repeat); try { Thread.sleep(sleepTime); } catch (InterruptedException timerEx) { logger.info("thread sleep interrupted", timerEx.getMessage()); } FileSystem.closeAllForUGI(Utils.getUGI()); dataFileSystem = dataPathList.get(0).getFileSystem(hiveConf); exportFileSystem = exportRootDataDir.getFileSystem(hiveConf); Path exportPath = new Path(exportRootDataDir, EximUtil.FILES_NAME); if (exportFileSystem.exists(exportPath)) { exportFileSystem.delete(exportPath, true); } } } }
Source:
public void testCmdEnvironment() throws Exception { CommandLineExecutorService cles = Framework.getLocalService(CommandLineExecutorService.class); assertNotNull(cles); deployContrib("org.nuxeo.ecm.platform.commandline.executor", "OSGI-INF/commandline-env-test-contrib.xml"); applyInlineDeployments(); List<String> cmds = cles.getRegistredCommands(); assertNotNull(cmds); assertTrue(cmds.contains("echo")); ExecResult result = cles.execCommand("echo", cles.getDefaultCmdParameters()); assertTrue(result.isSuccessful()); assertSame(0, result.getReturnCode()); assertTrue( String.format("Output should contain %s:\n%s", Environment.getDefault().getTemp().getPath(), result.getOutput()), String.join("", result.getOutput()).contains(Environment.getDefault().getTemp().getPath())); }

Target:
public void testCmdEnvironment() throws Exception { CommandLineExecutorService cles = Framework.getLocalService(CommandLineExecutorService.class); assertNotNull(cles); pushInlineDeployments("org.nuxeo.ecm.platform.commandline.executor:OSGI-INF/commandline-env-test-contrib.xml"); List<String> cmds = cles.getRegistredCommands(); assertNotNull(cmds); assertTrue(cmds.contains("echo")); ExecResult result = cles.execCommand("echo", cles.getDefaultCmdParameters()); assertTrue(result.isSuccessful()); assertSame(0, result.getReturnCode()); assertTrue( String.format("Output should contain %s:\n%s", Environment.getDefault().getTemp().getPath(), result.getOutput()), String.join("", result.getOutput()).contains(Environment.getDefault().getTemp().getPath())); }
Source:
public StructuredRecord getCurrentValue(StructuredRecord.Builder recordBuilder) throws IOException, InterruptedException { return recordTransformer.transform(delegate.getCurrentKey().datum()); }

Target:
public StructuredRecord getCurrentValue(StructuredRecord.Builder recordBuilder) throws IOException, InterruptedException { AvroJob.setOutputKeySchema(job, new org.apache.avro.Schema.Parser().parse(schema.toString())); StructuredRecord ret = recordTransformer.transform(recordBuilder, delegate.getCurrentKey().datum(), schema, pathField); return ret; }
Source:
public MediaServerConfiguration load(String filepath) throws Exception { MediaServerConfiguration configuration = new MediaServerConfiguration(); XMLConfiguration xml; try { try { xml = this.configurations.xml(filepath); } catch (ConfigurationException e) { log.warn("Could not load configuration from " + filepath); final String mmsHome = System.getProperty(MMS_HOME); filepath = mmsHome + DEFAULT_PATH; xml = this.configurations.xml(filepath); log.warn("Configuration file found at " + filepath); } configureNetwork(xml.configurationAt("network"), configuration.getNetworkConfiguration()); configureController(xml.configurationAt("controller"), configuration.getControllerConfiguration()); configureMedia(xml.configurationAt("media"), configuration.getMediaConfiguration()); configureResource(xml.configurationAt("resources"), configuration.getResourcesConfiguration()); configureDtls(xml.configurationAt("dtls"), configuration.getDtlsConfiguration()); } catch (Exception e) { log.error("Could not load configuration from " + filepath + ". Reason: " + e.getMessage()); throw e; } return configuration; }

Target:
public MediaServerConfiguration load(String filepath) throws Exception { MediaServerConfiguration configuration = new MediaServerConfiguration(); XMLConfiguration xml; try { xml = this.configurations.xml(filepath); } catch (ConfigurationException e) { log.warn("Could not load configuration from " + filepath); final String mmsHome = System.getProperty(MMS_HOME); filepath = mmsHome + DEFAULT_PATH; xml = this.configurations.xml(filepath); log.warn("Configuration file found at " + filepath); } configureNetwork(xml.configurationAt("network"), configuration.getNetworkConfiguration()); configureController(xml.configurationAt("controller"), configuration.getControllerConfiguration()); configureMedia(xml.configurationAt("media"), configuration.getMediaConfiguration()); configureResource(xml.configurationAt("resources"), configuration.getResourcesConfiguration()); configureDtls(xml.configurationAt("dtls"), configuration.getDtlsConfiguration()); return configuration; }
Source:
public String failed() throws IOException { final Object result = this.client.call( LuaCommand.FAILED.toString()); return result.toString(); }

Target:
public Map<String, Long> failed() throws IOException { final Object result = this.client.call( LuaCommand.FAILED.toString()); final JavaType javaType = new ObjectMapper().getTypeFactory().constructMapType( HashMap.class, String.class, Long.class); return JsonUtils.parse(result.toString(), javaType); }
Source:
public Filter createFilter(FilterFactoryParams params) throws FilterNotCreatedException { try { return createFilter(parseCategories(params.getArgs())); } catch (ClassNotFoundException e) { throw new FilterNotCreatedException(e.getMessage()); } }

Target:
public Filter createFilter(FilterFactoryParams params) throws FilterNotCreatedException { try { return createFilter(parseCategories(params.getArgs())); } catch (ClassNotFoundException e) { throw new FilterNotCreatedException(e); } }
Source:
private void maybeCloseNetworkChannel(boolean forceClose) { lastWriteFuture.addListener(ChannelFutureListener.CLOSE); logger.trace("Requested closing of channel {}", ctx.channel()); }

Target:
private boolean maybeCloseNetworkChannel(boolean forceClose) { lastWriteFuture.addListener(ChannelFutureListener.CLOSE); logger.trace("Requested closing of channel {}", ctx.channel()); return true; }
Source:
private void ingestFileObjectAsWork(ContentContainerObject parent, Resource parentResc, Resource childResc) throws DepositException { if (skipResumed(childResc)) { return; } PID childPid = PIDs.get(childResc.getURI()); PID workPid = repository.mintContentPid(); Model workModel = ModelFactory.createDefaultModel(); String label = getPropertyValue(childResc, CdrDeposit.label); if (label == null) { label = getPropertyValue(childResc, CdrDeposit.stagingLocation); if (label == null) { throw new DepositException("No staging location provided for file object (" + childResc.getURI() + ")"); } label = new File(label).getName(); } Resource workResc = workModel.createResource(workPid.getRepositoryPath()); workResc.addProperty(DC.title, label); FedoraTransaction tx = repository.startTransaction(); try { WorkObject newWork = repository.createWorkObject(workPid, workModel); addFileToWork(newWork, childResc); newWork.setPrimaryObject(childPid); parent.addMember(newWork); addClicks(1); log.info("Created work for file object for deposit {}", new Object[] {workPid, childPid, getDepositPID()}); } finally { tx.close(); } }

Target:
private void ingestFileObjectAsWork(ContentContainerObject parent, Resource parentResc, Resource childResc) throws DepositException { if (skipResumed(childResc)) { return; } PID childPid = PIDs.get(childResc.getURI()); PID workPid = repository.mintContentPid(); Model workModel = ModelFactory.createDefaultModel(); String label = getPropertyValue(childResc, CdrDeposit.label); if (label == null) { label = getPropertyValue(childResc, CdrDeposit.stagingLocation); if (label == null) { throw new DepositException("No staging location provided for file object (" + childResc.getURI() + ")"); } label = new File(label).getName(); } Resource workResc = workModel.createResource(workPid.getRepositoryPath()); workResc.addProperty(DC.title, label); FedoraTransaction tx = repository.startTransaction(); try { WorkObject newWork = repository.createWorkObject(workPid, workModel); addFileToWork(newWork, childResc); newWork.setPrimaryObject(childPid); parent.addMember(newWork); addClicks(1); log.info("Created work for file object for deposit {}", new Object[] {workPid, childPid, getDepositPID()}); } catch(Exception e) { tx.cancel(e); } finally { tx.close(); } }
Source:
public static List<String> explode(final String input) { List<String> result = newArrayList(); if (isNull(input)) { return result; } char[] characters = input.toCharArray(); for (int i = 0; i < input.length(); i++) { result.add(String.valueOf(characters[i])); } return result; }

Target:
public static List<String> explode(final String input) { List<String> result = newArrayList(); if (isNull(input)) { return result; } for (char character : input.toCharArray()) { result.add(String.valueOf(character)); } return result; }
Source:
public RoomMediator getFirstRoomMediator(ClientMediatorPod pod) { Log.log(Level.FINEST, pod, "getFirstRoomMediator: builder={0}, new={1}", Log.getHexHash(this), pod.room == null); boolean newbie = pod.room == null; Site site = mapClient.getSite(Constants.FIRST_ROOM); if ( site == null ) { site = FirstRoom.getFallbackSite(); } String playerMode = "full"; String targetId = null; SignedJWT clientJwt = pod.getParsedClientJwt(); if(clientJwt!=null) { Claims c = clientJwt.getClaims(); if(c.containsKey("playerMode")) { playerMode = c.get("playerMode", String.class); targetId = c.get("story", String.class); } } if("guided".equals(playerMode)) { return new GuidedFirstRoom(nexus.getMultiUserView(Constants.FIRST_ROOM), pod.getEncodedServerJwt(), playerClient, mapClient, site, targetId); } else { return new FirstRoom(nexus.getMultiUserView(Constants.FIRST_ROOM), pod.getEncodedServerJwt(), playerClient, mapClient, site, newbie); } }

Target:
public RoomMediator getFirstRoomMediator(ClientMediatorPod pod) { Log.log(Level.FINEST, pod, "getFirstRoomMediator: builder={0}, new={1}", Log.getHexHash(this), pod.room == null); boolean newbie = pod.room == null; Site site = mapClient.getSite(Constants.FIRST_ROOM); if ( site == null ) { site = FirstRoom.getFallbackSite(); } String playerMode = "default"; String targetId = null; SignedJWT clientJwt = pod.getParsedClientJwt(); if(clientJwt!=null) { Claims c = clientJwt.getClaims(); if(c.containsKey("playerMode")) { playerMode = c.get("playerMode", String.class); targetId = c.get("story", String.class); } } if("guided".equals(playerMode)) { return new GuidedFirstRoom(nexus.getMultiUserView(Constants.FIRST_ROOM), pod.getEncodedServerJwt(), playerClient, mapClient, site, targetId); } else { return new FirstRoom(nexus.getMultiUserView(Constants.FIRST_ROOM), pod.getEncodedServerJwt(), playerClient, mapClient, site, newbie); } }
Source:
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try { log.debug("Entered AuthorizeServlet QueryString: {}, Parameters : {}", request.getQueryString(), SsoUtils.getRequestParameters(request)); String responseType = SsoUtils.getRequestParameter(request, SsoConstants.JSON_RESPONSE_TYPE); if (!responseType.equals("code")) { throw new OAuthException(SsoConstants.ERR_CODE_INVALID_REQUEST, String.format( ssoContext.getLocalizationUtils().localize( SsoConstants.APP_ERROR_UNSUPPORTED_PARAMETER_IN_REQUEST, (Locale) request.getAttribute(SsoConstants.LOCALE)), responseType, SsoConstants.JSON_RESPONSE_TYPE)); } login(request, response, buildSsoSession(request)); } catch (Exception ex) { SsoSession ssoSession = SsoUtils.getSsoSession(request, true); if (ssoSession.isOpenIdScope() || SsoUtils.scopeAsList(SsoUtils.getScopeRequestParameter(request, "")).contains(SsoConstants.OPENID_SCOPE)) { ssoSession.setRedirectUri(request.getParameter(SsoConstants.HTTP_PARAM_REDIRECT_URI)); } SsoUtils.redirectToErrorPage(request, response, ex); } }

Target:
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try { log.debug("Entered AuthorizeServlet QueryString: {}, Parameters : {}", request.getQueryString(), SsoUtils.getRequestParameters(request)); String responseType = SsoUtils.getRequestParameter(request, SsoConstants.JSON_RESPONSE_TYPE); if (!responseType.equals("code")) { throw new OAuthException(SsoConstants.ERR_CODE_INVALID_REQUEST, String.format( ssoContext.getLocalizationUtils().localize( SsoConstants.APP_ERROR_UNSUPPORTED_PARAMETER_IN_REQUEST, (Locale) request.getAttribute(SsoConstants.LOCALE)), responseType, SsoConstants.JSON_RESPONSE_TYPE)); } login(request, response, buildSsoSession(request)); } catch (Exception ex) { SsoSession ssoSession = SsoUtils.getSsoSession(request, true); String scope = SsoUtils.getScopeRequestParameter(request, ""); if (ssoSession.isOpenIdScope() || SsoUtils.scopeAsList(scope).contains(SsoConstants.OPENID_SCOPE)) { ssoSession.setRedirectUri(request.getParameter(SsoConstants.HTTP_PARAM_REDIRECT_URI)); } SsoUtils.redirectToErrorPage(request, response, ex); } }
Source:
public void copyObject(String bucketName, String objectName, String destBucketName, String destObjectName, CopyConditions copyConditions, Map<String,String> metadata) throws InvalidKeyException, InvalidBucketNameException, NoSuchAlgorithmException, InsufficientDataException, NoResponseException, ErrorResponseException, InternalException, IOException, XmlPullParserException, InvalidArgumentException { if (bucketName == null) { throw new InvalidArgumentException("Source bucket name cannot be empty"); } if (objectName == null) { throw new InvalidArgumentException("Source object name cannot be empty"); } if (destBucketName == null) { throw new InvalidArgumentException("Destination bucket name cannot be empty"); } String sourceObjectPath = S3Escaper.encodePath(bucketName + "/" + objectName); if (destObjectName == null) { destObjectName = objectName; } Map<String, String> headerMap = new HashMap<>(); headerMap.put("x-amz-copy-source", sourceObjectPath); if (copyConditions != null) { headerMap.putAll(copyConditions.getConditions()); } if (metadata != null) { headerMap.putAll(Collections.unmodifiableMap(metadata)); } HttpResponse response = executePut(destBucketName, destObjectName, headerMap, null, "", 0); CopyObjectResult result = new CopyObjectResult(); result.parseXml(response.body().charStream()); response.body().close(); }

Target:
public void copyObject(String bucketName, String objectName, String destBucketName, String destObjectName, CopyConditions copyConditions, Map<String,String> metadata) throws InvalidKeyException, InvalidBucketNameException, NoSuchAlgorithmException, InsufficientDataException, NoResponseException, ErrorResponseException, InternalException, IOException, XmlPullParserException, InvalidArgumentException { if (bucketName == null) { throw new InvalidArgumentException("Source bucket name cannot be empty"); } if (objectName == null) { throw new InvalidArgumentException("Source object name cannot be empty"); } if (destBucketName == null) { throw new InvalidArgumentException("Destination bucket name cannot be empty"); } String sourceObjectPath = S3Escaper.encodePath(bucketName + "/" + objectName); if (destObjectName == null) { destObjectName = objectName; } Map<String, String> headerMap = new HashMap<>(); headerMap.put("x-amz-copy-source", sourceObjectPath); if (copyConditions != null) { headerMap.putAll(copyConditions.getConditions()); } if (metadata != null) { headerMap.putAll(metadata); } HttpResponse response = executePut(destBucketName, destObjectName, headerMap, null, "", 0); CopyObjectResult result = new CopyObjectResult(); result.parseXml(response.body().charStream()); response.body().close(); }
Source:
protected void run() throws UnloggedFailure, Failure, Exception { stdout.println("Hello, cookbook administrator"); }

Target:
protected void run() { stdout.println("Hello, cookbook administrator"); }
Source:
public List<ObjectId> revListAll() throws GitException { List<ObjectId> oidList = new ArrayList<>(); RevListCommand revListCommand = revList_(); revListCommand.all(); revListCommand.to(oidList); try { revListCommand.execute(); } catch (InterruptedException e) { throw new GitException(e); } catch (IOException e) { throw new GitException(e); } return oidList; }

Target:
public List<ObjectId> revListAll() throws GitException { List<ObjectId> oidList = new ArrayList<>(); RevListCommand revListCommand = revList_(); revListCommand.all(); revListCommand.to(oidList); try { revListCommand.execute(); } catch (InterruptedException | IOException e) { throw new GitException(e); } return oidList; }
Source:
protected void buildAuditMessage(StringBuilder builder) { super.buildAuditMessage(builder); SortedSet<String> roleSet = new TreeSet<>(); roleSet.addAll(users.keySet()); roleSet.addAll(groups.keySet()); roleSet.addAll(roles.keySet()); builder.append(", Roles("); List<String> lines = new LinkedList<>(); List<String> tmpLines = null; for (String role : roleSet) { tmpLines = new LinkedList<>(); lines.add(role + ": ["); if (users.get(role) != null && !users.get(role).isEmpty()) { tmpLines.add(" Users: " + StringUtils.join(users.get(role), ", ")); } if (groups.get(role) != null && !groups.get(role).isEmpty()) { tmpLines.add(" Groups: " + StringUtils.join(groups.get(role), ", ")); } if (roles.get(role) != null && !roles.get(role).isEmpty()) { tmpLines.add(" Roles: " + StringUtils.join(roles.get(role), ", ")); } lines.add(StringUtils.join(tmpLines, ";")); lines.add("] "); } builder.append(StringUtils.join(lines, "")); builder.append(")"); }

Target:
protected void buildAuditMessage(StringBuilder builder) { super.buildAuditMessage(builder); SortedSet<String> roleSet = new TreeSet<>(); roleSet.addAll(users.keySet()); roleSet.addAll(groups.keySet()); roleSet.addAll(roles.keySet()); builder.append(", Roles("); List<String> lines = new LinkedList<>(); for (String role : roleSet) { List<String> tmpLines = new LinkedList<>(); lines.add(role + ": ["); if (users.get(role) != null && !users.get(role).isEmpty()) { tmpLines.add("Users: " + StringUtils.join(users.get(role), ", ")); } if (groups.get(role) != null && !groups.get(role).isEmpty()) { tmpLines.add("Groups: " + StringUtils.join(groups.get(role), ", ")); } if (roles.get(role) != null && !roles.get(role).isEmpty()) { tmpLines.add("Roles: " + StringUtils.join(roles.get(role), ", ")); } lines.add(StringUtils.join(tmpLines, ";")); lines.add("] "); } builder.append(StringUtils.join(lines, "")); builder.append(")"); }
Source:
public void setAttribute(String attributeName, Object attributeValue) { if (attributeValue == null) { this.delta.put(attributeName, DeltaValue.REMOVED); } else { final Object existingAttributeValue = this.delegate.getAttribute(attributeName); if (existingAttributeValue != null) { if (existingAttributeValue == attributeValue && ClassUtils.isPrimitiveOrWrapper(attributeValue.getClass())) { this.delta.put(attributeName, DeltaValue.UPDATED); } } else { this.delta.put(attributeName, DeltaValue.ADDED); } } this.delegate.setAttribute(attributeName, attributeValue); if (PRINCIPAL_NAME_INDEX_NAME.equals(attributeName) || SPRING_SECURITY_CONTEXT.equals(attributeName)) { this.changed = true; } }

Target:
public void setAttribute(String attributeName, Object attributeValue) { final Object existingAttributeValue = this.delegate.getAttribute(attributeName); boolean attributeExists = (existingAttributeValue != null); boolean attributeRemoved = (attributeValue == null); if (!attributeExists && attributeRemoved) { return; } if (attributeExists) { if (attributeRemoved) { this.delta.merge(attributeName, DeltaValue.REMOVED, (oldDeltaValue, deltaValue) -> oldDeltaValue == DeltaValue.ADDED ? null : deltaValue); } else if (existingAttributeValue.getClass() != attributeValue.getClass() || !isImmutable(existingAttributeValue.getClass()) || !attributeValue.equals(existingAttributeValue)) { this.delta.merge(attributeName, DeltaValue.UPDATED, (oldDeltaValue, deltaValue) -> oldDeltaValue == DeltaValue.ADDED ? oldDeltaValue : deltaValue); } } else { this.delta.merge(attributeName, DeltaValue.ADDED, (oldDeltaValue, deltaValue) -> oldDeltaValue == DeltaValue.ADDED ? oldDeltaValue : DeltaValue.UPDATED); } this.delegate.setAttribute(attributeName, attributeValue); if (PRINCIPAL_NAME_INDEX_NAME.equals(attributeName) || SPRING_SECURITY_CONTEXT.equals(attributeName)) { this.changed = true; } }
Source:
private void addToDuplicateLibs(Map<String, Set<Dependency>> map, Dependency dependency) { String coordinate = getCoordinate(dependency.getGroupId(), dependency.getArtifactId(), dependency.getType(), null); if (!map.containsKey(coordinate)) { Set<Dependency> set = new HashSet<>(); map.put(coordinate, set); } boolean exist = false; for (Dependency dep : map.get(coordinate)) { if (dep.getGroupId().equals(dependency.getGroupId()) && dep.getArtifactId().equals(dependency.getArtifactId()) && dep.getVersion().equals(dependency.getVersion()) && dep.getType().equals(dependency.getType())) { exist = true; break; } } if (!exist) { map.get(coordinate).add(dependency); } }

Target:
private void addToDuplicateLibs(Map<String, Set<Dependency>> map, Dependency dependency) { String coordinate = getCoordinate(dependency.getGroupId(), dependency.getArtifactId(), dependency.getType(), null); if (!map.containsKey(coordinate)) { Set<Dependency> set = new HashSet<>(); map.put(coordinate, set); } map.get(coordinate).add(dependency); }
Source:
private void checkPlainText() { if (expectedLines == null) { expectedLines = headerFormat.split("(?:\r)?\n|\r"); } CompatibleInputFile inputFile = getContext().getFile(); List<String> lines; try (InputStreamReader inr = new InputStreamReader(inputFile.inputStream(), inputFile.charset())) { lines = CharStreams.readLines(inr); } catch (IOException e) { throw new IllegalStateException("Unable to execute rule \"S1451\" for file " + getContext().getFileName(), e); } if (!matches(expectedLines, lines)) { addIssue(new FileIssue(this, MESSAGE)); } }

Target:
private void checkPlainText() { if (expectedLines == null) { expectedLines = headerFormat.split("(?:\r)?\n|\r"); } JavaScriptFile file = getContext().getJavaScriptFile(); List<String> lines = CheckUtils.readLines(file); if (!matches(expectedLines, lines)) { addIssue(new FileIssue(this, MESSAGE)); } }
Source:
public void shutdown(final boolean clean) { log.debug("Shutting down all active tasks in" + "\n" + "Created: {}" + "\n" + "Restoring: {}" + "\n" + "Running: {}" + "\n" + "Suspended: {}", created.keySet(), restoring.keySet(), running.keySet(), suspended.keySet()); super.shutdown(clean); }

Target:
public void shutdown(final boolean clean) { final String shutdownType = clean ? "Clean" : "Unclean"; log.debug(shutdownType + " shutdown of all active tasks" + "\n" + "non-initialized tasks to close: {}" + "\n" + "restoring tasks to close: {}" + "\n" + "running tasks to close: {}" + "\n" + "suspended tasks to close: {}", clean, created.keySet(), restoring.keySet(), running.keySet(), suspended.keySet()); super.shutdown(clean); }
Source:
public static void withContextIfNeed(UUID secSubjId, GridKernalContext ctx, RunnableX r) throws IgniteCheckedException { IgniteSecurity security = ctx.security(); try { if (security.enabled() && secSubjId != null) { try (OperationSecurityContext s = security.withContext(secSubjId)) { r.runx(); } } else r.runx(); } catch (Exception e) { if (e instanceof IgniteCheckedException) throw (IgniteCheckedException)e; throw new IgniteCheckedException(e); } }

Target:
public static void withContextIfNeed(UUID secSubjId, GridKernalContext ctx, RunnableX r) { IgniteSecurity security = ctx.security(); if (security.enabled() && secSubjId != null) { try (OperationSecurityContext s = security.withContext(secSubjId)) { r.run(); } } else r.run(); }
Source:
public void onMessage(Message message) { try { if (message != null) { if (log.isDebugEnabled()) { log.debug("Event received in JMS Event Receiver - " + message); } Topic jmsDestination = (Topic) message.getJMSDestination(); if (message instanceof MapMessage) { MapMessage mapMessage = (MapMessage) message; Map<String, Object> map = new HashMap<String, Object>(); Enumeration enumeration = mapMessage.getMapNames(); while (enumeration.hasMoreElements()) { String key = (String) enumeration.nextElement(); map.put(key, mapMessage.getObject(key)); } if (APIConstants.TopicNames.TOPIC_NOTIFICATION.equalsIgnoreCase(jmsDestination.getTopicName())) { if (map.get(APIConstants.EVENT_TYPE) != null) { ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); final Runnable task = new Runnable() { @Override public void run() { handleNotificationMessage((String) map.get(APIConstants.EVENT_TYPE), (Long) map.get(APIConstants.EVENT_TIMESTAMP), (String) map.get(APIConstants.EVENT_PAYLOAD)); } }; scheduler.schedule(task, gatewayArtifactSynchronizerProperties.getEventWaitingTime(), TimeUnit.MILLISECONDS); } } } else { log.warn("Event dropped due to unsupported message type " + message.getClass()); } } else { log.warn("Dropping the empty/null event received through jms receiver"); } } catch (JMSException e) { log.error("JMSException occurred when processing the received message ", e); } }

Target:
public void onMessage(Message message) { try { if (message != null) { if (log.isDebugEnabled()) { log.debug("Event received in JMS Event Receiver - " + message); } Topic jmsDestination = (Topic) message.getJMSDestination(); if (message instanceof MapMessage) { MapMessage mapMessage = (MapMessage) message; Map<String, Object> map = new HashMap<String, Object>(); Enumeration enumeration = mapMessage.getMapNames(); while (enumeration.hasMoreElements()) { String key = (String) enumeration.nextElement(); map.put(key, mapMessage.getObject(key)); } if (APIConstants.TopicNames.TOPIC_NOTIFICATION.equalsIgnoreCase(jmsDestination.getTopicName())) { if (map.get(APIConstants.EVENT_TYPE) != null) { if (debugEnabled) { log.debug("Event received from the topic of " + jmsDestination.getTopicName()); } handleNotificationMessage((String) map.get(APIConstants.EVENT_TYPE), (Long) map.get(APIConstants.EVENT_TIMESTAMP), (String) map.get(APIConstants.EVENT_PAYLOAD)); } } } else { log.warn("Event dropped due to unsupported message type " + message.getClass()); } } else { log.warn("Dropping the empty/null event received through jms receiver"); } } catch (JMSException e) { log.error("JMSException occurred when processing the received message ", e); } }
Source:
public double getCommandedSteeringAngle() { int closestIndex = getClosestIndex(wayPoints,pose); if(closestIndex == -1){ return 17433504; } double delta = 10; int targetIndex = closestIndex; while(GPSPoseMessage.getDistance(pose,wayPoints.get(targetIndex).toGpsPoseMessage(0)) < delta){ targetIndex = targetIndex+1; } if(targetIndex >= wayPoints.size()) { return 0; } GpsMeasurement targetPoint = wayPoints.get(targetIndex); double dx = targetPoint.getLongitude() - pose.getLongitude(); double dy = targetPoint.getLatitude() - pose.getLatitude(); double desiredHeading = 180*Math.atan2(dy, dx)/Math.PI; return desiredHeading - pose.getHeading(); }

Target:
public double getCommandedSteeringAngle() { int closestIndex = getClosestIndex(wayPoints,pose); if(closestIndex == -1){ return 17433504; } double delta = 10; int targetIndex = closestIndex; while(GPSPoseMessage.getDistance(pose,wayPoints.get(targetIndex).toGpsPoseMessage(0)) < delta){ targetIndex = targetIndex+1; } if(targetIndex >= wayPoints.size()) { return 0; } GpsMeasurement targetPoint = wayPoints.get(targetIndex); double dLon = targetPoint.getLongitude() - pose.getLongitude(); double dLat = targetPoint.getLatitude() - pose.getLatitude(); double desiredHeading = 180*Math.atan2(dLat, dLon)/Math.PI; return desiredHeading - pose.getHeading(); }
Source:
private void addAPIs(List<ComponentManifest.API> apis, String appContextPath, String componentContextPath, String componentName, ClassLoader classLoader) { if ((apis == null) || apis.isEmpty()) { return; } for (ComponentManifest.API api : apis) { String className = api.getClassName(); String uri = appContextPath + componentContextPath + "/apis" + api.getUri(); Object apiImplementation; try { apiImplementation = classLoader.loadClass(className).newInstance(); } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) { throw new UUFException("Error in deploying API " + className, e); } Dictionary<String, String> serviceProperties = new Hashtable<>(); serviceProperties.put("contextPath", uri); classLoaderProvider.deployAPI(apiImplementation, serviceProperties); LOGGER.info("Deployed API '{}' in component '{}' with the context path '{}'.", className, componentName, uri); } }

Target:
private void addAPIs(List<ComponentManifest.API> apis, String appContextPath, String componentContextPath, String componentName, ClassLoader classLoader) { if ((apis == null) || apis.isEmpty()) { return; } for (ComponentManifest.API api : apis) { String className = api.getClassName(); String uri = appContextPath + componentContextPath + "/apis" + api.getUri(); Object apiImplementation; try { apiImplementation = classLoader.loadClass(className).newInstance(); } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) { throw new UUFException("Cannot deploy REST API '" + className + "' for component '" + componentName + "'", e); } Dictionary<String, String> serviceProperties = new Hashtable<>(); serviceProperties.put("contextPath", uri); classLoaderProvider.deployAPI(apiImplementation, serviceProperties); LOGGER.info("Deployed REST API '{}' for component '{}' with context path '{}'.", className, componentName, uri); } }
Source:
protected Cluster buildGroup(GroupParams<Node.NodeParams> groupParams) { if (groupParams.getType().equals(CorfuServerParams.class)) { groupParams.getNodesParams().forEach(node -> FAKE_DNS.addForwardResolution(node.getName(), InetAddress.getLoopbackAddress()) ); return DockerCorfuCluster.builder() .universeParams(universeParams) .params(ClassUtils.cast(groupParams)) .loggingParams(loggingParams) .docker(docker) .build(); }if (groupParams.getType().equals(SupportServerParams.class)) { groupParams.getNodesParams().forEach(node -> FAKE_DNS.addForwardResolution(node.getName(), InetAddress.getLoopbackAddress()) ); return DockerSupportCluster.builder() .universeParams(universeParams) .monitoringParams(ClassUtils.cast(groupParams)) .loggingParams(loggingParams) .docker(docker) .build(); } else { throw new UniverseException("Unknown node type"); } }

Target:
protected Cluster buildGroup(GroupParams<Node.NodeParams> groupParams) { switch (groupParams.getType()) { case CORFU_CLUSTER: groupParams.getNodesParams().forEach(node -> FAKE_DNS.addForwardResolution(node.getName(), InetAddress.getLoopbackAddress()) ); return DockerCorfuCluster.builder() .universeParams(universeParams) .params(ClassUtils.cast(groupParams)) .loggingParams(loggingParams) .docker(docker) .build(); case SUPPORT_CLUSTER: groupParams.getNodesParams().forEach(node -> FAKE_DNS.addForwardResolution(node.getName(), InetAddress.getLoopbackAddress()) ); return DockerSupportCluster.builder() .universeParams(universeParams) .monitoringParams(ClassUtils.cast(groupParams)) .loggingParams(loggingParams) .docker(docker) .build(); default: throw new UniverseException("Unknown node type"); } }
Source:
public void testSafelyHandleModuleInfo() throws IOException { ZipFile zipFile = new ZipFile(libraryModuleInfoJar.toFile()); ZipEntry entry = zipFile.getEntry("module-info.class"); ClassCache cache = new ClassCache( ImmutableSet.of(), ImmutableSet.of(), ImmutableSet.of(), ImmutableSet.of(), false); try (InputStream classStream = zipFile.getInputStream(entry)) { ClassReader reader = new ClassReader(classStream); DepsCheckerClassVisitor checker = new DepsCheckerClassVisitor(cache, null); reader.accept(checker, ClassReader.SKIP_DEBUG | ClassReader.SKIP_FRAMES); } }

Target:
public void testSafelyHandleModuleInfo() throws IOException { try (ZipFile zipFile = new ZipFile(libraryModuleInfoJar.toFile())) { ZipEntry entry = zipFile.getEntry("module-info.class"); ClassCache cache = new ClassCache( ImmutableSet.of(), ImmutableSet.of(), ImmutableSet.of(), ImmutableSet.of(), false); try (InputStream classStream = zipFile.getInputStream(entry)) { ClassReader reader = new ClassReader(classStream); DepsCheckerClassVisitor checker = new DepsCheckerClassVisitor(cache, null); reader.accept(checker, ClassReader.SKIP_DEBUG | ClassReader.SKIP_FRAMES); } } }
Source:
private static TenantId tenantOf(Iterable<Command> commands) { Iterator<Command> iterator = commands.iterator(); if (!iterator.hasNext()) { return TenantId.getDefaultInstance(); } TenantId result = iterator.next().tenant(); return result; }

Target:
private static TenantId tenantOf(Iterable<Command> commands) { Iterator<Command> iterator = commands.iterator(); return iterator.hasNext() ? iterator.next().tenant() : TenantId.getDefaultInstance(); }
Source:
public void higherTrustLevelWins() throws MalformedURLException, IOException, FetcherException { final URL lowUrl = new URL("<LINK_0>"); final URL highUrl = new URL("<LINK_1>"); FulltextFetcher finderHigh = mock(FulltextFetcher.class); FulltextFetcher finderLow = mock(FulltextFetcher.class); when(finderHigh.getTrustLevel()).thenReturn(TrustLevel.SOURCE); when(finderLow.getTrustLevel()).thenReturn(TrustLevel.UNKNOWN); when(finderHigh.findFullText(entry)).thenReturn(Optional.of(highUrl)); when(finderLow.findFullText(entry)).thenReturn(Optional.of(lowUrl)); FulltextFetchers fetcher = new FulltextFetchers(new HashSet<>(Arrays.asList(finderLow, finderHigh))); assertEquals(Optional.of(highUrl), fetcher.findFullTextPDF(entry)); }

Target:
public void higherTrustLevelWins() throws MalformedURLException, IOException, FetcherException { final URL lowUrl = new URL("<LINK_0>"); final URL highUrl = new URL("<LINK_1>"); FulltextFetcher finderHigh = mock(FulltextFetcher.class); FulltextFetcher finderLow = mock(FulltextFetcher.class); when(finderHigh.getTrustLevel()).thenReturn(TrustLevel.SOURCE); when(finderLow.getTrustLevel()).thenReturn(TrustLevel.UNKNOWN); when(finderHigh.findFullText(entry)).thenReturn(Optional.of(highUrl)); when(finderLow.findFullText(entry)).thenReturn(Optional.of(lowUrl)); FulltextFetchers fetcher = new FulltextFetchers(Set.of(finderLow, finderHigh)); assertEquals(Optional.of(highUrl), fetcher.findFullTextPDF(entry)); }
Source:
public List<Block> filter(Block block) { if (VALID_PLAINTEXT_BLOCKS.contains(block.getClass())) { return Collections.singletonList(block); } if (LinkBlock.class.isAssignableFrom(block.getClass()) && block.getChildren().isEmpty()) { ResourceReference reference = ((LinkBlock) block).getReference(); try { String label; ResourceType resourceType = reference.getType(); boolean cond = ResourceType.DOCUMENT.equals(resourceType) || ResourceType.SPACE.equals(resourceType); label = cond ? this.linkLabelGenerator.generate(reference) : reference.getReference(); return this.plainTextParser.parse(new StringReader(label)).getChildren().get(0).getChildren(); } catch (ParseException e) { throw new RuntimeException("Failed to parse link label as plain text", e); } } return Collections.emptyList(); }

Target:
public List<Block> filter(Block block) { if (VALID_PLAINTEXT_BLOCKS.contains(block.getClass())) { return Collections.singletonList(block); } if (LinkBlock.class.isAssignableFrom(block.getClass()) && block.getChildren().isEmpty()) { ResourceReference reference = ((LinkBlock) block).getReference(); return filterLinkBlock(reference); } return Collections.emptyList(); }
Source:
public synchronized Optional<ConnectorOutputMetadata> finishInsert(ConnectorSession session, ConnectorInsertTableHandle insertHandle, Collection<Slice> fragments) { requireNonNull(insertHandle, "insertHandle is null"); checkArgument(insertHandle instanceof MemoryInsertTableHandle); MemoryInsertTableHandle memoryInsertHandle = (MemoryInsertTableHandle) insertHandle; updateRowsOnHosts(memoryInsertHandle.getTable(), fragments); return Optional.empty(); }

Target:
public synchronized Optional<ConnectorOutputMetadata> finishInsert(ConnectorSession session, ConnectorInsertTableHandle insertHandle, Collection<Slice> fragments) { requireNonNull(insertHandle, "insertHandle is null"); MemoryInsertTableHandle memoryInsertHandle = (MemoryInsertTableHandle) insertHandle; updateRowsOnHosts(memoryInsertHandle.getTable(), fragments); return Optional.empty(); }
Source:
private String asString(Object value) { if ( value instanceof String ) { return ( String ) value; } Integer i = (Integer) value; if ( i == 0 ) return ""; else return enumValues[((Integer) value) - 1]; }

Target:
private String asString(Object value) { if ( value instanceof String ) { return ( String ) value; } Integer i = (Integer) value; if ( i == 0 ) return null; else return enumValues[((Integer) value) - 1]; }
Source:
public void setup() { Link link = new Link(new Shell(), SWT.NONE); event = new HyperlinkEvent(link, "uri://test", "link", 0); linkEventConsumer = new HyperlinkEventConsumer(); }

Target:
public void setup() { event = new HyperlinkEvent(link, "uri://test", "link", 0); linkEventConsumer = new HyperlinkEventConsumer(); }
Source:
public void run() { if (logger.isDebugEnabled()) { logger.debug("Read selector running for connections to " + this.getHost() + ":" + this.getPort()); } try { this.selector = Selector.open(); while (this.isActive()) { SocketChannel newChannel; int soTimeout = this.getSoTimeout(); int selectionCount = 0; try { selectionCount = selector.select(soTimeout < 0 ? 0 : soTimeout); } catch (CancelledKeyException cke) { if (logger.isDebugEnabled()) { logger.debug("CancelledKeyException during Selector.select()"); } } catch (ClosedSelectorException cse) { throw cse; } while ((newChannel = newChannels.poll()) != null) { try { newChannel.register(this.selector, SelectionKey.OP_READ, channelMap.get(newChannel)); } catch (ClosedChannelException cce) { if (logger.isDebugEnabled()) { logger.debug("Channel closed before registering with selector for reading"); } } catch (ClosedSelectorException cse) { throw cse; } } this.processNioSelections(selectionCount, selector, null, this.channelMap); } } catch (ClosedSelectorException cse) { if (this.isActive()) { logger.error("Selector closed", cse); } } catch (Exception e) { logger.error("Exception in read selector thread", e); this.setActive(false); } if (logger.isDebugEnabled()) { logger.debug("Read selector exiting for connections to " + this.getHost() + ":" + this.getPort()); } }

Target:
public void run() { if (logger.isDebugEnabled()) { logger.debug("Read selector running for connections to " + this.getHost() + ":" + this.getPort()); } try { this.selector = Selector.open(); while (this.isActive()) { SocketChannel newChannel; int soTimeout = this.getSoTimeout(); int selectionCount = 0; try { selectionCount = selector.select(soTimeout < 0 ? 0 : soTimeout); } catch (CancelledKeyException cke) { if (logger.isDebugEnabled()) { logger.debug("CancelledKeyException during Selector.select()"); } } while ((newChannel = newChannels.poll()) != null) { try { newChannel.register(this.selector, SelectionKey.OP_READ, channelMap.get(newChannel)); } catch (ClosedChannelException cce) { if (logger.isDebugEnabled()) { logger.debug("Channel closed before registering with selector for reading"); } } } this.processNioSelections(selectionCount, selector, null, this.channelMap); } } catch (ClosedSelectorException cse) { if (this.isActive()) { logger.error("Selector closed", cse); } } catch (Exception e) { logger.error("Exception in read selector thread", e); this.setActive(false); } if (logger.isDebugEnabled()) { logger.debug("Read selector exiting for connections to " + this.getHost() + ":" + this.getPort()); } }