WebLogic 10.3 doesn't implements equals() and hashCode() for TimerHandle?

Hi,
I'm using WebLogic 10.3 and need to use TimerHandle to handle some logic in my application.
Below is a scenario.
At the time by creating EJB Timer, I've saved the TimerHandle for later use into Database along with specific name as a key.
Then, at the time to execute/awaken timer I need to check that the saved TimerHandle is the same as passed Timer.
@Timeout
public void execute( final Timer timer )
// getting key from passed object in timer.getInfo().
// getting saved timerhandle by key. let's say dao.getXxxHandle(key);
// perform checking.
if ( timerHandle != null && timerHandle.equals( timer.getHandle() ) )
// do sth.
else
//do another thing.
The result is always drop in else block.
By doing this is working on WAS7 and JBoss4xx (getting to if block). I was wondering if WebLogic doesn't implements equals and hashCode method then is there another way to check that the retrieved TimerHandle is the same one as timer.getHandle()?
I'm thinking of adding some unique ID to see if timehandle is the same one or not? However as I mentioned, It works on WAS and JBoss. Does WebLogic has another way to handle my scenario?
Any help would be appreciate.
Thanks in advance,
Nattachai W.

As you have suggested, it looks like we don't override the equals() method on either our local or clustered TimerHandle implementations.
We opened a bug (9558396) so we can address it in a future patchset.
In the meantime, if you have an Oracle support contract, you could open a service request and ask for a patch for bug 9558396 to be created.
-steve-

