How should i protect accept() method from TooManyOpenFiles?

I am calling accept() method assuming it will always work, considering it might result in NULL, but i've noticed in some situations the accept will fail and result in a CPU problem because it fails and since i did not do anything with the failure the key might still be valid and it tries to accept over and over again.
What is the right thing to do here - should i surround with try-catch and it will not attempt to accept the connection again?
        SocketChannel channel = ((ServerSocketChannel) key.channel()).accept();
        if (channel != null)
            if (!isApprovedClient(channel))
                channel.close();
                channel = null;
                rejectedClients++;
                return;
            acceptedClients++;
            channel.configureBlocking(false);
            BasicContext context = onClientAccept(channel);
            context.setCurrentSocket(channel);
            context.setEstablishTime();
            channel.register(selector, SelectionKey.OP_READ, context);
            log.log(Level.FINER, "Added main-channel {0}", channel.socket().getInetAddress());
        }

I am calling accept() method assuming it will always work, considering it might result in NULL, but i've noticed in some situations the accept will failFail how?
and result in a CPU problemWhat CPU problem?
because it fails and since i did not do anything with the failure the key might still be validWhat key? The key of the ServerSocketChannel? It is valid until you close or deregister it. Nothing to do with accept failures.
and it tries to accept over and over again.If the accept fails there is no SocketChannel to leak/to be closed.

