Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unregisterInterest cause problem #22

Open
GoogleCodeExporter opened this issue Aug 29, 2015 · 0 comments
Open

unregisterInterest cause problem #22

GoogleCodeExporter opened this issue Aug 29, 2015 · 0 comments

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?
1.In PhotoShare,take a picture ,add a attribute ,for example "test", "test" is 
automatically added as interest by PhotoShare.Then PhotoShare will receive and 
show this picture.

2.Delete the interest "test" ,and now PhotoShare can no longer receive any 
picture.You can take some more pictures ,name them any attributes,but 
PhotoShare cannot recieve and show them. 

I guess it is the call h.unregisterInterest() cause problem,so I did something 
to test it.

3.Here is TestApp.java which I've done a little change for my test.When 
unregisterInterest() is called,it seems to caused problem.

Code changed is here :
Attribute[] attrs = new Attribute[num_dataobjects];
DataObject[] dobjs = new DataObject[num_dataobjects];
for (int i = 0; i < num_dataobjects; i++) {
    attrs[i] = new Attribute("num", "" + i, 1);
    h.registerInterest(attrs[i]);
    dobjs[i] = new DataObject();
    dobjs[i].addAttribute("num", "" + i, 1);
    h.publishDataObject(dobjs[i]);
    Thread.sleep(2000);
}

...

public synchronized void onNewDataObject(DataObject dObj) {
    num_dataobjects_received++;
    Attribute attr = dObj.getAttribute("num", 0);
    h.unregisterInterest(attr);
    System.out.println("Got data object " + " filepath="
        + dObj.getFilePath());
    dObj.dispose();
}


What is the expected output? What do you see instead?

If variable num_dataobjects is 10 ,we should receive 10 dataobjects with 
attribute num:0,num:1,num:2...,num:10.
But I only received one dataobject num:0.
OnNewDataObject() was called only once.
I guess it was "h.unregisterInterest()" that caused this problem,so I commented 
it:

public synchronized void onNewDataObject(DataObject dObj) {
    num_dataobjects_received++;
    //Attribute attr = dObj.getAttribute("num", 0);
    //h.unregisterInterest(attr);
    System.out.println("Got data object " + " filepath="
        + dObj.getFilePath());
    dObj.dispose();
}

Program ran correctly,10 dataobjects was received.

When unregisterInterest() was called,you could no longer receive dataobjects.

What version of the product are you using? On what operating system?

Haggle-0.4 on android 2.2

Please provide any additional information below.

Original issue reported on code.google.com by Donzell...@gmail.com on 27 May 2011 at 8:13

Attachments:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant