This commit is contained in:
Naoyuki Kanezawa
2014-05-02 19:29:48 +09:00
parent a4effe9198
commit 3b43196cdf

View File

@@ -8,10 +8,13 @@ import java.net.URI;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.net.URL; import java.net.URL;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Logger;
public class IO { public class IO {
private static final Logger logger = Logger.getLogger(IO.class.getName());
private static final ConcurrentHashMap<String, Manager> managers = new ConcurrentHashMap<String, Manager>(); private static final ConcurrentHashMap<String, Manager> managers = new ConcurrentHashMap<String, Manager>();
/** /**
@@ -53,15 +56,17 @@ public class IO {
} catch (MalformedURLException e) { } catch (MalformedURLException e) {
throw new URISyntaxException(uri.toString(), e.getMessage()); throw new URISyntaxException(uri.toString(), e.getMessage());
} }
URI href = parsed.toURI(); URI source = parsed.toURI();
Manager io; Manager io;
if (opts.forceNew || !opts.multiplex) { if (opts.forceNew || !opts.multiplex) {
io = new Manager(href, opts); logger.info(String.format("ignoring socket cache for %s", source));
io = new Manager(source, opts);
} else { } else {
String id = Url.extractId(parsed); String id = Url.extractId(parsed);
if (!managers.containsKey(id)) { if (!managers.containsKey(id)) {
managers.putIfAbsent(id, new Manager(href, opts)); logger.info(String.format("new io instance for %s", source));
managers.putIfAbsent(id, new Manager(source, opts));
} }
io = managers.get(id); io = managers.get(id);
} }