Similar Messages

  • Due to virus attack i had to format my windows laptop...now when i installed new itunes software i had to sync my ipod touch again but it says that if do the same then the data on my ipod touch will be erased....how should i protect my ipod touch data?

    due to the virus attack i had to format my windows laptop...now when i installed new itunes software i had to sync my ipod touch again but it says that if i do it then the data present on my ipod touch will be erased as it is syncd to some older library... how should i protect my ipod touch data?

    With all you media (apps, music) in the iTunes library connect the iPod to the computer and make a backup. Do that by right clicking on the iPod under Devices in iTunes and select Back Up. Then restore the iPod from that backup.
    Note the the iPod backup that iTunes makes does not included synced media like apps and music.

  • How to call jpf controller method from javascript

    Can any one help me how to call pageflow controller method from JavaScript.\
    Thanks.

    Accessing a particular pageflow method from Javascript is directly not possible unless we do some real funky coding in specifying document.myForm.action = xyz...Heres what I tried and it did not work as expected: I found another workaround that I will share with you.
    1. In my jsp file when I click a button a call a JavaScript that calls the method that I want in pageflow like this: My method got invoked BUT when that method forwards the jsp, it lost the portal context. I saw my returned jsp only on the browser instead of seeing it inside the portlet on the page of a portal. I just see contents of jsp on full browser screen. I checked the url. This does make the sense. I do not see the url where I will have like test1.portal?_pageLabe=xxx&portlet details etc etc. So this bottom approach will notwork.
    document.getElementById("batchForm").action = "/portlets/com/hid/iod/Batches/holdBatch"; // here if you give like test1.portal/pagelable value like complete url...it may work...but not suggested/recommended....
    document.getElementById("batchForm").submit;
    2. I achieved my requirement using a hidden variable inside my netui:form tag in the jsp. Say for example, I have 3 buttons and all of them should call their own action methods like create, update, delete on pageflow side. But I want these to be called through javascript say for example to do some validation. (I have diff usecase though). So I created a hidden field like ACTION_NAME. I have 3 javascript functions create(), update() etc. These javascripts are called onclick() for these buttons. In thse functions first I set unique value to this hiddent field appropriately. Then submit the form. Note that all 3 buttons now go to same common action in the JPF. The code is like this.
    document.getElementById("ACTION_NAME").value = "UPDATE";
    document.getElementById("batchForm").submit.
    Inside the pageflow common method, I retriev this hidden field value and based on its value, I call one of the above 3 methods in pageflow. This works for me. There may be better solution.
    3. Another usecase that I want to share and may be help others also. Most of the time very common usecase is, when we select a item in a drop bos or netui:select, we want to invoke the pageflow action. Say we have 2 dropdown boxes with States and Cities. Anytime States select box is changed, it should go back to server and get new list of Cities for that state. (We can get both states and cities and do all string tokenizer on jsp itself. But inreality as per business needs, we do have to go to server to get dynamic values. Here is the code snippet that I use and it works for all my select boxes onChange event.
    This entire lines of code should do what we want.
    <netui:anchor action="selectArticleChanged" formSubmit="true" tagId="selectPropertyAction"/>                    
    <netui:select onChange="document.getElementById(lookupIdByTagId('selectPropertyAction',this )).onclick();" dataSource="pageFlow.selectedArticleId" >
    <c:forEach items="${requestScope.ALL_ARTICLE}" var="eachArticle">
    <%-- workshop:varType="com.hid.iod.forms.IoDProfileArticleRelForm" --%>
    <netui:selectOption value="${eachArticle.articleIdAsString}">${eachArticle.articleItemName}</netui:selectOption>
    </c:forEach>               
    </netui:select>
    See if you can build along those above lines of code. Any other simpler approches are highly welcome.
    Thanks
    Ravi Jegga

  • How can i protect my iphone from virus

    How can i protect my iphone from virus plz gelp me

    Don't jailbreak it.
    As long as you do not hack it, then you have nothing to fear.

  • How to call a bean method from javascript event

    Hi,
    I could not find material on how to call a bean method from javascript, any help would be appreciated.
    Ralph

    Hi,
    Basically, I would like to call a method that I have written in the page java bean, or in the session bean, or application bean, or an external bean, from the javascript events (mouseover, on click, etc...) of a ui jsf component. I.e., I would like to take an action when a user clicks in a column in a datatable.
    Cheers,
    Ralph

  • How I can change Valuation Method from Moving Average to Standar

    Hi Experts:
    How I can change Valuation Method from Moving Average to Standar for an item that has bookings. We running Sap Business One 2007 A, PL 45...
    Thanks very in advance.
    Claudia

    Hi
    You can change the valuation method, but for that you need to have zero physical stock for that item.
    Make a Goods issue entry for that Item for all the warehouses, change the method and make goods receipt entry for that item for all the warehouse.
    Regards
    Kamlesh

  • How do you call a method from  another class without extending as a parent?

    How do you call a method from another class without extending it as a parent? Is this possible?

    Why don't you just create an instance of the class?
    Car c = new Car();
    c.drive("fast");The drive method is in the car class, but as long as the method is public, you can use it anywhere.
    Is that what you were asking or am I totally misunderstanding your question?
    Jen

  • How can I protect my MacBookPro from static electricity in my house?

    How can I protect my MacBookPro from static electricity in my house?

    I would not worry about that.
    I woud sorry more about power surges (not a grave risk unless your power in your house is twitchy) and water/soda on the keyboard or dropping.

  • How to call backing bean method from java script

    Hi,
    I would like to know how to call backing bean method from java script.
    I am aware of serverListener and [AjaxAutoSuggest article|http://www.oracle.com/technology/products/jdev/tips/mills/AjaxAutoSuggest/AjaxAutoSuggest.html]
    but i am running in to some issues with [AjaxAutoSuggest article|http://www.oracle.com/technology/products/jdev/tips/mills/AjaxAutoSuggest/AjaxAutoSuggest.html]
    regarding which i asked for help in other thread with subject ....Question on AjaxAutoSuggest article (Ajax Transactions Using ADF and J...)
    The reason why i posted is ( though i realise both are duplicates) .. that threads looks as a specific question to that article hence i would like to ask the quantified problem is asked in this thread.
    So could any please letme know how to call backing bean method from java script
    Thanks
    Murali
    Edited by: mchepuri on Oct 24, 2009 6:17 PM
    Edited by: mchepuri on Oct 24, 2009 6:20 PM

    Hello,
    May know how to submit a button autoamtically on onload of page with clicking a welcome alert box. the submit button has managed button too to show a message on console using SOP.
    the problem is.
    1. before loading the page a javascript comes on which i clicked ok
    2. the page gets loaded and the button is there which gets automatically clicked and the managed bean associated with prints a message on console using SOP.
    I m trying to do this through server listener and click listener. the code is(adf jspx page)
    <?xml version='1.0' encoding='UTF-8'?>
    <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
    <jsp:directive.page contentType="text/html;charset=UTF-8"/>
    <f:view>
    <af:document id="d1" binding="#{backingBeanScope.backing_check4.d1}">
    <af:form id="f1" binding="#{backingBeanScope.backing_check4.f1}">
    <af:commandButton text="commandButton 1"
    binding="#{backingBeanScope.backing_check4.cb1}"
    id="cb1" action="#{beanCheck4.submit1}"/>
    <af:clientListener type="click" method="delRow"/>
    <af:serverListener type= "jsServerListener"
    method="#{backingBeanScope.backing_check4.submit1}"/>
    <f:facet name="metaContainer">
    <af:resource type ="javascript">
    x=confirm("hi");
    // if(x){
    delRow = function(event){
    AdfCustomEvent.queue(event.getSource(), "jsServerListener", {}, false);
    return true;
    </af:resource>
    </f:facet>
    </af:form>
    </af:document>
    </f:view>
    <!--oracle-jdev-comment:auto-binding-backing-bean-name:backing_check4-->
    </jsp:root>
    the backing bean code is -----
    public class classCheck4 {
    public classCheck4() {
    public String submit1() {
    System.out.println("hello");
    return null;
    }

  • I have forgot my ipod passcode how should i remove the passcode from it

    i have forgot my ipod passcode how should i remove the passcode from it

    Connect the iOS device to your computer and restore via iTunes. Place the iPod in Recovery Mode if necessary to allow the restore.
    If recovery mode does not work try DFU mode.
    How to put iPod touch / iPhone into DFU mode « Karthik's scribblings
    For how to restore:
    iTunes: Backing up, updating, and restoring iOS software
    To restore from backup see:
    iOS: How to back up
    If you restore from iCloud backup the apps will be automatically downloaded. If you restore from iTunes backup the apps and music have to be in the iTunes library since synced media like apps and music are not included in the iPod backup that iTunes makes.
    You can redownload iTuns purchases by:
    Downloading past purchases from the App Store, iBookstore, and iTunes Store

  • HT2731 how can my computer accept cookies from itunes music store

    how can my computer accept cookies from itunes music store

    Well on a Mac, you enable cooks in your Safari browser....
    But you're on Windows?

  • How can i protect J2EE applications from piracy?

    I m looking for solution to protect Web application from piracy.
    I want my application run on web server for which it is built, &
    it musn't run on any other web server.
    how can i protect my web application from piracy?.
    Our .Net applications we protect using Hardware ID binding ,
    How can i protect J2EE applications?

    How is it going to get anywhere else? What's the threat model here? and what's the real, not imaginary, cost to you of the threat succeeding? and can you price your product such that it's cheaper to buy it than to pirate it?
    The answers to this question probably aren't in the field of tricky code or cryptography. They're more likely in marketing, time-to-market, pricing, and in physical security of the server, ...

  • How to call Backing Bean method from href tag in JSF. -- URGENT

    Hi guys,
    i am new to JSF. i want one option. how to call a backing bean method from href.
    I searched a lot. i found one component <commandLink>, but i cann't use <commandLink> i have to use only href which is client instructions.
    If anyone knows pls help me. Its Urgent. If u can, give me the code also.
    Suggestions will be appreciated.
    Thanks
    Rajesh

    You can make use of the constructor of the backing bean or the @PostConstruct annotation if you want to use managed properties.
    You may get some ideas out of this: [http://balusc.blogspot.com/2006/06/communication-in-jsf.html].

  • How should I protect my MBP?

    I am thinking of getting a Speck SeeThru Transparent hardshell case because I want to protect my MB from scractes and at the same time, I can still see the aluminium skin of my MB.
    But I have read a lot of reviews that it is just better to use a sleeve case for MB since the speck hardshell case add on weight and makes it more bulky.
    So if I were to buy a sleeve case for my MB, does a protector film on the macbook cover is even neccessary?
    And should I get a trackpad protector film?

    Personal Choice !
    I use Black Satin
    https://www.speckproducts.com/macbook-cases/macbook-pro-seethru-satin.html
    The Apple logo shines through, it looks smart in my opinion.
    http://www.google.co.uk/imgres?q=Black+Satin+apple+logo+speck&hl=en&sa=X&biw=129 7&bih=692&tbm=isch&prmd=imvns&tbnid=QuitjStXE93W7M:&imgrefurl=http://www.geekinh eels.com/2012/01/24/cool-tool-tuesdays-what-i-use-to-clean-and-protect-my-macboo k-pro.html&docid=33nHdnIIcBUbEM&imgurl=http://www.geekinheels.com/wp-content/upl oads/2012/01/speck_product_seethru_satin_case_apple_logo.jpeg&w=400&h=318&ei=tRi AT_6ZKqWr0QXSk_mWBw&zoom=1&iact=hc&vpx=407&vpy=154&dur=166&hovh=200&hovw=252&tx= 63&ty=147&sig=103331582394836820815&page=1&tbnh=150&tbnw=202&start=0&ndsp=15&ved =1t:429,r:1,s:0,i:69

  • How should I protect my code?

    Hi,
    To start with I'd like to apologize if I've posted this question in the wrong forum. I wasn't quite sure where to post it.
    Ok, here goes. I've gotten a contract to design a database connected website for a government organization. One of the conditions of the contract is that I have to provide them with 'access' to the source code for the system I write. I haven't done a licensing agreement for the project yet, but they've already been made aware that they will receive a license and will not be allowed to use any of the source code for purposes other than expanding their system. This is fine with them. Now here's where I'm at a loss of what to do...
    I know there will be future contracts awarded to continue the development of this system. However, the future contracts will be for more money and will involve less work than the orignal contract I'm doing (it's the government and they really have no comprehension of what's involved). So, I basically want to fulfill my legal obligation of providing source code, but I want to make it as difficult as possible for someone to build into the system I write. Here's what I've come up with so far.
    1. Try to get a licensing agreement that forces them to obtain written permission before modifying any source code for future development (which will be necessary).
    2. I've seen programs that will make code very unreadable after it's been decompiled. Is there anything that will do a similar thing to source code? For example, remove all comments and rename all the variables to something like 'an5the32'.
    I know this sounds kind of greedy, but the scope of this project is considerably larger than I realized (was led to believe) and without landing one of the future contracts I'm getting ripped off, so I really have no reservations about making things difficult for them. Any suggestions would be appreciated.

    Have you seen this site?
    http://mindprod.com/unmainobfuscation.html
    In all seriousness, there are several source code
    obfuscation tools available, Just use Google and
    search for "source obfuscator Java" or like.
    Some of the products I found but never tested are:
    http://www.semdesigns.com/Products/Formatters/Obfuscators.html
    http://www.jdevelop.com/java-source-obfuscator.html
    For byte code obfuscators to protect the binary from being decompiled, the links in
    http://mindprod.com/jglossobfuscator.html
    I found to be quite comprehensive..
    BTW Out of all of them in the list,
    I have evaluated Dash-O and Sourceguard.
    I chose sourceguard but 4thpass chose to
    abandon the product with no notice, soon
    after we had bought it...
    Software companies doing that kind of
    thing should not last long, but anyways,
    Good luck, and happy obfuscating!
    Steve Tsang
    [email protected]

Maybe you are looking for