Similar Messages

  • Implementing equals() and hashcode

    Hi,
    I need to implement equals() and hashcode() in a class. I only need to use one class variable in the equals() method; String id.
    I'm having difficulties to understand the examples I've seen - can someone please help me out?
    regards, Puzz

    And I know you said you had a hard time understanding some examples, but I'm not sure which examples you've seen. Here is some recommended reading that I think explains this concept well:
    Sun's Java Tutorial: The equals and hashCode Methods
    Josh Bloch: Effective Java
    JavaWorld: Implementing equals and hashCode
    IBM: Defining hashCode() and equals() effectively and correctly
    JavaPractices: Implementing hashCode
    JavaWorld: override hashcode/equals
    ~

  • Comparator question - changing Equals and HashCode too?

    Hi all I have an object test - this contains 2 variables:
    Int a; and Int b;Then there is a method called test() which returns a double and looks like this:
    public Double test()
    return a * (1d / b);
    }I have implemented the compareTo method do the "compareTo" test using the call to test() not on the fields directly e.g.
    this.test().compareTo(anotherObject.test()) instead of
    if (this.a != null && anotherDateInterval.a != null)
                compareTo = this.a.compareTo(anotherDateInterval.a);
            }Because I using the test() in the compareTo do I need to change the equals and hashcode method as well to reflect the use of test()?
    e.g.
    public boolean equals(Object obj)
       if (test() == null)
                if (other.test() != null)
                    return false;
            else if (!test().equals(other.test()))
                return false;
    }

    That depends if there are any class invarients that can be depended upon.
    The basic rule is that if .equals() returns true, then .compareTo() must return 0, but not necessarily the other way around. As long as this holds true, you don't really have to change .equals() or .hashCode(). If you're still using the identity equals method, then you probably don't have to worry about it. If you've overridden .equals() to be dependent upon a and b in some way, you probably do have to change the way .equals() works to make sure that .equals() doesn't return true if .compareTo() doesn't return 0.
    - Adam

  • Adding Objects To a HashSet, overriding equals and hashCode

    Hi everyone,
    I'm trying to add objects to a HashSet, using a string identifier (an attribute of these objects) to determine if two objects are equal.
    I have a class 'IntExpEvent' class that overrides the equals and hashCode methods.
    public class IntExpEvent implements ExperimentalEvent{
    public int correctAnswer;
    public String identifier;
    public IntExpEvent(String id, int correctAnswer){
         this.identifier = id;
         this.correctAnswer=correctAnswer;
    public String getID(){
         return(this.identifier);
    public boolean equals(ExperimentalEvent e){
         return (this.identifier.equals(e.getID()));
    public int hashCode(){
         System.out.println((this.getID()).hashCode());
         return (this.getID()).hashCode();
    private int hashCode=-1;
    public int hashCode() {
         if(hashCode==-1) {
         char[] ca=getID().toCharArray();
         for(int x=0;x<ca.length;x++) {
              hashCode+=ca[x];
         return(hashCode);
         IntExpEvent e1 = new IntExpEvent("test_IntExpEvent",4);
         IntExpEvent e2 = new IntExpEvent("test_IntExpEvent",6);
         HashSet hs = new HashSet();
         System.out.println(hs.add(e1));
         System.out.println(hs.add(e2));
    I can still add both e1 and e2 to the HashSet, which is what I'm trying to stop from happening. i.e. objects with the same identifier should be treated as the same object, allowing only one to be added to the HashSet. Does anyone know how I can do this? Help would be greatly appreciated

    In fact you don't override the equals method. The signature defined in the Object class is
      boolean equals(Object o)In your case it is
      boolean equals(ExperimentalEvent e)So instead of overriding the method you're overloading it.
    Regards

  • Why methods equals() and hashCode() is defined in Object Class?

    Why methods equals() and hashCode() is defined in Object Class?

    If you have two objects and you don't know (or care about) their exact types, but you still want to know if they are the same, then you can do something like this:
    Object o1 = getObject1();
    Object o2 = getObject2();
    if (o1.equals(o2)) {
      // they are the same, do something
    } else {
      // they are different, do something else
    }This could be useful if you were to write a generic cache, for example.
    A similar thing is true for hashCode(), if you want to manage things in a HashSet, you'll need them to implement hashCode().
    If Object didn't have those methods, then you'd have to write that code against a more specific interface/class and it wouldn't be so general any more.

  • Overrideing equals() and hashCode()

    This is related to my previous post. I have followed the advice that was given to me. I overrode equals() and hashcode()
    public class TwoTuple<A,B>{
         public final A first;
         public final B second;
         public TwoTuple(A a, B b){
              first = a;
              second = b;
         public boolean equals(TwoTuple tt){
            return first.equals(tt.first);
         public int hashCode(){
              return 31 * first.hashCode();
         public String toString(){
              return "Variable == " + first + "  Value == " + second;
    }Test class:
    import java.util.*;
    public class Test{
         private static Set<TwoTuple> state = new HashSet<TwoTuple>();
         public static void main(String[] args){
              state.add(new TwoTuple<String,Boolean>("Testing", true));
              state.add(new TwoTuple<String,Boolean>("Testing", true));
              state.add(new TwoTuple<String,Boolean>("Testing", true));
              for(TwoTuple tt : state){
                   System.out.println(tt);
              TwoTuple tt = new TwoTuple("Testing", true);
              System.out.println("Equals == " + tt.equals(new TwoTuple("Testing", true)));
              System.out.println("Equals == " + tt.equals(new TwoTuple("Hello", true)));
              System.out.println("Equals == " + tt.equals(new TwoTuple("abc", true)));
    }Output;
    Variable == Testing  Value == true
    Variable == Testing  Value == true
    Variable == Testing  Value == true
    Equals == true
    Equals == false
    Equals == falseI am still getting 3 elements that are identical inside my set. What am I doing wrong?

    SquareBox wrote:
    This is related to my previous post.An unrelated piece of advice that I was going to put in your previous thread (but it seems you've moved on):
    Be careful how you name your classes.
    'TwoTuple' may mean something to you, but it's not very descriptive to the rest of us. Furthermore, the word 'Tuple' suggests a very specific usage that isn't borne out in any of the methods you've implemented. What about 'Pair' or 'Couple' or 'Duo'? (In the world of names, shortest is usually best.)
    Winston

  • HashSet - equals and hashCode

    I must be missing the obvious over here..from what I understood of HashSet's/equals and hashCode, the program below should not add the Person object twice. Please suggest whats wrong...
    import java.util.*;
    public class TestHashSet2 {
    Set set = null;
    public TestHashSet2() {
    set = new HashSet();
    class Person {
    String name;
    Person(String name) {
    this.name = name;
    public boolean equals(Person person) {
    if (name.equals(person.name)) {
         return true;
    } else {
         return false;
    public int hashCode() {
    int code = name.length();
    System.out.println(" HashCode: " + code);
    return code;
    public void addPerson() {
    Person person1 = new Person("Mike");
    set.add(person1);
    Person person2 = new Person("Mike");
    System.out.println(" person1 equals person2: " + person1.equals(person2));
    set.add(person2);
    public void showPersons() {
    Iterator iterator = set.iterator();
    Object obj = null;
    while (iterator.hasNext()) {
    obj = iterator.next();
    System.out.println(" ELEMENT--> " + obj);
    System.out.println(" Number of elements in set: " + set.size());
    public static void main(String args[]) {
    TestHashSet2 tSet = new TestHashSet2();
    tSet.addPerson();
    tSet.showPersons();
    }

    the method equals(Person) has a different parameter type as equals(Object) and therefore doesn't override it. You need to change the method to equals(Object). This is a common 'gotcha' ...

  • Why Collection interface declares equals() and hashCode() method

    When I went through the source code of Collection interface, I found equals() and hashCode() are declared? Why? If a class implements this interface, it will inherit these two method from Object, and we can true to override them.

    It's probably so that they can provide the documentation that you see there.

  • How equals and hashCode fail here?

    I have a set of Address objects. The pair of equals and hashCode are generated by Eclipse as the following:
         @Override
         public int hashCode() {
              final int prime = 31;
              int result = super.hashCode();
              result = prime * result + ((city == null) ? 0 : city.hashCode());
              result = prime * result
                        + ((cityCode == null) ? 0 : cityCode.hashCode());
              result = prime * result + ((country == null) ? 0 : country.hashCode());
              result = prime * result + ((entry == null) ? 0 : entry.hashCode());
              result = prime * result + ((number == null) ? 0 : number.hashCode());
              result = prime * result + ((phone == null) ? 0 : phone.hashCode());
              result = prime * result
                        + ((postalCode == null) ? 0 : postalCode.hashCode());
              result = prime * result
                        + ((province == null) ? 0 : province.hashCode());
              result = prime * result + ((street == null) ? 0 : street.hashCode());
              return result;
         /* (non-Javadoc)
          * @see java.lang.Object#equals(java.lang.Object)
         @Override
         public boolean equals(Object obj) {
              if (this == obj)
                   return true;
              if (!super.equals(obj))
                   return false;
              if (getClass() != obj.getClass())
                   return false;
              final AddressEntity other = (AddressEntity) obj;
              if (city == null) {
                   if (other.city != null)
                        return false;
              } else if (!city.equals(other.city))
                   return false;
              if (cityCode == null) {
                   if (other.cityCode != null)
                        return false;
              } else if (!cityCode.equals(other.cityCode))
                   return false;
              if (country == null) {
                   if (other.country != null)
                        return false;
              } else if (!country.equals(other.country))
                   return false;
              if (entry == null) {
                   if (other.entry != null)
                        return false;
              } else if (!entry.equals(other.entry))
                   return false;
              if (number == null) {
                   if (other.number != null)
                        return false;
              } else if (!number.equals(other.number))
                   return false;
              if (phone == null) {
                   if (other.phone != null)
                        return false;
              } else if (!phone.equals(other.phone))
                   return false;
              if (postalCode == null) {
                   if (other.postalCode != null)
                        return false;
              } else if (!postalCode.equals(other.postalCode))
                   return false;
              if (province == null) {
                   if (other.province != null)
                        return false;
              } else if (!province.equals(other.province))
                   return false;
              if (street == null) {
                   if (other.street != null)
                        return false;
              } else if (!street.equals(other.street))
                   return false;
              return true;
         }But, the following code fails on the removing an Address object
              boolean found = false;
              for(Address ae : entry.getAddresses()){
                   if((int)ae.getId() == aId){
              if(!entry.removeAddress(address))
                   logger.error("Fail to remove address with ID: " + address.getId());
                        found = true;
                        break;

    warnerja wrote:
    The removeAddress method is implemented as the following:
              address.setEntry(null);
              return addresses.remove(address);
    So you set the entry property to null (and presumably it wasn't null beforehand), and then invoke remove with that object. Well, since entry is one of the properties included in the criteria for equality, don't you see a problem with that? It can't find an object "equal" to that one, since the only ones it finds don't match ALL of the fields included in the equality criteria anymore, since you just wiped out one of them on the target object to find.
    Here's another thing that looks suspect:
    for(Address ae : entry.getAddresses()){
    if(!entry.removeAddress( address ))
    ...Note the bolded parts. Anything strike you as odd?warnerja spotted my careless code. I shouldn't have address.setEntry(null); before the removal. After one attribute is changed, the object definitely is not the same again.
    BTW, sorry for little bit messy on the sample code. I put together code from various classes to illustrate the problem.

  • I have samsung corby gts3653 mobile and need to connect internet to mac through it but it doesn't have wifi and pcsuite for mac and how could i able to connect it through gprs? GPRS is active in mobile but unable to link it with macbook pro(using lion os)

    i have samsung corby gts3653 mobile and need to connect internet to mac through it but it doesn't have wifi and pcsuite for mac and how could i able to connect it, through gprs? GPRS is active in mobile but unable to link it with macbook pro(using lion os) can any one reply.

    Until the MacBook Air was released and supported in 10.5, the Mac did not consider USB to be a valid Networking Protocol. So set the Mac with USB solutions aside.
    To connect computer-to-computer, you typically need to be using an Ethernet crossover cable. Assigning the same address to two Ethernet devices is never the solution -- it gives a Network Conflict, just as you said.
    If your Windows box has some mechanism for Sharing its WiFi connection over Ethernet, you would have to follow its rules. Whether that means Manually assigning an Ethernet Address in the same range or the PC will provide the Address, I do not know.
    Best success may be running an Ethernet cable to your Wired/Wireless Base Station, or using a "gaming adapter" (Ethernet-to-Wireless no drivers required) connected to the Mac's Ethernet port to give it WiFi access. What is your Base Station {Cable, DSL, FIOS, Other} ? Ethernet cables can be up to 100 meters (an American Football Field). Often the Base Station can be moved closer for more convenience.

  • Overriding equals and hashCode

    Everywhere I look it talks about overriding equals and hashCode together, and it also warns that doing it wrong could complicate things severly. However I haven't been able to find good documentation on how to do it properly.
    Any suggestions on where to find this out, or how to properly override the two?

    Thank you!!
    I have to say I have been very impressed with this forum. I have posted on many java forums recently with little or no success. This forum has been great, I normally get responses if a few minutes and they are all very helpful.
    thanks again

  • Comparing dynamic fields of objects using equals and hashCode methods

    To compare the different objects of the same class with their contents like jobTitleId, classificationId, deptId & classificationId was to be done and do some manipulations later using Set and Map. I was able to do that by simply overriding the equals and hashCode methods of Object class and was able to fetch the information (like in the following Map).
        Map<LocationData, List<LocationData>>
    The following is the class I used (its been shown to you so that it can be referred for my problem statement):
    LocationData class
        package com.astreait.bulkloader;
        public class LocationData {    
            String locId, deptId, jobTitleId, classificationId;
            @Override  
            public boolean equals(Object obj) {        
                LocationData ld = (LocationData)obj;       
                return this.deptId.equals(ld.deptId) && this.jobTitleId.equals(ld.jobTitleId) && this.classificationId.equals(ld.classificationId) &&
        this.locId.equals(ld.locId);   
            @Override  
            public int hashCode() {        
                return deptId.hashCode() + jobTitleId.hashCode() + classificationId.hashCode() +locId.hashCode();  
    Problem:
    I'm already known to which all fields of this object I need to make the comparison.
    i.e I'm bound to use the variables named classificationId, deptId, jobTitleId & locId etc.
    Need:
    I need to customize this logic such that the fields Names (classificationId, deptId, jobTitleId & locId etc) can be pulled dynamically along with their values. So, as far as my understanding I made use of 2 classes (TableClass and ColWithData) such that the List of ColWithData is there in TableClass object.
    I'm thinking what if I override the same two methods `equals() & hashCode();`
    such that the same can be achieved.
        TableClass class #1
        class TableClass{
            List<ColWithData> cwdList;
            @Override
            public boolean equals(Object obj) {
                boolean returnVal = false;
                        // I need to have the logic to be defined such that
                        // all of the dynamic fields can be compared
                return returnVal;
            @Override
            public int hashCode() {
                int returnVal = 0;
                        // I need to have the logic to be defined such that
                        // all of the dynamic fields can be found for their individual hashCodes
                return returnVal;
    ColWithData class #2
        class ColWithData{
            String col; // here the jobTitleId, classificationId, deptId, locId or any other more fields info can come.
            String data; // The corresponding data or value for each jobTitleId, classificationId, deptId, locId or any other more fields.
    Please let me know if I'm proceeding in the right direction or I should make some any other approach. If it is ok to use the current approach then what should be performed in the equals and hashCode methods?
    Finally I need to make the map as: (Its not the concern how I will make, but can be considered as my desired result from this logic)
        Map<TableClass, List<TableClass>> finalMap;

    Hello,
    What is the relation with the Oracle Forms tool ?
    Francois

  • Problem in not overriding equals and Hashcode

    I have a very small question. We know that if we do not override the equals and hascode of Object class, we can not use the object in the Hashed collection. Can anybody provide me a concrete example which indicates the problem if we do not override the equals and hascode.

    back to the original question from DebadattaMishra
    I have a very small question. We know that if we do
    not override the equals and hascode of Object class,
    we can not use the object in the Hashed collection.
    Can anybody provide me a concrete example which
    indicates the problem if we do not override the
    equals and hascode.lets extend the example from jverd. Suppose we have a Person and want to store some Score in a HashMapclass Person {
        String name;
        Person(String name) {
            this.name = name;
    class Score {
        int value;
        Score(int value) {
            this.value = value;
    public class PersonTest {
        Map<Person, Score> map = new HashMap<Person, Score>();
        void test() {
            map.put(new Person("John"), new Score(1));
            map.put(new Person("Maria"), new Score(2));
            Score score = searchScore("John");
            System.out.println("Found: " + score);  // Found: null
        Score searchScore(String name) {
            return map.get(new Person(name));
    }if you run test() you will get "Found: null" since the John instance in the HashMap is not the same as used in searchScore. HashMap uses the equals method from Object since we have not overridden it.
    If we add an equals methodclass Person {
        String name;
        Person(String name) {
            this.name = name;
        public boolean equals(Object obj) {
            if(obj instanceof Person) {
                Person p = (Person) obj;
                return name.equals(p.name);
            } else {
                return false;
        // hashcode not overridden
    }we probably will get "Found: null" most if the time. The HashMap uses the hashcode() to create an index for saving the keys, so it mostly will not find the Person.((there is still a very small probability that the correct Person is found))
    It will work fine if we add a hashcode like    public int hashCode() {
            return name.hashCode();
        }I hope this example helped.

  • Safari doesn't open facebook and yahoo for a week now. What should I do?

    It only started last week.  Everytime I go to www.facebook, safari won't let it load, it kept on saying that "the server is busy, there was a problem, etc..." I cleared my cache, cookies, and everything.  Then once I go back again, facebook will load, then I will be able to sign in, then after signing in, it suddenly froze up and i couldn't click anything.  I'm sure I didn't do anything, and I don't know why it kept on doing that.  Then 3 days ago, that same thing happen to www.yahoo.com.  every time i go to yahoo, safari won't load at all.  What do you think is the problem? I've read the other discussions here about safari not opening facebook or yahoo.  I tried the delete cookies, database, etc., but it still doesn't work... Anyone who can help will be appreciated!

    Contact Apple directly >  Contacting Apple for support and service

  • Objectmodel equals() and hashCode()

    Hello,
    all my objects have a db-id:
    class Emp {
    private Long id;
    Now i have overridden the equals()-method like this:
    public boolean equals(Object obj) {
    if (obj instanceof Emp) {
    if (((Emp)obj).getId().equals(id)) {
    return true;
    return false;
    and the hashCode()-method like this:
    public int hashCode() {
    return id.intValue() * 17;
    I wonder what I should do with new objects, cos the id is null until a commit updated the cache-object. Any suggestion on this?
    Steffen

    equals is a business level definition. In the case where the id is null, you'll need to make the comparison on whatever fields you feel are necessary in your business domain. It may require doing comparisons on other fields, etc. Or, since an object with a null id is obviously new and uncommitted, you may be able to assume it's not .equals to anything else. It really depends on your business domain and where/how you're using it.
    - Don

Maybe you are looking for

  • CVI localtime to get the Day of the Year

    I have a vendor supplied driver that needs the day of the year (0-365), minutes, hours, seconds for their board so that it updates itself to the correct time. I am looking at the LabWindows/CVI functions time and localtime to get this information. Th

  • Ftp setup - can't get kernel!

    Actually, I ripped a friends PC to install arch on it. While I wanted to install the kernel-scsi-image, I fetch response of the system that it can't find the image. Has anyone removed the kernel images, that are used by the arch iso cd???? I used ftp

  • Tab table in Oracle database

    Hi All, This is regarding the Tab table in the oracle database. When I query this Tab table using a database account I cannot see some of the tables in it, where as using another database accout I can see all those tables. Any idea why?

  • Exception in CMS when transporting the Components in the assembly stage

    Hi, I am getting the following exception in CMS when transporting the Components in the assembly stage: com.sap.cms.tcs.interfaces.exceptions.TCSFileCreateException: cannot create file:*****.sca Error adding file *****/pr_deployarchivedr/TestDc.sda t

  • Optimization for 256 MB of ram server running apache/postgresql

    Hi, I'm on a VPS for 256 MB of ram planning to run Apache and PostgreSQL. Does anyone have recommendations on some settings to use so I can avoid blowing up the server with memory problems due to unnecessary spawning of workers or something like that