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

Gate isn't closed if localhost is used #25

Open
TheAIBot opened this issue Jan 18, 2018 · 0 comments
Open

Gate isn't closed if localhost is used #25

TheAIBot opened this issue Jan 18, 2018 · 0 comments

Comments

@TheAIBot
Copy link

TheAIBot commented Jan 18, 2018

As the title says, the gate isn't closed if localhost is used as the ip address. Here is a minimal example.

import java.io.IOException;
import java.net.UnknownHostException;

import org.jspace.ActualField;
import org.jspace.RemoteSpace;
import org.jspace.SequentialSpace;
import org.jspace.SpaceRepository;

public class TestStarter {
	public static void main(String[] args) throws UnknownHostException, IOException, InterruptedException {
		try {
			final SpaceRepository rep = new SpaceRepository();
			rep.addGate("tcp://localhost:1290/?conn");
			final SequentialSpace getSpace = new SequentialSpace();
			rep.add("teeest", getSpace);
			final RemoteSpace putSpace = new RemoteSpace("tcp://localhost:1290/teeest?conn");
			
			//close the gate
			rep.closeGate("tcp://localhost:1290/?conn");
			System.out.println("Gate closed");
			
			//now putting something shouldn't work
			putSpace.put("cake");
			System.out.println("Give cake");
			
			//and get also shouldn't work
			getSpace.get(new ActualField("cake"));
			System.out.println("Got cake!");
		} catch (Exception e) {
			e.printStackTrace();
		}		
	}
}

The output is:

Gate closed
Give cake
Got cake!

I would expect both the put and get to throw an error because the connection should have ended.

I should mention that this doesn't only happen with localhost but we have also experienced it with other ip addresses although i am not able to produce an example of it.
Maybe that requires the SpaceRepository and RemoteSpace to be on separate computers to reproduce?

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

No branches or pull requests

1 participant