| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
package javax.jmdns.impl; |
| 6 |
|
|
| 7 |
|
import java.io.IOException; |
| 8 |
|
import java.net.DatagramPacket; |
| 9 |
|
import java.net.Inet4Address; |
| 10 |
|
import java.net.Inet6Address; |
| 11 |
|
import java.net.InetAddress; |
| 12 |
|
import java.net.MulticastSocket; |
| 13 |
|
import java.net.SocketException; |
| 14 |
|
import java.util.AbstractMap; |
| 15 |
|
import java.util.ArrayList; |
| 16 |
|
import java.util.Collection; |
| 17 |
|
import java.util.Collections; |
| 18 |
|
import java.util.HashMap; |
| 19 |
|
import java.util.HashSet; |
| 20 |
|
import java.util.Iterator; |
| 21 |
|
import java.util.LinkedList; |
| 22 |
|
import java.util.List; |
| 23 |
|
import java.util.Map; |
| 24 |
|
import java.util.Properties; |
| 25 |
|
import java.util.Random; |
| 26 |
|
import java.util.Set; |
| 27 |
|
import java.util.concurrent.ConcurrentHashMap; |
| 28 |
|
import java.util.concurrent.ConcurrentMap; |
| 29 |
|
import java.util.concurrent.ExecutorService; |
| 30 |
|
import java.util.concurrent.Executors; |
| 31 |
|
import java.util.concurrent.locks.ReentrantLock; |
| 32 |
|
import java.util.logging.Level; |
| 33 |
|
import java.util.logging.Logger; |
| 34 |
|
|
| 35 |
|
import javax.jmdns.JmDNS; |
| 36 |
|
import javax.jmdns.ServiceEvent; |
| 37 |
|
import javax.jmdns.ServiceInfo; |
| 38 |
|
import javax.jmdns.ServiceInfo.Fields; |
| 39 |
|
import javax.jmdns.ServiceListener; |
| 40 |
|
import javax.jmdns.ServiceTypeListener; |
| 41 |
|
import javax.jmdns.impl.ListenerStatus.ServiceListenerStatus; |
| 42 |
|
import javax.jmdns.impl.ListenerStatus.ServiceTypeListenerStatus; |
| 43 |
|
import javax.jmdns.impl.constants.DNSConstants; |
| 44 |
|
import javax.jmdns.impl.constants.DNSRecordClass; |
| 45 |
|
import javax.jmdns.impl.constants.DNSRecordType; |
| 46 |
|
import javax.jmdns.impl.constants.DNSState; |
| 47 |
|
import javax.jmdns.impl.tasks.DNSTask; |
| 48 |
|
|
| 49 |
|
|
| 50 |
|
|
| 51 |
|
|
| 52 |
|
|
| 53 |
|
|
| 54 |
|
@author |
| 55 |
|
|
|
|
|
| 64.1% |
Uncovered Elements: 360 (1,002) |
Complexity: 284 |
Complexity Density: 0.45 |
|
| 56 |
|
public class JmDNSImpl extends JmDNS implements DNSStatefulObject, DNSTaskStarter { |
| 57 |
|
private static Logger logger = Logger.getLogger(JmDNSImpl.class.getName()); |
| 58 |
|
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 0 |
Complexity Density: - |
|
| 59 |
|
public enum Operation { |
| 60 |
|
Remove, Update, Add, RegisterServiceType, Noop |
| 61 |
|
} |
| 62 |
|
|
| 63 |
|
|
| 64 |
|
|
| 65 |
|
|
| 66 |
|
private volatile InetAddress _group; |
| 67 |
|
|
| 68 |
|
|
| 69 |
|
|
| 70 |
|
private volatile MulticastSocket _socket; |
| 71 |
|
|
| 72 |
|
|
| 73 |
|
|
| 74 |
|
|
| 75 |
|
private final List<DNSListener> _listeners; |
| 76 |
|
|
| 77 |
|
|
| 78 |
|
|
| 79 |
|
|
| 80 |
|
private final ConcurrentMap<String, List<ServiceListenerStatus>> _serviceListeners; |
| 81 |
|
|
| 82 |
|
|
| 83 |
|
|
| 84 |
|
|
| 85 |
|
private final Set<ServiceTypeListenerStatus> _typeListeners; |
| 86 |
|
|
| 87 |
|
|
| 88 |
|
|
| 89 |
|
|
| 90 |
|
private final DNSCache _cache; |
| 91 |
|
|
| 92 |
|
|
| 93 |
|
|
| 94 |
|
|
| 95 |
|
private final ConcurrentMap<String, ServiceInfo> _services; |
| 96 |
|
|
| 97 |
|
|
| 98 |
|
|
| 99 |
|
|
| 100 |
|
|
| 101 |
|
|
| 102 |
|
private final ConcurrentMap<String, ServiceTypeEntry> _serviceTypes; |
| 103 |
|
|
| 104 |
|
private volatile Delegate _delegate; |
| 105 |
|
|
| 106 |
|
|
| 107 |
|
|
| 108 |
|
|
| 109 |
|
|
| 110 |
|
|
| 111 |
|
|
|
|
|
| 37.1% |
Uncovered Elements: 22 (35) |
Complexity: 11 |
Complexity Density: 0.48 |
|
| 112 |
|
public static class ServiceTypeEntry extends AbstractMap<String, String> implements Cloneable { |
| 113 |
|
|
| 114 |
|
private final Set<Map.Entry<String, String>> _entrySet; |
| 115 |
|
|
| 116 |
|
private final String _type; |
| 117 |
|
|
|
|
|
| 39.3% |
Uncovered Elements: 17 (28) |
Complexity: 12 |
Complexity Density: 1 |
|
| 118 |
|
private static class SubTypeEntry implements Entry<String, String>, java.io.Serializable, Cloneable { |
| 119 |
|
|
| 120 |
|
private static final long serialVersionUID = 9188503522395855322L; |
| 121 |
|
|
| 122 |
|
private final String _key; |
| 123 |
|
private final String _value; |
| 124 |
|
|
|
|
|
| 80% |
Uncovered Elements: 1 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 125 |
2
|
public SubTypeEntry(String subtype) {... |
| 126 |
2
|
super(); |
| 127 |
2
|
_value = (subtype != null ? subtype : ""); |
| 128 |
2
|
_key = _value.toLowerCase(); |
| 129 |
|
} |
| 130 |
|
|
| 131 |
|
|
| 132 |
|
@inheritDoc |
| 133 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 134 |
7
|
@Override... |
| 135 |
|
public String getKey() { |
| 136 |
7
|
return _key; |
| 137 |
|
} |
| 138 |
|
|
| 139 |
|
|
| 140 |
|
@inheritDoc |
| 141 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 142 |
0
|
@Override... |
| 143 |
|
public String getValue() { |
| 144 |
0
|
return _value; |
| 145 |
|
} |
| 146 |
|
|
| 147 |
|
|
| 148 |
|
|
| 149 |
|
|
| 150 |
|
@param |
| 151 |
|
|
| 152 |
|
@return |
| 153 |
|
@exception |
| 154 |
|
|
| 155 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 156 |
0
|
@Override... |
| 157 |
|
public String setValue(String value) { |
| 158 |
0
|
throw new UnsupportedOperationException(); |
| 159 |
|
} |
| 160 |
|
|
| 161 |
|
|
| 162 |
|
@inheritDoc |
| 163 |
|
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 164 |
0
|
@Override... |
| 165 |
|
public boolean equals(Object entry) { |
| 166 |
0
|
if (!(entry instanceof Map.Entry)) { |
| 167 |
0
|
return false; |
| 168 |
|
} |
| 169 |
0
|
return this.getKey().equals(((Map.Entry<?, ?>) entry).getKey()) && this.getValue().equals(((Map.Entry<?, ?>) entry).getValue()); |
| 170 |
|
} |
| 171 |
|
|
| 172 |
|
|
| 173 |
|
@inheritDoc |
| 174 |
|
|
|
|
|
| 60% |
Uncovered Elements: 2 (5) |
Complexity: 3 |
Complexity Density: 3 |
|
| 175 |
2
|
@Override... |
| 176 |
|
public int hashCode() { |
| 177 |
2
|
return (_key == null ? 0 : _key.hashCode()) ^ (_value == null ? 0 : _value.hashCode()); |
| 178 |
|
} |
| 179 |
|
|
| 180 |
|
|
| 181 |
|
|
| 182 |
|
@see |
| 183 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 184 |
0
|
@Override... |
| 185 |
|
public SubTypeEntry clone() { |
| 186 |
|
|
| 187 |
0
|
return this; |
| 188 |
|
} |
| 189 |
|
|
| 190 |
|
|
| 191 |
|
@inheritDoc |
| 192 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 193 |
0
|
@Override... |
| 194 |
|
public String toString() { |
| 195 |
0
|
return _key + "=" + _value; |
| 196 |
|
} |
| 197 |
|
|
| 198 |
|
} |
| 199 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 200 |
27
|
public ServiceTypeEntry(String type) {... |
| 201 |
27
|
super(); |
| 202 |
27
|
this._type = type; |
| 203 |
27
|
this._entrySet = new HashSet<Map.Entry<String, String>>(); |
| 204 |
|
} |
| 205 |
|
|
| 206 |
|
|
| 207 |
|
|
| 208 |
|
|
| 209 |
|
@return |
| 210 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 211 |
0
|
public String getType() {... |
| 212 |
0
|
return _type; |
| 213 |
|
} |
| 214 |
|
|
| 215 |
|
|
| 216 |
|
|
| 217 |
|
@see |
| 218 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 219 |
13
|
@Override... |
| 220 |
|
public Set<Map.Entry<String, String>> entrySet() { |
| 221 |
13
|
return _entrySet; |
| 222 |
|
} |
| 223 |
|
|
| 224 |
|
|
| 225 |
|
|
| 226 |
|
|
| 227 |
|
|
| 228 |
|
@param |
| 229 |
|
|
| 230 |
|
@return |
| 231 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 232 |
13
|
public boolean contains(String subtype) {... |
| 233 |
13
|
return subtype != null && this.containsKey(subtype.toLowerCase()); |
| 234 |
|
} |
| 235 |
|
|
| 236 |
|
|
| 237 |
|
|
| 238 |
|
|
| 239 |
|
|
| 240 |
|
@param |
| 241 |
|
|
| 242 |
|
@return |
| 243 |
|
|
|
|
|
| 66.7% |
Uncovered Elements: 2 (6) |
Complexity: 3 |
Complexity Density: 0.75 |
|
| 244 |
2
|
public boolean add(String subtype) {... |
| 245 |
2
|
if (subtype == null || this.contains(subtype)) { |
| 246 |
0
|
return false; |
| 247 |
|
} |
| 248 |
2
|
_entrySet.add(new SubTypeEntry(subtype)); |
| 249 |
2
|
return true; |
| 250 |
|
} |
| 251 |
|
|
| 252 |
|
|
| 253 |
|
|
| 254 |
|
|
| 255 |
|
@return |
| 256 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 257 |
0
|
public Iterator<String> iterator() {... |
| 258 |
0
|
return this.keySet().iterator(); |
| 259 |
|
} |
| 260 |
|
|
| 261 |
|
|
| 262 |
|
|
| 263 |
|
@see |
| 264 |
|
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
| 265 |
0
|
@Override... |
| 266 |
|
public ServiceTypeEntry clone() { |
| 267 |
0
|
ServiceTypeEntry entry = new ServiceTypeEntry(this.getType()); |
| 268 |
0
|
for (Map.Entry<String, String> subTypeEntry : this.entrySet()) { |
| 269 |
0
|
entry.add(subTypeEntry.getValue()); |
| 270 |
|
} |
| 271 |
0
|
return entry; |
| 272 |
|
} |
| 273 |
|
|
| 274 |
|
|
| 275 |
|
|
| 276 |
|
@see |
| 277 |
|
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 2 |
Complexity Density: 0.25 |
|
| 278 |
0
|
@Override... |
| 279 |
|
public String toString() { |
| 280 |
0
|
final StringBuilder aLog = new StringBuilder(200); |
| 281 |
0
|
if (this.isEmpty()) { |
| 282 |
0
|
aLog.append("empty"); |
| 283 |
|
} else { |
| 284 |
0
|
for (String value : this.values()) { |
| 285 |
0
|
aLog.append(value); |
| 286 |
0
|
aLog.append(", "); |
| 287 |
|
} |
| 288 |
0
|
aLog.setLength(aLog.length() - 2); |
| 289 |
|
} |
| 290 |
0
|
return aLog.toString(); |
| 291 |
|
} |
| 292 |
|
|
| 293 |
|
} |
| 294 |
|
|
| 295 |
|
|
| 296 |
|
|
| 297 |
|
|
| 298 |
|
protected Thread _shutdown; |
| 299 |
|
|
| 300 |
|
|
| 301 |
|
|
| 302 |
|
|
| 303 |
|
private HostInfo _localHost; |
| 304 |
|
|
| 305 |
|
private Thread _incomingListener; |
| 306 |
|
|
| 307 |
|
|
| 308 |
|
|
| 309 |
|
|
| 310 |
|
private int _throttle; |
| 311 |
|
|
| 312 |
|
|
| 313 |
|
|
| 314 |
|
|
| 315 |
|
private long _lastThrottleIncrement; |
| 316 |
|
|
| 317 |
|
private final ExecutorService _executor = Executors.newSingleThreadExecutor(); |
| 318 |
|
|
| 319 |
|
|
| 320 |
|
|
| 321 |
|
|
| 322 |
|
|
| 323 |
|
|
| 324 |
|
|
| 325 |
|
|
| 326 |
|
|
| 327 |
|
|
| 328 |
|
|
| 329 |
|
|
| 330 |
|
|
| 331 |
|
|
| 332 |
|
|
| 333 |
|
|
| 334 |
|
private final static Random _random = new Random(); |
| 335 |
|
|
| 336 |
|
|
| 337 |
|
|
| 338 |
|
|
| 339 |
|
private final ReentrantLock _ioLock = new ReentrantLock(); |
| 340 |
|
|
| 341 |
|
|
| 342 |
|
|
| 343 |
|
|
| 344 |
|
|
| 345 |
|
private DNSIncoming _plannedAnswer; |
| 346 |
|
|
| 347 |
|
|
| 348 |
|
|
| 349 |
|
|
| 350 |
|
|
| 351 |
|
|
| 352 |
|
@see |
| 353 |
|
|
| 354 |
|
private final ConcurrentMap<String, ServiceCollector> _serviceCollectors; |
| 355 |
|
|
| 356 |
|
private final String _name; |
| 357 |
|
|
| 358 |
|
|
| 359 |
|
|
| 360 |
|
|
| 361 |
|
@param |
| 362 |
|
|
| 363 |
|
|
|
|
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 2 |
Complexity Density: 0.18 |
|
| 364 |
0
|
public static void main(String[] argv) {... |
| 365 |
0
|
String version = null; |
| 366 |
0
|
try { |
| 367 |
0
|
final Properties pomProperties = new Properties(); |
| 368 |
0
|
pomProperties.load(JmDNSImpl.class.getResourceAsStream("/META-INF/maven/javax.jmdns/jmdns/pom.properties")); |
| 369 |
0
|
version = pomProperties.getProperty("version"); |
| 370 |
|
} catch (Exception e) { |
| 371 |
0
|
version = "RUNNING.IN.IDE.FULL"; |
| 372 |
|
} |
| 373 |
0
|
System.out.println("JmDNS version \"" + version + "\""); |
| 374 |
0
|
System.out.println(" "); |
| 375 |
|
|
| 376 |
0
|
System.out.println("Running on java version \"" + System.getProperty("java.version") + "\"" + " (build " + System.getProperty("java.runtime.version") + ")" + " from " + System.getProperty("java.vendor")); |
| 377 |
|
|
| 378 |
0
|
System.out.println("Operating environment \"" + System.getProperty("os.name") + "\"" + " version " + System.getProperty("os.version") + " on " + System.getProperty("os.arch")); |
| 379 |
|
|
| 380 |
0
|
System.out.println("For more information on JmDNS please visit https://sourceforge.net/projects/jmdns/"); |
| 381 |
|
} |
| 382 |
|
|
| 383 |
|
|
| 384 |
|
|
| 385 |
|
|
| 386 |
|
@param |
| 387 |
|
|
| 388 |
|
@param |
| 389 |
|
|
| 390 |
|
@exception |
| 391 |
|
|
|
|
|
| 89.5% |
Uncovered Elements: 2 (19) |
Complexity: 3 |
Complexity Density: 0.2 |
|
| 392 |
29
|
public JmDNSImpl(InetAddress address, String name) throws IOException {... |
| 393 |
29
|
super(); |
| 394 |
29
|
if (logger.isLoggable(Level.FINER)) { |
| 395 |
0
|
logger.finer("JmDNS instance created"); |
| 396 |
|
} |
| 397 |
29
|
_cache = new DNSCache(100); |
| 398 |
|
|
| 399 |
29
|
_listeners = Collections.synchronizedList(new ArrayList<DNSListener>()); |
| 400 |
29
|
_serviceListeners = new ConcurrentHashMap<String, List<ServiceListenerStatus>>(); |
| 401 |
29
|
_typeListeners = Collections.synchronizedSet(new HashSet<ServiceTypeListenerStatus>()); |
| 402 |
29
|
_serviceCollectors = new ConcurrentHashMap<String, ServiceCollector>(); |
| 403 |
|
|
| 404 |
29
|
_services = new ConcurrentHashMap<String, ServiceInfo>(20); |
| 405 |
29
|
_serviceTypes = new ConcurrentHashMap<String, ServiceTypeEntry>(20); |
| 406 |
|
|
| 407 |
29
|
_localHost = HostInfo.newHostInfo(address, this, name); |
| 408 |
29
|
_name = (name != null ? name : _localHost.getName()); |
| 409 |
|
|
| 410 |
|
|
| 411 |
|
|
| 412 |
|
|
| 413 |
|
|
| 414 |
|
|
| 415 |
|
|
| 416 |
|
|
| 417 |
|
|
| 418 |
|
|
| 419 |
|
|
| 420 |
29
|
this.openMulticastSocket(this.getLocalHost()); |
| 421 |
29
|
this.start(this.getServices().values()); |
| 422 |
|
|
| 423 |
29
|
this.startReaper(); |
| 424 |
|
} |
| 425 |
|
|
|
|
|
| 60% |
Uncovered Elements: 4 (10) |
Complexity: 3 |
Complexity Density: 0.38 |
|
| 426 |
29
|
private void start(Collection<? extends ServiceInfo> serviceInfos) {... |
| 427 |
29
|
if (_incomingListener == null) { |
| 428 |
29
|
_incomingListener = new SocketListener(this); |
| 429 |
29
|
_incomingListener.start(); |
| 430 |
|
} |
| 431 |
29
|
this.startProber(); |
| 432 |
29
|
for (ServiceInfo info : serviceInfos) { |
| 433 |
0
|
try { |
| 434 |
0
|
this.registerService(new ServiceInfoImpl(info)); |
| 435 |
|
} catch (final Exception exception) { |
| 436 |
0
|
logger.log(Level.WARNING, "start() Registration exception ", exception); |
| 437 |
|
} |
| 438 |
|
} |
| 439 |
|
} |
| 440 |
|
|
|
|
|
| 66.7% |
Uncovered Elements: 8 (24) |
Complexity: 8 |
Complexity Density: 0.57 |
|
| 441 |
29
|
private void openMulticastSocket(HostInfo hostInfo) throws IOException {... |
| 442 |
29
|
if (_group == null) { |
| 443 |
29
|
if (hostInfo.getInetAddress() instanceof Inet6Address) { |
| 444 |
1
|
_group = InetAddress.getByName(DNSConstants.MDNS_GROUP_IPV6); |
| 445 |
|
} else { |
| 446 |
28
|
_group = InetAddress.getByName(DNSConstants.MDNS_GROUP); |
| 447 |
|
} |
| 448 |
|
} |
| 449 |
29
|
if (_socket != null) { |
| 450 |
0
|
this.closeMulticastSocket(); |
| 451 |
|
} |
| 452 |
29
|
_socket = new MulticastSocket(DNSConstants.MDNS_PORT); |
| 453 |
29
|
if ((hostInfo != null) && (hostInfo.getInterface() != null)) { |
| 454 |
29
|
try { |
| 455 |
29
|
_socket.setNetworkInterface(hostInfo.getInterface()); |
| 456 |
|
} catch (SocketException e) { |
| 457 |
0
|
if (logger.isLoggable(Level.FINE)) { |
| 458 |
0
|
logger.fine("openMulticastSocket() Set network interface exception: " + e.getMessage()); |
| 459 |
|
} |
| 460 |
|
} |
| 461 |
|
} |
| 462 |
29
|
_socket.setTimeToLive(255); |
| 463 |
29
|
_socket.joinGroup(_group); |
| 464 |
|
} |
| 465 |
|
|
|
|
|
| 74.1% |
Uncovered Elements: 7 (27) |
Complexity: 11 |
Complexity Density: 0.65 |
|
| 466 |
29
|
private void closeMulticastSocket() {... |
| 467 |
|
|
| 468 |
|
|
| 469 |
29
|
if (logger.isLoggable(Level.FINER)) { |
| 470 |
0
|
logger.finer("closeMulticastSocket()"); |
| 471 |
|
} |
| 472 |
29
|
if (_socket != null) { |
| 473 |
|
|
| 474 |
29
|
try { |
| 475 |
29
|
try { |
| 476 |
29
|
_socket.leaveGroup(_group); |
| 477 |
|
} catch (SocketException exception) { |
| 478 |
|
|
| 479 |
|
} |
| 480 |
29
|
_socket.close(); |
| 481 |
|
|
| 482 |
|
|
| 483 |
|
|
| 484 |
|
|
| 485 |
|
|
| 486 |
|
|
| 487 |
42
|
while (_incomingListener != null && _incomingListener.isAlive()) { |
| 488 |
13
|
synchronized (this) { |
| 489 |
13
|
try { |
| 490 |
13
|
if (_incomingListener != null && _incomingListener.isAlive()) { |
| 491 |
|
|
| 492 |
13
|
if (logger.isLoggable(Level.FINER)) { |
| 493 |
0
|
logger.finer("closeMulticastSocket(): waiting for jmDNS monitor"); |
| 494 |
|
} |
| 495 |
13
|
this.wait(1000); |
| 496 |
|
} |
| 497 |
|
} catch (InterruptedException ignored) { |
| 498 |
|
|
| 499 |
|
} |
| 500 |
|
} |
| 501 |
|
} |
| 502 |
29
|
_incomingListener = null; |
| 503 |
|
} catch (final Exception exception) { |
| 504 |
0
|
logger.log(Level.WARNING, "closeMulticastSocket() Close socket exception ", exception); |
| 505 |
|
} |
| 506 |
29
|
_socket = null; |
| 507 |
|
} |
| 508 |
|
} |
| 509 |
|
|
| 510 |
|
|
| 511 |
|
|
| 512 |
|
@inheritDoc |
| 513 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 514 |
164
|
@Override... |
| 515 |
|
public boolean advanceState(DNSTask task) { |
| 516 |
164
|
return this._localHost.advanceState(task); |
| 517 |
|
} |
| 518 |
|
|
| 519 |
|
|
| 520 |
|
@inheritDoc |
| 521 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 522 |
0
|
@Override... |
| 523 |
|
public boolean revertState() { |
| 524 |
0
|
return this._localHost.revertState(); |
| 525 |
|
} |
| 526 |
|
|
| 527 |
|
|
| 528 |
|
@inheritDoc |
| 529 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 530 |
0
|
@Override... |
| 531 |
|
public boolean cancelState() { |
| 532 |
0
|
return this._localHost.cancelState(); |
| 533 |
|
} |
| 534 |
|
|
| 535 |
|
|
| 536 |
|
@inheritDoc |
| 537 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 538 |
29
|
@Override... |
| 539 |
|
public boolean closeState() { |
| 540 |
29
|
return this._localHost.closeState(); |
| 541 |
|
} |
| 542 |
|
|
| 543 |
|
|
| 544 |
|
@inheritDoc |
| 545 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 546 |
0
|
@Override... |
| 547 |
|
public boolean recoverState() { |
| 548 |
0
|
return this._localHost.recoverState(); |
| 549 |
|
} |
| 550 |
|
|
| 551 |
|
|
| 552 |
|
@inheritDoc |
| 553 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 554 |
650
|
@Override... |
| 555 |
|
public JmDNSImpl getDns() { |
| 556 |
663
|
return this; |
| 557 |
|
} |
| 558 |
|
|
| 559 |
|
|
| 560 |
|
@inheritDoc |
| 561 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 562 |
184
|
@Override... |
| 563 |
|
public void associateWithTask(DNSTask task, DNSState state) { |
| 564 |
184
|
this._localHost.associateWithTask(task, state); |
| 565 |
|
} |
| 566 |
|
|
| 567 |
|
|
| 568 |
|
@inheritDoc |
| 569 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 570 |
133
|
@Override... |
| 571 |
|
public void removeAssociationWithTask(DNSTask task) { |
| 572 |
133
|
this._localHost.removeAssociationWithTask(task); |
| 573 |
|
} |
| 574 |
|
|
| 575 |
|
|
| 576 |
|
@inheritDoc |
| 577 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 578 |
317
|
@Override... |
| 579 |
|
public boolean isAssociatedWithTask(DNSTask task, DNSState state) { |
| 580 |
317
|
return this._localHost.isAssociatedWithTask(task, state); |
| 581 |
|
} |
| 582 |
|
|
| 583 |
|
|
| 584 |
|
@inheritDoc |
| 585 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 586 |
0
|
@Override... |
| 587 |
|
public boolean isProbing() { |
| 588 |
0
|
return this._localHost.isProbing(); |
| 589 |
|
} |
| 590 |
|
|
| 591 |
|
|
| 592 |
|
@inheritDoc |
| 593 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 594 |
0
|
@Override... |
| 595 |
|
public boolean isAnnouncing() { |
| 596 |
0
|
return this._localHost.isAnnouncing(); |
| 597 |
|
} |
| 598 |
|
|
| 599 |
|
|
| 600 |
|
@inheritDoc |
| 601 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 602 |
532
|
@Override... |
| 603 |
|
public boolean isAnnounced() { |
| 604 |
534
|
return this._localHost.isAnnounced(); |
| 605 |
|
} |
| 606 |
|
|
| 607 |
|
|
| 608 |
|
@inheritDoc |
| 609 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 610 |
2378
|
@Override... |
| 611 |
|
public boolean isCanceling() { |
| 612 |
2414
|
return this._localHost.isCanceling(); |
| 613 |
|
} |
| 614 |
|
|
| 615 |
|
|
| 616 |
|
@inheritDoc |
| 617 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 618 |
2393
|
@Override... |
| 619 |
|
public boolean isCanceled() { |
| 620 |
2417
|
return this._localHost.isCanceled(); |
| 621 |
|
} |
| 622 |
|
|
| 623 |
|
|
| 624 |
|
@inheritDoc |
| 625 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 626 |
718
|
@Override... |
| 627 |
|
public boolean isClosing() { |
| 628 |
730
|
return this._localHost.isClosing(); |
| 629 |
|
} |
| 630 |
|
|
| 631 |
|
|
| 632 |
|
@inheritDoc |
| 633 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 634 |
662
|
@Override... |
| 635 |
|
public boolean isClosed() { |
| 636 |
674
|
return this._localHost.isClosed(); |
| 637 |
|
} |
| 638 |
|
|
| 639 |
|
|
| 640 |
|
@inheritDoc |
| 641 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 642 |
20
|
@Override... |
| 643 |
|
public boolean waitForAnnounced(long timeout) { |
| 644 |
20
|
return this._localHost.waitForAnnounced(timeout); |
| 645 |
|
} |
| 646 |
|
|
| 647 |
|
|
| 648 |
|
@inheritDoc |
| 649 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 650 |
29
|
@Override... |
| 651 |
|
public boolean waitForCanceled(long timeout) { |
| 652 |
29
|
return this._localHost.waitForCanceled(timeout); |
| 653 |
|
} |
| 654 |
|
|
| 655 |
|
|
| 656 |
|
|
| 657 |
|
|
| 658 |
|
@return |
| 659 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 660 |
1974
|
public DNSCache getCache() {... |
| 661 |
1995
|
return _cache; |
| 662 |
|
} |
| 663 |
|
|
| 664 |
|
|
| 665 |
|
@inheritDoc |
| 666 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 667 |
835
|
@Override... |
| 668 |
|
public String getName() { |
| 669 |
835
|
return _name; |
| 670 |
|
} |
| 671 |
|
|
| 672 |
|
|
| 673 |
|
@inheritDoc |
| 674 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 675 |
0
|
@Override... |
| 676 |
|
public String getHostName() { |
| 677 |
0
|
return _localHost.getName(); |
| 678 |
|
} |
| 679 |
|
|
| 680 |
|
|
| 681 |
|
|
| 682 |
|
|
| 683 |
|
@return |
| 684 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 685 |
1976
|
public HostInfo getLocalHost() {... |
| 686 |
2011
|
return _localHost; |
| 687 |
|
} |
| 688 |
|
|
| 689 |
|
|
| 690 |
|
@inheritDoc |
| 691 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 692 |
0
|
@Override... |
| 693 |
|
public InetAddress getInterface() throws IOException { |
| 694 |
0
|
return _socket.getInterface(); |
| 695 |
|
} |
| 696 |
|
|
| 697 |
|
|
| 698 |
|
@inheritDoc |
| 699 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 700 |
3
|
@Override... |
| 701 |
|
public ServiceInfo getServiceInfo(String type, String name) { |
| 702 |
3
|
return this.getServiceInfo(type, name, false, DNSConstants.SERVICE_INFO_TIMEOUT); |
| 703 |
|
} |
| 704 |
|
|
| 705 |
|
|
| 706 |
|
@inheritDoc |
| 707 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 708 |
0
|
@Override... |
| 709 |
|
public ServiceInfo getServiceInfo(String type, String name, long timeout) { |
| 710 |
0
|
return this.getServiceInfo(type, name, false, timeout); |
| 711 |
|
} |
| 712 |
|
|
| 713 |
|
|
| 714 |
|
@inheritDoc |
| 715 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 716 |
0
|
@Override... |
| 717 |
|
public ServiceInfo getServiceInfo(String type, String name, boolean persistent) { |
| 718 |
0
|
return this.getServiceInfo(type, name, persistent, DNSConstants.SERVICE_INFO_TIMEOUT); |
| 719 |
|
} |
| 720 |
|
|
| 721 |
|
|
| 722 |
|
@inheritDoc |
| 723 |
|
|
|
|
|
| 80% |
Uncovered Elements: 1 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 724 |
3
|
@Override... |
| 725 |
|
public ServiceInfo getServiceInfo(String type, String name, boolean persistent, long timeout) { |
| 726 |
3
|
final ServiceInfoImpl info = this.resolveServiceInfo(type, name, "", persistent); |
| 727 |
3
|
this.waitForInfoData(info, timeout); |
| 728 |
3
|
return (info.hasData() ? info : null); |
| 729 |
|
} |
| 730 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 2 |
Complexity Density: 0.25 |
|
| 731 |
21
|
ServiceInfoImpl resolveServiceInfo(String type, String name, String subtype, boolean persistent) {... |
| 732 |
21
|
this.cleanCache(); |
| 733 |
21
|
String loType = type.toLowerCase(); |
| 734 |
21
|
this.registerServiceType(type); |
| 735 |
21
|
if (_serviceCollectors.putIfAbsent(loType, new ServiceCollector(type)) == null) { |
| 736 |
2
|
this.addServiceListener(loType, _serviceCollectors.get(loType), ListenerStatus.SYNCHONEOUS); |
| 737 |
|
} |
| 738 |
|
|
| 739 |
|
|
| 740 |
21
|
final ServiceInfoImpl info = this.getServiceInfoFromCache(type, name, subtype, persistent); |
| 741 |
|
|
| 742 |
21
|
this.startServiceInfoResolver(info); |
| 743 |
|
|
| 744 |
21
|
return info; |
| 745 |
|
} |
| 746 |
|
|
|
|
|
| 88.9% |
Uncovered Elements: 7 (63) |
Complexity: 13 |
Complexity Density: 0.33 |
|
| 747 |
59
|
ServiceInfoImpl getServiceInfoFromCache(String type, String name, String subtype, boolean persistent) {... |
| 748 |
|
|
| 749 |
62
|
ServiceInfoImpl info = new ServiceInfoImpl(type, name, subtype, 0, 0, 0, persistent, (byte[]) null); |
| 750 |
62
|
DNSEntry pointerEntry = this.getCache().getDNSEntry(new DNSRecord.Pointer(type, DNSRecordClass.CLASS_ANY, false, 0, info.getQualifiedName())); |
| 751 |
62
|
if (pointerEntry instanceof DNSRecord) { |
| 752 |
53
|
ServiceInfoImpl cachedInfo = (ServiceInfoImpl) ((DNSRecord) pointerEntry).getServiceInfo(persistent); |
| 753 |
54
|
if (cachedInfo != null) { |
| 754 |
|
|
| 755 |
|
|
| 756 |
54
|
Map<Fields, String> map = cachedInfo.getQualifiedNameMap(); |
| 757 |
53
|
byte[] srvBytes = null; |
| 758 |
54
|
String server = ""; |
| 759 |
54
|
DNSEntry serviceEntry = this.getCache().getDNSEntry(info.getQualifiedName(), DNSRecordType.TYPE_SRV, DNSRecordClass.CLASS_ANY); |
| 760 |
54
|
if (serviceEntry instanceof DNSRecord) { |
| 761 |
13
|
ServiceInfo cachedServiceEntryInfo = ((DNSRecord) serviceEntry).getServiceInfo(persistent); |
| 762 |
13
|
if (cachedServiceEntryInfo != null) { |
| 763 |
13
|
cachedInfo = new ServiceInfoImpl(map, cachedServiceEntryInfo.getPort(), cachedServiceEntryInfo.getWeight(), cachedServiceEntryInfo.getPriority(), persistent, (byte[]) null); |
| 764 |
13
|
srvBytes = cachedServiceEntryInfo.getTextBytes(); |
| 765 |
13
|
server = cachedServiceEntryInfo.getServer(); |
| 766 |
|
} |
| 767 |
|
} |
| 768 |
54
|
DNSEntry addressEntry = this.getCache().getDNSEntry(server, DNSRecordType.TYPE_A, DNSRecordClass.CLASS_ANY); |
| 769 |
53
|
if (addressEntry instanceof DNSRecord) { |
| 770 |
12
|
ServiceInfo cachedAddressInfo = ((DNSRecord) addressEntry).getServiceInfo(persistent); |
| 771 |
12
|
if (cachedAddressInfo != null) { |
| 772 |
12
|
for (Inet4Address address : cachedAddressInfo.getInet4Addresses()) { |
| 773 |
12
|
cachedInfo.addAddress(address); |
| 774 |
|
} |
| 775 |
12
|
cachedInfo._setText(cachedAddressInfo.getTextBytes()); |
| 776 |
|
} |
| 777 |
|
} |
| 778 |
52
|
addressEntry = this.getCache().getDNSEntry(server, DNSRecordType.TYPE_AAAA, DNSRecordClass.CLASS_ANY); |
| 779 |
54
|
if (addressEntry instanceof DNSRecord) { |
| 780 |
13
|
ServiceInfo cachedAddressInfo = ((DNSRecord) addressEntry).getServiceInfo(persistent); |
| 781 |
13
|
if (cachedAddressInfo != null) { |
| 782 |
13
|
for (Inet6Address address : cachedAddressInfo.getInet6Addresses()) { |
| 783 |
13
|
cachedInfo.addAddress(address); |
| 784 |
|
} |
| 785 |
13
|
cachedInfo._setText(cachedAddressInfo.getTextBytes()); |
| 786 |
|
} |
| 787 |
|
} |
| 788 |
53
|
DNSEntry textEntry = this.getCache().getDNSEntry(cachedInfo.getQualifiedName(), DNSRecordType.TYPE_TXT, DNSRecordClass.CLASS_ANY); |
| 789 |
53
|
if (textEntry instanceof DNSRecord) { |
| 790 |
13
|
ServiceInfo cachedTextInfo = ((DNSRecord) textEntry).getServiceInfo(persistent); |
| 791 |
13
|
if (cachedTextInfo != null) { |
| 792 |
13
|
cachedInfo._setText(cachedTextInfo.getTextBytes()); |
| 793 |
|
} |
| 794 |
|
} |
| 795 |
52
|
if (cachedInfo.getTextBytes().length == 0) { |
| 796 |
0
|
cachedInfo._setText(srvBytes); |
| 797 |
|
} |
| 798 |
54
|
if (cachedInfo.hasData()) { |
| 799 |
13
|
info = cachedInfo; |
| 800 |
|
} |
| 801 |
|
} |
| 802 |
|
} |
| 803 |
61
|
return info; |
| 804 |
|
} |
| 805 |
|
|
|
|
|
| 60% |
Uncovered Elements: 6 (15) |
Complexity: 5 |
Complexity Density: 0.56 |
|
| 806 |
4
|
private void waitForInfoData(ServiceInfo info, long timeout) {... |
| 807 |
4
|
synchronized (info) { |
| 808 |
4
|
long loops = (timeout / 200L); |
| 809 |
4
|
if (loops < 1) { |
| 810 |
0
|
loops = 1; |
| 811 |
|
} |
| 812 |
4
|
for (int i = 0; i < loops; i++) { |
| 813 |
4
|
if (info.hasData()) { |
| 814 |
4
|
break; |
| 815 |
|
} |
| 816 |
0
|
try { |
| 817 |
0
|
info.wait(200); |
| 818 |
|
} catch (final InterruptedException e) { |
| 819 |
|
|
| 820 |
|
} |
| 821 |
|
} |
| 822 |
|
} |
| 823 |
|
} |
| 824 |
|
|
| 825 |
|
|
| 826 |
|
@inheritDoc |
| 827 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 828 |
1
|
@Override... |
| 829 |
|
public void requestServiceInfo(String type, String name) { |
| 830 |
1
|
this.requestServiceInfo(type, name, false, DNSConstants.SERVICE_INFO_TIMEOUT); |
| 831 |
|
} |
| 832 |
|
|
| 833 |
|
|
| 834 |
|
@inheritDoc |
| 835 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 836 |
0
|
@Override... |
| 837 |
|
public void requestServiceInfo(String type, String name, boolean persistent) { |
| 838 |
0
|
this.requestServiceInfo(type, name, persistent, DNSConstants.SERVICE_INFO_TIMEOUT); |
| 839 |
|
} |
| 840 |
|
|
| 841 |
|
|
| 842 |
|
@inheritDoc |
| 843 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 844 |
0
|
@Override... |
| 845 |
|
public void requestServiceInfo(String type, String name, long timeout) { |
| 846 |
0
|
this.requestServiceInfo(type, name, false, DNSConstants.SERVICE_INFO_TIMEOUT); |
| 847 |
|
} |
| 848 |
|
|
| 849 |
|
|
| 850 |
|
@inheritDoc |
| 851 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 852 |
1
|
@Override... |
| 853 |
|
public void requestServiceInfo(String type, String name, boolean persistent, long timeout) { |
| 854 |
1
|
final ServiceInfoImpl info = this.resolveServiceInfo(type, name, "", persistent); |
| 855 |
1
|
this.waitForInfoData(info, timeout); |
| 856 |
|
} |
| 857 |
|
|
|
|
|
| 92.3% |
Uncovered Elements: 1 (13) |
Complexity: 5 |
Complexity Density: 0.56 |
|
| 858 |
68
|
void handleServiceResolved(ServiceEvent event) {... |
| 859 |
68
|
List<ServiceListenerStatus> list = _serviceListeners.get(event.getType().toLowerCase()); |
| 860 |
68
|
final List<ServiceListenerStatus> listCopy; |
| 861 |
68
|
if ((list != null) && (!list.isEmpty())) { |
| 862 |
27
|
if ((event.getInfo() != null) && event.getInfo().hasData()) { |
| 863 |
27
|
final ServiceEvent localEvent = event; |
| 864 |
27
|
synchronized (list) { |
| 865 |
27
|
listCopy = new ArrayList<ServiceListenerStatus>(list); |
| 866 |
|
} |
| 867 |
27
|
for (final ServiceListenerStatus listener : listCopy) { |
| 868 |
40
|
_executor.submit(new Runnable() { |
| 869 |
|
@inheritDoc |
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 870 |
40
|
@Override... |
| 871 |
|
public void run() { |
| 872 |
40
|
listener.serviceResolved(localEvent); |
| 873 |
|
} |
| 874 |
|
}); |
| 875 |
|
} |
| 876 |
|
} |
| 877 |
|
} |
| 878 |
|
} |
| 879 |
|
|
| 880 |
|
|
| 881 |
|
@inheritDoc |
| 882 |
|
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
| 883 |
0
|
@Override... |
| 884 |
|
public void addServiceTypeListener(ServiceTypeListener listener) throws IOException { |
| 885 |
0
|
ServiceTypeListenerStatus status = new ServiceTypeListenerStatus(listener, ListenerStatus.ASYNCHONEOUS); |
| 886 |
0
|
_typeListeners.add(status); |
| 887 |
|
|
| 888 |
|
|
| 889 |
0
|
for (String type : _serviceTypes.keySet()) { |
| 890 |
0
|
status.serviceTypeAdded(new ServiceEventImpl(this, type, "", null)); |
| 891 |
|
} |
| 892 |
|
|
| 893 |
0
|
this.startTypeResolver(); |
| 894 |
|
} |
| 895 |
|
|
| 896 |
|
|
| 897 |
|
@inheritDoc |
| 898 |
|
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 899 |
0
|
@Override... |
| 900 |
|
public void removeServiceTypeListener(ServiceTypeListener listener) { |
| 901 |
0
|
ServiceTypeListenerStatus status = new ServiceTypeListenerStatus(listener, ListenerStatus.ASYNCHONEOUS); |
| 902 |
0
|
_typeListeners.remove(status); |
| 903 |
|
} |
| 904 |
|
|
| 905 |
|
|
| 906 |
|
@inheritDoc |
| 907 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 908 |
8
|
@Override... |
| 909 |
|
public void addServiceListener(String type, ServiceListener listener) { |
| 910 |
8
|
this.addServiceListener(type, listener, ListenerStatus.ASYNCHONEOUS); |
| 911 |
|
} |
| 912 |
|
|
|
|
|
| 88.9% |
Uncovered Elements: 4 (36) |
Complexity: 8 |
Complexity Density: 0.36 |
|
| 913 |
25
|
private void addServiceListener(String type, ServiceListener listener, boolean synch) {... |
| 914 |
25
|
ServiceListenerStatus status = new ServiceListenerStatus(listener, synch); |
| 915 |
25
|
final String loType = type.toLowerCase(); |
| 916 |
25
|
List<ServiceListenerStatus> list = _serviceListeners.get(loType); |
| 917 |
25
|
if (list == null) { |
| 918 |
17
|
if (_serviceListeners.putIfAbsent(loType, new LinkedList<ServiceListenerStatus>()) == null) { |
| 919 |
17
|
if (_serviceCollectors.putIfAbsent(loType, new ServiceCollector(type)) == null) { |
| 920 |
|
|
| 921 |
8
|
this.addServiceListener(loType, _serviceCollectors.get(loType), ListenerStatus.SYNCHONEOUS); |
| 922 |
|
} |
| 923 |
|
} |
| 924 |
17
|
list = _serviceListeners.get(loType); |
| 925 |
|
} |
| 926 |
25
|
if (list != null) { |
| 927 |
25
|
synchronized (list) { |
| 928 |
25
|
if (!list.contains(listener)) { |
| 929 |
25
|
list.add(status); |
| 930 |
|
} |
| 931 |
|
} |
| 932 |
|
} |
| 933 |
|
|
| 934 |
25
|
final List<ServiceEvent> serviceEvents = new ArrayList<ServiceEvent>(); |
| 935 |
25
|
Collection<DNSEntry> dnsEntryLits = this.getCache().allValues(); |
| 936 |
25
|
for (DNSEntry entry : dnsEntryLits) { |
| 937 |
41
|
final DNSRecord record = (DNSRecord) entry; |
| 938 |
41
|
if (record.getRecordType() == DNSRecordType.TYPE_SRV) { |
| 939 |
8
|
if (record.getKey().endsWith(loType)) { |
| 940 |
|
|
| 941 |
|
|
| 942 |
8
|
serviceEvents.add(new ServiceEventImpl(this, record.getType(), toUnqualifiedName(record.getType(), record.getName()), record.getServiceInfo())); |
| 943 |
|
} |
| 944 |
|
} |
| 945 |
|
} |
| 946 |
|
|
| 947 |
25
|
for (ServiceEvent serviceEvent : serviceEvents) { |
| 948 |
8
|
status.serviceAdded(serviceEvent); |
| 949 |
|
} |
| 950 |
|
|
| 951 |
25
|
this.startServiceResolver(type); |
| 952 |
|
} |
| 953 |
|
|
| 954 |
|
|
| 955 |
|
@inheritDoc |
| 956 |
|
|
|
|
|
| 91.7% |
Uncovered Elements: 1 (12) |
Complexity: 3 |
Complexity Density: 0.38 |
|
| 957 |
17
|
@Override... |
| 958 |
|
public void removeServiceListener(String type, ServiceListener listener) { |
| 959 |
17
|
String loType = type.toLowerCase(); |
| 960 |
17
|
List<ServiceListenerStatus> list = _serviceListeners.get(loType); |
| 961 |
17
|
if (list != null) { |
| 962 |
17
|
synchronized (list) { |
| 963 |
17
|
ServiceListenerStatus status = new ServiceListenerStatus(listener, ListenerStatus.ASYNCHONEOUS); |
| 964 |
17
|
list.remove(status); |
| 965 |
17
|
if (list.isEmpty()) { |
| 966 |
9
|
_serviceListeners.remove(loType, list); |
| 967 |
|
} |
| 968 |
|
} |
| 969 |
|
} |
| 970 |
|
} |
| 971 |
|
|
| 972 |
|
|
| 973 |
|
@inheritDoc |
| 974 |
|
|
|
|
|
| 76.5% |
Uncovered Elements: 8 (34) |
Complexity: 8 |
Complexity Density: 0.36 |
|
| 975 |
21
|
@Override... |
| 976 |
|
public void registerService(ServiceInfo infoAbstract) throws IOException { |
| 977 |
21
|
if (this.isClosing() || this.isClosed()) { |
| 978 |
0
|
throw new IllegalStateException("This DNS is closed."); |
| 979 |
|
} |
| 980 |
21
|
final ServiceInfoImpl info = (ServiceInfoImpl) infoAbstract; |
| 981 |
|
|
| 982 |
21
|
if (info.getDns() != null) { |
| 983 |
2
|
if (info.getDns() != this) { |
| 984 |
0
|
throw new IllegalStateException("A service information can only be registered with a single instamce of JmDNS."); |
| 985 |
2
|
} else if (_services.get(info.getKey()) != null) { |
| 986 |
1
|
throw new IllegalStateException("A service information can only be registered once."); |
| 987 |
|
} |
| 988 |
|
} |
| 989 |
20
|
info.setDns(this); |
| 990 |
|
|
| 991 |
20
|
this.registerServiceType(info.getTypeWithSubtype()); |
| 992 |
|
|
| 993 |
|
|
| 994 |
20
|
info.recoverState(); |
| 995 |
20
|
info.setServer(_localHost.getName()); |
| 996 |
20
|
info.addAddress(_localHost.getInet4Address()); |
| 997 |
20
|
info.addAddress(_localHost.getInet6Address()); |
| 998 |
|
|
| 999 |
20
|
this.waitForAnnounced(DNSConstants.SERVICE_INFO_TIMEOUT); |
| 1000 |
|
|
| 1001 |
20
|
this.makeServiceNameUnique(info); |
| 1002 |
20
|
while (_services.putIfAbsent(info.getKey(), info) != null) { |
| 1003 |
0
|
this.makeServiceNameUnique(info); |
| 1004 |
|
} |
| 1005 |
|
|
| 1006 |
20
|
this.startProber(); |
| 1007 |
20
|
info.waitForAnnounced(DNSConstants.SERVICE_INFO_TIMEOUT); |
| 1008 |
|
|
| 1009 |
20
|
if (logger.isLoggable(Level.FINE)) { |
| 1010 |
0
|
logger.fine("registerService() JmDNS registered service as " + info); |
| 1011 |
|
} |
| 1012 |
|
} |
| 1013 |
|
|
| 1014 |
|
|
| 1015 |
|
@inheritDoc |
| 1016 |
|
|
|
|
|
| 69.2% |
Uncovered Elements: 4 (13) |
Complexity: 3 |
Complexity Density: 0.33 |
|
| 1017 |
4
|
@Override... |
| 1018 |
|
public void unregisterService(ServiceInfo infoAbstract) { |
| 1019 |
4
|
final ServiceInfoImpl info = (ServiceInfoImpl) _services.get(infoAbstract.getKey()); |
| 1020 |
|
|
| 1021 |
4
|
if (info != null) { |
| 1022 |
4
|
info.cancelState(); |
| 1023 |
4
|
this.startCanceler(); |
| 1024 |
4
|
info.waitForCanceled(DNSConstants.CLOSE_TIMEOUT); |
| 1025 |
|
|
| 1026 |
4
|
_services.remove(info.getKey(), info); |
| 1027 |
4
|
if (logger.isLoggable(Level.FINE)) { |
| 1028 |
0
|
logger.fine("unregisterService() JmDNS unregistered service as " + info); |
| 1029 |
|
} |
| 1030 |
|
} else { |
| 1031 |
0
|
logger.warning("Removing unregistered service info: " + infoAbstract.getKey()); |
| 1032 |
|
} |
| 1033 |
|
} |
| 1034 |
|
|
| 1035 |
|
|
| 1036 |
|
@inheritDoc |
| 1037 |
|
|
|
|
|
| 69.2% |
Uncovered Elements: 8 (26) |
Complexity: 6 |
Complexity Density: 0.38 |
|
| 1038 |
29
|
@Override... |
| 1039 |
|
public void unregisterAllServices() { |
| 1040 |
29
|
if (logger.isLoggable(Level.FINER)) { |
| 1041 |
0
|
logger.finer("unregisterAllServices()"); |
| 1042 |
|
} |
| 1043 |
|
|
| 1044 |
29
|
for (String name : _services.keySet()) { |
| 1045 |
16
|
ServiceInfoImpl info = (ServiceInfoImpl) _services.get(name); |
| 1046 |
16
|
if (info != null) { |
| 1047 |
16
|
if (logger.isLoggable(Level.FINER)) { |
| 1048 |
0
|
logger.finer("Cancelling service info: " + info); |
| 1049 |
|
} |
| 1050 |
16
|
info.cancelState(); |
| 1051 |
|
} |
| 1052 |
|
} |
| 1053 |
29
|
this.startCanceler(); |
| 1054 |
|
|
| 1055 |
29
|
for (String name : _services.keySet()) { |
| 1056 |
16
|
ServiceInfoImpl info = (ServiceInfoImpl) _services.get(name); |
| 1057 |
16
|
if (info != null) { |
| 1058 |
16
|
if (logger.isLoggable(Level.FINER)) { |
| 1059 |
0
|
logger.finer("Wait for service info cancel: " + info); |
| 1060 |
|
} |
| 1061 |
16
|
info.waitForCanceled(DNSConstants.CLOSE_TIMEOUT); |
| 1062 |
16
|
_services.remove(name, info); |
| 1063 |
|
} |
| 1064 |
|
} |
| 1065 |
|
|
| 1066 |
|
} |
| 1067 |
|
|
| 1068 |
|
|
| 1069 |
|
@inheritDoc |
| 1070 |
|
|
|
|
|
| 83% |
Uncovered Elements: 8 (47) |
Complexity: 14 |
Complexity Density: 0.48 |
|
| 1071 |
193
|
@Override... |
| 1072 |
|
public boolean registerServiceType(String type) { |
| 1073 |
193
|
boolean typeAdded = false; |
| 1074 |
193
|
Map<Fields, String> map = ServiceInfoImpl.decodeQualifiedNameMapForType(type); |
| 1075 |
199
|
String domain = map.get(Fields.Domain); |
| 1076 |
197
|
String protocol = map.get(Fields.Protocol); |
| 1077 |
197
|
String application = map.get(Fields.Application); |
| 1078 |
198
|
String subtype = map.get(Fields.Subtype); |
| 1079 |
|
|
| 1080 |
198
|
final String name = (application.length() > 0 ? "_" + application + "." : "") + (protocol.length() > 0 ? "_" + protocol + "." : "") + domain + "."; |
| 1081 |
196
|
final String loname = name.toLowerCase(); |
| 1082 |
196
|
if (logger.isLoggable(Level.FINE)) { |
| 1083 |
0
|
logger.fine(this.getName() + ".registering service type: " + type + " as: " + name + (subtype.length() > 0 ? " subtype: " + subtype : "")); |
| 1084 |
|
} |
| 1085 |
196
|
if (!_serviceTypes.containsKey(loname) && !application.toLowerCase().equals("dns-sd") && !domain.toLowerCase().endsWith("in-addr.arpa") && !domain.toLowerCase().endsWith("ip6.arpa")) { |
| 1086 |
27
|
typeAdded = _serviceTypes.putIfAbsent(loname, new ServiceTypeEntry(name)) == null; |
| 1087 |
27
|
if (typeAdded) { |
| 1088 |
27
|
final ServiceTypeListenerStatus[] list = _typeListeners.toArray(new ServiceTypeListenerStatus[_typeListeners.size()]); |
| 1089 |
27
|
final ServiceEvent event = new ServiceEventImpl(this, name, "", null); |
| 1090 |
27
|
for (final ServiceTypeListenerStatus status : list) { |
| 1091 |
0
|
_executor.submit(new Runnable() { |
| 1092 |
|
@inheritDoc |
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 1093 |
0
|
@Override... |
| 1094 |
|
public void run() { |
| 1095 |
0
|
status.serviceTypeAdded(event); |
| 1096 |
|
} |
| 1097 |
|
}); |
| 1098 |
|
} |
| 1099 |
|
} |
| 1100 |
|
} |
| 1101 |
197
|
if (subtype.length() > 0) { |
| 1102 |
9
|
ServiceTypeEntry subtypes = _serviceTypes.get(loname); |
| 1103 |
9
|
if ((subtypes != null) && (!subtypes.contains(subtype))) { |
| 1104 |
2
|
synchronized (subtypes) { |
| 1105 |
2
|
if (!subtypes.contains(subtype)) { |
| 1106 |
2
|
typeAdded = true; |
| 1107 |
2
|
subtypes.add(subtype); |
| 1108 |
2
|
final ServiceTypeListenerStatus[] list = _typeListeners.toArray(new ServiceTypeListenerStatus[_typeListeners.size()]); |
| 1109 |
2
|
final ServiceEvent event = new ServiceEventImpl(this, "_" + subtype + "._sub." + name, "", null); |
| 1110 |
2
|
for (final ServiceTypeListenerStatus status : list) { |
| 1111 |
0
|
_executor.submit(new Runnable() { |
| 1112 |
|
@inheritDoc |
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 1113 |
0
|
@Override... |
| 1114 |
|
public void run() { |
| 1115 |
0
|
status.subTypeForServiceTypeAdded(event); |
| 1116 |
|
} |
| 1117 |
|
}); |
| 1118 |
|
} |
| 1119 |
|
} |
| 1120 |
|
} |
| 1121 |
|
} |
| 1122 |
|
} |
| 1123 |
197
|
return typeAdded; |
| 1124 |
|
} |
| 1125 |
|
|
| 1126 |
|
|
| 1127 |
|
|
| 1128 |
|
|
| 1129 |
|
@return |
| 1130 |
|
|
|
|
|
| 37.9% |
Uncovered Elements: 18 (29) |
Complexity: 9 |
Complexity Density: 0.47 |
|
| 1131 |
20
|
private boolean makeServiceNameUnique(ServiceInfoImpl info) {... |
| 1132 |
20
|
final String originalQualifiedName = info.getKey(); |
| 1133 |
20
|
final long now = System.currentTimeMillis(); |
| 1134 |
|
|
| 1135 |
20
|
boolean collision; |
| 1136 |
20
|
do { |
| 1137 |
20
|
collision = false; |
| 1138 |
|
|
| 1139 |
|
|
| 1140 |
20
|
for (DNSEntry dnsEntry : this.getCache().getDNSEntryList(info.getKey())) { |
| 1141 |
0
|
if (DNSRecordType.TYPE_SRV.equals(dnsEntry.getRecordType()) && !dnsEntry.isExpired(now)) { |
| 1142 |
0
|
final DNSRecord.Service s = (DNSRecord.Service) dnsEntry; |
| 1143 |
0
|
if (s.getPort() != info.getPort() || !s.getServer().equals(_localHost.getName())) { |
| 1144 |
0
|
if (logger.isLoggable(Level.FINER)) { |
| 1145 |
0
|
logger.finer("makeServiceNameUnique() JmDNS.makeServiceNameUnique srv collision:" + dnsEntry + " s.server=" + s.getServer() + " " + _localHost.getName() + " equals:" + (s.getServer().equals(_localHost.getName()))); |
| 1146 |
|
} |
| 1147 |
0
|
info.setName(incrementName(info.getName())); |
| 1148 |
0
|
collision = true; |
| 1149 |
0
|
break; |
| 1150 |
|
} |
| 1151 |
|
} |
| 1152 |
|
} |
| 1153 |
|
|
| 1154 |
|
|
| 1155 |
20
|
final ServiceInfo selfService = _services.get(info.getKey()); |
| 1156 |
20
|
if (selfService != null && selfService != info) { |
| 1157 |
0
|
info.setName(incrementName(info.getName())); |
| 1158 |
0
|
collision = true; |
| 1159 |
|
} |
| 1160 |
|
} |
| 1161 |
20
|
while (collision); |
| 1162 |
|
|
| 1163 |
20
|
return !(originalQualifiedName.equals(info.getKey())); |
| 1164 |
|
} |
| 1165 |
|
|
|
|
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 4 |
Complexity Density: 0.44 |
|
| 1166 |
0
|
String incrementName(String name) {... |
| 1167 |
0
|
String aName = name; |
| 1168 |
0
|
try { |
| 1169 |
0
|
final int l = aName.lastIndexOf('('); |
| 1170 |
0
|
final int r = aName.lastIndexOf(')'); |
| 1171 |
0
|
if ((l >= 0) && (l < r)) { |
| 1172 |
0
|
aName = aName.substring(0, l) + "(" + (Integer.parseInt(aName.substring(l + 1, r)) + 1) + ")"; |
| 1173 |
|
} else { |
| 1174 |
0
|
aName += " (2)"; |
| 1175 |
|
} |
| 1176 |
|
} catch (final NumberFormatException e) { |
| 1177 |
0
|
aName += " (2)"; |
| 1178 |
|
} |
| 1179 |
0
|
return aName; |
| 1180 |
|
} |
| 1181 |
|
|
| 1182 |
|
|
| 1183 |
|
|
| 1184 |
|
|
| 1185 |
|
@param |
| 1186 |
|
|
| 1187 |
|
@param |
| 1188 |
|
|
| 1189 |
|
|
|
|
|
| 80% |
Uncovered Elements: 2 (10) |
Complexity: 4 |
Complexity Density: 0.67 |
|
| 1190 |
21
|
public void addListener(DNSListener listener, DNSQuestion question) {... |
| 1191 |
21
|
final long now = System.currentTimeMillis(); |
| 1192 |
|
|
| 1193 |
|
|
| 1194 |
21
|
_listeners.add(listener); |
| 1195 |
|
|
| 1196 |
|
|
| 1197 |
|
|
| 1198 |
21
|
if (question != null) { |
| 1199 |
21
|
for (DNSEntry dnsEntry : this.getCache().getDNSEntryList(question.getName().toLowerCase())) { |
| 1200 |
24
|
if (question.answeredBy(dnsEntry) && !dnsEntry.isExpired(now)) { |
| 1201 |
24
|
listener.updateRecord(this.getCache(), now, dnsEntry); |
| 1202 |
|
} |
| 1203 |
|
} |
| 1204 |
|
} |
| 1205 |
|
} |
| 1206 |
|
|
| 1207 |
|
|
| 1208 |
|
|
| 1209 |
|
|
| 1210 |
|
@param |
| 1211 |
|
|
| 1212 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 1213 |
2
|
public void removeListener(DNSListener listener) {... |
| 1214 |
2
|
_listeners.remove(listener); |
| 1215 |
|
} |
| 1216 |
|
|
| 1217 |
|
|
| 1218 |
|
|
| 1219 |
|
|
| 1220 |
|
@param |
| 1221 |
|
|
| 1222 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 1223 |
40
|
public void renewServiceCollector(DNSRecord record) {... |
| 1224 |
40
|
ServiceInfo info = record.getServiceInfo(); |
| 1225 |
40
|
if (_serviceCollectors.containsKey(info.getType().toLowerCase())) { |
| 1226 |
|
|
| 1227 |
3
|
this.startServiceResolver(info.getType()); |
| 1228 |
|
} |
| 1229 |
|
} |
| 1230 |
|
|
| 1231 |
|
|
| 1232 |
|
|
| 1233 |
|
|
| 1234 |
|
|
| 1235 |
|
@param |
| 1236 |
|
|
| 1237 |
|
@param |
| 1238 |
|
|
| 1239 |
|
@param |
| 1240 |
|
|
| 1241 |
|
|
|
|
|
| 86.5% |
Uncovered Elements: 7 (52) |
Complexity: 12 |
Complexity Density: 0.33 |
|
| 1242 |
175
|
public void updateRecord(long now, DNSRecord rec, Operation operation) {... |
| 1243 |
|
|
| 1244 |
|
{ |
| 1245 |
176
|
List<DNSListener> listenerList = null; |
| 1246 |
175
|
synchronized (_listeners) { |
| 1247 |
177
|
listenerList = new ArrayList<DNSListener>(_listeners); |
| 1248 |
|
} |
| 1249 |
177
|
for (DNSListener listener : listenerList) { |
| 1250 |
42
|
listener.updateRecord(this.getCache(), now, rec); |
| 1251 |
|
} |
| 1252 |
|
} |
| 1253 |
177
|
if (DNSRecordType.TYPE_PTR.equals(rec.getRecordType())) |
| 1254 |
|
|
| 1255 |
|
{ |
| 1256 |
41
|
ServiceEvent event = rec.getServiceEvent(this); |
| 1257 |
40
|
if ((event.getInfo() == null) || !event.getInfo().hasData()) { |
| 1258 |
|
|
| 1259 |
40
|
ServiceInfo info = this.getServiceInfoFromCache(event.getType(), event.getName(), "", false); |
| 1260 |
40
|
if (info.hasData()) { |
| 1261 |
1
|
event = new ServiceEventImpl(this, event.getType(), event.getName(), info); |
| 1262 |
|
} |
| 1263 |
|
} |
| 1264 |
|
|
| 1265 |
41
|
List<ServiceListenerStatus> list = _serviceListeners.get(event.getType().toLowerCase()); |
| 1266 |
41
|
final List<ServiceListenerStatus> serviceListenerList; |
| 1267 |
41
|
if (list != null) { |
| 1268 |
15
|
synchronized (list) { |
| 1269 |
15
|
serviceListenerList = new ArrayList<ServiceListenerStatus>(list); |
| 1270 |
|
} |
| 1271 |
|
} else { |
| 1272 |
26
|
serviceListenerList = Collections.emptyList(); |
| 1273 |
|
} |
| 1274 |
41
|
if (logger.isLoggable(Level.FINEST)) { |
| 1275 |
0
|
logger.finest(this.getName() + ".updating record for event: " + event + " list " + serviceListenerList + " operation: " + operation); |
| 1276 |
|
} |
| 1277 |
41
|
if (!serviceListenerList.isEmpty()) { |
| 1278 |
15
|
final ServiceEvent localEvent = event; |
| 1279 |
|
|
| 1280 |
15
|
switch (operation) { |
| 1281 |
10
|
case Add: |
| 1282 |
10
|
for (final ServiceListenerStatus listener : serviceListenerList) { |
| 1283 |
18
|
if (listener.isSynchronous()) { |
| 1284 |
10
|
listener.serviceAdded(localEvent); |
| 1285 |
|
} else { |
| 1286 |
8
|
_executor.submit(new Runnable() { |
| 1287 |
|
@inheritDoc |
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 1288 |
8
|
@Override... |
| 1289 |
|
public void run() { |
| 1290 |
8
|
listener.serviceAdded(localEvent); |
| 1291 |
|
} |
| 1292 |
|
}); |
| 1293 |
|
} |
| 1294 |
|
} |
| 1295 |
10
|
break; |
| 1296 |
5
|
case Remove: |
| 1297 |
5
|
for (final ServiceListenerStatus listener : serviceListenerList) { |
| 1298 |
5
|
if (listener.isSynchronous()) { |
| 1299 |
5
|
listener.serviceRemoved(localEvent); |
| 1300 |
|
} else { |
| 1301 |
0
|
_executor.submit(new Runnable() { |
| 1302 |
|
@inheritDoc |
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 1303 |
0
|
@Override... |
| 1304 |
|
public void run() { |
| 1305 |
0
|
listener.serviceRemoved(localEvent); |
| 1306 |
|
} |
| 1307 |
|
}); |
| 1308 |
|
} |
| 1309 |
|
} |
| 1310 |
5
|
break; |
| 1311 |
0
|
default: |
| 1312 |
0
|
break; |
| 1313 |
|
} |
| 1314 |
|
} |
| 1315 |
|
} |
| 1316 |
|
} |
| 1317 |
|
|
|
|
|
| 70.7% |
Uncovered Elements: 22 (75) |
Complexity: 23 |
Complexity Density: 0.53 |
|
| 1318 |
717
|
void handleRecord(DNSRecord record, long now) {... |
| 1319 |
724
|
DNSRecord newRecord = record; |
| 1320 |
|
|
| 1321 |
723
|
Operation cacheOperation = Operation.Noop; |
| 1322 |
714
|
final boolean expired = newRecord.isExpired(now); |
| 1323 |
722
|
if (logger.isLoggable(Level.FINE)) { |
| 1324 |
0
|
logger.fine(this.getName() + " handle response: " + newRecord); |
| 1325 |
|
} |
| 1326 |
|
|
| 1327 |
|
|
| 1328 |
724
|
if (!newRecord.isServicesDiscoveryMetaQuery() && !newRecord.isDomainDiscoveryQuery()) { |
| 1329 |
719
|
final boolean unique = newRecord.isUnique(); |
| 1330 |
717
|
final DNSRecord cachedRecord = (DNSRecord) this.getCache().getDNSEntry(newRecord); |
| 1331 |
719
|
if (logger.isLoggable(Level.FINE)) { |
| 1332 |
0
|
logger.fine(this.getName() + " handle response cached record: " + cachedRecord); |
| 1333 |
|
} |
| 1334 |
722
|
if (unique) { |
| 1335 |
589
|
for (DNSEntry entry : this.getCache().getDNSEntryList(newRecord.getKey())) { |
| 1336 |
968
|
if (newRecord.getRecordType().equals(entry.getRecordType()) && newRecord.getRecordClass().equals(entry.getRecordClass()) && (entry != cachedRecord)) { |
| 1337 |
0
|
((DNSRecord) entry).setWillExpireSoon(now); |
| 1338 |
|
} |
| 1339 |
|
} |
| 1340 |
|
} |
| 1341 |
712
|
if (cachedRecord != null) { |
| 1342 |
568
|
if (expired) { |
| 1343 |
|
|
| 1344 |
54
|
if (newRecord.getTTL() == 0) { |
| 1345 |
54
|
cacheOperation = Operation.Noop; |
| 1346 |
54
|
cachedRecord.setWillExpireSoon(now); |
| 1347 |
|
|
| 1348 |
|
} else { |
| 1349 |
0
|
cacheOperation = Operation.Remove; |
| 1350 |
0
|
this.getCache().removeDNSEntry(cachedRecord); |
| 1351 |
|
} |
| 1352 |
|
} else { |
| 1353 |
|
|
| 1354 |
515
|
if (!newRecord.sameValue(cachedRecord) || (!newRecord.sameSubtype(cachedRecord) && (newRecord.getSubtype().length() > 0))) { |
| 1355 |
8
|
if (newRecord.isSingleValued()) { |
| 1356 |
8
|
cacheOperation = Operation.Update; |
| 1357 |
7
|
this.getCache().replaceDNSEntry(newRecord, cachedRecord); |
| 1358 |
|
} else { |
| 1359 |
|
|
| 1360 |
0
|
cacheOperation = Operation.Add; |
| 1361 |
0
|
this.getCache().addDNSEntry(newRecord); |
| 1362 |
|
} |
| 1363 |
|
} else { |
| 1364 |
509
|
cachedRecord.resetTTL(newRecord); |
| 1365 |
507
|
newRecord = cachedRecord; |
| 1366 |
|
} |
| 1367 |
|
} |
| 1368 |
|
} else { |
| 1369 |
150
|
if (!expired) { |
| 1370 |
152
|
cacheOperation = Operation.Add; |
| 1371 |
150
|
this.getCache().addDNSEntry(newRecord); |
| 1372 |
|
} |
| 1373 |
|
} |
| 1374 |
|
} |
| 1375 |
|
|
| 1376 |
|
|
| 1377 |
717
|
if (newRecord.getRecordType() == DNSRecordType.TYPE_PTR) { |
| 1378 |
|
|
| 1379 |
155
|
boolean typeAdded = false; |
| 1380 |
155
|
if (newRecord.isServicesDiscoveryMetaQuery()) { |
| 1381 |
|
|
| 1382 |
0
|
if (!expired) { |
| 1383 |
0
|
typeAdded = this.registerServiceType(((DNSRecord.Pointer) newRecord).getAlias()); |
| 1384 |
|
} |
| 1385 |
0
|
return; |
| 1386 |
|
} |
| 1387 |
153
|
typeAdded |= this.registerServiceType(newRecord.getName()); |
| 1388 |
155
|
if (typeAdded && (cacheOperation == Operation.Noop)) { |
| 1389 |
0
|
cacheOperation = Operation.RegisterServiceType; |
| 1390 |
|
} |
| 1391 |
|
} |
| 1392 |
|
|
| 1393 |
|
|
| 1394 |
718
|
if (cacheOperation != Operation.Noop) { |
| 1395 |
160
|
this.updateRecord(now, newRecord, cacheOperation); |
| 1396 |
|
} |
| 1397 |
|
|
| 1398 |
|
} |
| 1399 |
|
|
| 1400 |
|
|
| 1401 |
|
|
| 1402 |
|
|
| 1403 |
|
@exception |
| 1404 |
|
|
|
|
|
| 85.7% |
Uncovered Elements: 2 (14) |
Complexity: 5 |
Complexity Density: 0.5 |
|
| 1405 |
302
|
void handleResponse(DNSIncoming msg) throws IOException {... |
| 1406 |
306
|
final long now = System.currentTimeMillis(); |
| 1407 |
|
|
| 1408 |
303
|
boolean hostConflictDetected = false; |
| 1409 |
305
|
boolean serviceConflictDetected = false; |
| 1410 |
|
|
| 1411 |
310
|
for (DNSRecord newRecord : msg.getAllAnswers()) { |
| 1412 |
699
|
this.handleRecord(newRecord, now); |
| 1413 |
|
|
| 1414 |
707
|
if (DNSRecordType.TYPE_A.equals(newRecord.getRecordType()) || DNSRecordType.TYPE_AAAA.equals(newRecord.getRecordType())) { |
| 1415 |
306
|
hostConflictDetected |= newRecord.handleResponse(this); |
| 1416 |
|
} else { |
| 1417 |
398
|
serviceConflictDetected |= newRecord.handleResponse(this); |
| 1418 |
|
} |
| 1419 |
|
|
| 1420 |
|
} |
| 1421 |
|
|
| 1422 |
309
|
if (hostConflictDetected || serviceConflictDetected) { |
| 1423 |
0
|
this.startProber(); |
| 1424 |
|
} |
| 1425 |
|
} |
| 1426 |
|
|
| 1427 |
|
|
| 1428 |
|
|
| 1429 |
|
|
| 1430 |
|
@param |
| 1431 |
|
@param |
| 1432 |
|
@param |
| 1433 |
|
@exception |
| 1434 |
|
|
|
|
|
| 71.4% |
Uncovered Elements: 8 (28) |
Complexity: 5 |
Complexity Density: 0.25 |
|
| 1435 |
335
|
void handleQuery(DNSIncoming in, InetAddress addr, int port) throws IOException {... |
| 1436 |
344
|
if (logger.isLoggable(Level.FINE)) { |
| 1437 |
0
|
logger.fine(this.getName() + ".handle query: " + in); |
| 1438 |
|
} |
| 1439 |
|
|
| 1440 |
346
|
boolean conflictDetected = false; |
| 1441 |
345
|
final long expirationTime = System.currentTimeMillis() + DNSConstants.KNOWN_ANSWER_TTL; |
| 1442 |
340
|
for (DNSRecord answer : in.getAllAnswers()) { |
| 1443 |
240
|
conflictDetected |= answer.handleQuery(this, expirationTime); |
| 1444 |
|
} |
| 1445 |
|
|
| 1446 |
343
|
this.ioLock(); |
| 1447 |
339
|
try { |
| 1448 |
|
|
| 1449 |
343
|
if (_plannedAnswer != null) { |
| 1450 |
0
|
_plannedAnswer.append(in); |
| 1451 |
|
} else { |
| 1452 |
347
|
DNSIncoming plannedAnswer = in.clone(); |
| 1453 |
334
|
if (in.isTruncated()) { |
| 1454 |
0
|
_plannedAnswer = plannedAnswer; |
| 1455 |
|
} |
| 1456 |
338
|
this.startResponder(plannedAnswer, port); |
| 1457 |
|
} |
| 1458 |
|
|
| 1459 |
|
} finally { |
| 1460 |
348
|
this.ioUnlock(); |
| 1461 |
|
} |
| 1462 |
|
|
| 1463 |
348
|
final long now = System.currentTimeMillis(); |
| 1464 |
346
|
for (DNSRecord answer : in.getAnswers()) { |
| 1465 |
18
|
this.handleRecord(answer, now); |
| 1466 |
|
} |
| 1467 |
|
|
| 1468 |
339
|
if (conflictDetected) { |
| 1469 |
0
|
this.startProber(); |
| 1470 |
|
} |
| 1471 |
|
} |
| 1472 |
|
|
|
|
|
| 71.4% |
Uncovered Elements: 2 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
| 1473 |
349
|
public void respondToQuery(DNSIncoming in) {... |
| 1474 |
349
|
this.ioLock(); |
| 1475 |
348
|
try { |
| 1476 |
349
|
if (_plannedAnswer == in) { |
| 1477 |
0
|
_plannedAnswer = null; |
| 1478 |
|
} |
| 1479 |
|
} finally { |
| 1480 |
347
|
this.ioUnlock(); |
| 1481 |
|
} |
| 1482 |
|
} |
| 1483 |
|
|
| 1484 |
|
|
| 1485 |
|
|
| 1486 |
|
|
| 1487 |
|
@param |
| 1488 |
|
@param |
| 1489 |
|
@param |
| 1490 |
|
@param |
| 1491 |
|
@param |
| 1492 |
|
@return |
| 1493 |
|
@exception |
| 1494 |
|
|
|
|
|
| 0% |
Uncovered Elements: 13 (13) |
Complexity: 3 |
Complexity Density: 0.27 |
|
| 1495 |
0
|
public DNSOutgoing addAnswer(DNSIncoming in, InetAddress addr, int port, DNSOutgoing out, DNSRecord rec) throws IOException {... |
| 1496 |
0
|
DNSOutgoing newOut = out; |
| 1497 |
0
|
if (newOut == null) { |
| 1498 |
0
|
newOut = new DNSOutgoing(DNSConstants.FLAGS_QR_RESPONSE | DNSConstants.FLAGS_AA, false, in.getSenderUDPPayload()); |
| 1499 |
|
} |
| 1500 |
0
|
try { |
| 1501 |
0
|
newOut.addAnswer(in, rec); |
| 1502 |
|
} catch (final IOException e) { |
| 1503 |
0
|
newOut.setFlags(newOut.getFlags() | DNSConstants.FLAGS_TC); |
| 1504 |
0
|
newOut.setId(in.getId()); |
| 1505 |
0
|
send(newOut); |
| 1506 |
|
|
| 1507 |
0
|
newOut = new DNSOutgoing(DNSConstants.FLAGS_QR_RESPONSE | DNSConstants.FLAGS_AA, false, in.getSenderUDPPayload()); |
| 1508 |
0
|
newOut.addAnswer(in, rec); |
| 1509 |
|
} |
| 1510 |
0
|
return newOut; |
| 1511 |
|
} |
| 1512 |
|
|
| 1513 |
|
|
| 1514 |
|
|
| 1515 |
|
|
| 1516 |
|
@param |
| 1517 |
|
@exception |
| 1518 |
|
|
|
|
|
| 50% |
Uncovered Elements: 10 (20) |
Complexity: 7 |
Complexity Density: 0.58 |
|
| 1519 |
414
|
public void send(DNSOutgoing out) throws IOException {... |
| 1520 |
414
|
if (!out.isEmpty()) { |
| 1521 |
414
|
byte[] message = out.data(); |
| 1522 |
414
|
final DatagramPacket packet = new DatagramPacket(message, message.length, _group, DNSConstants.MDNS_PORT); |
| 1523 |
|
|
| 1524 |
414
|
if (logger.isLoggable(Level.FINEST)) { |
| 1525 |
0
|
try { |
| 1526 |
0
|
final DNSIncoming msg = new DNSIncoming(packet); |
| 1527 |
0
|
if (logger.isLoggable(Level.FINEST)) { |
| 1528 |
0
|
logger.finest("send(" + this.getName() + ") JmDNS out:" + msg.print(true)); |
| 1529 |
|
} |
| 1530 |
|
} catch (final IOException e) { |
| 1531 |
0
|
logger.throwing(getClass().toString(), "send(" + this.getName() + ") - JmDNS can not parse what it sends!!!", e); |
| 1532 |
|
} |
| 1533 |
|
} |
| 1534 |
414
|
final MulticastSocket ms = _socket; |
| 1535 |
414
|
if (ms != null && !ms.isClosed()) { |
| 1536 |
414
|
ms.send(packet); |
| 1537 |
|
} |
| 1538 |
|
} |
| 1539 |
|
} |
| 1540 |
|
|
| 1541 |
|
|
| 1542 |
|
|
| 1543 |
|
@see |
| 1544 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 1545 |
0
|
@Override... |
| 1546 |
|
public void purgeTimer() { |
| 1547 |
0
|
DNSTaskStarter.Factory.getInstance().getStarter(this.getDns()).purgeTimer(); |
| 1548 |
|
} |
| 1549 |
|
|
| 1550 |
|
|
| 1551 |
|
|
| 1552 |
|
@see |
| 1553 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 1554 |
0
|
@Override... |
| 1555 |
|
public void purgeStateTimer() { |
| 1556 |
0
|
DNSTaskStarter.Factory.getInstance().getStarter(this.getDns()).purgeStateTimer(); |
| 1557 |
|
} |
| 1558 |
|
|
| 1559 |
|
|
| 1560 |
|
|
| 1561 |
|
@see |
| 1562 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 1563 |
29
|
@Override... |
| 1564 |
|
public void cancelTimer() { |
| 1565 |
29
|
DNSTaskStarter.Factory.getInstance().getStarter(this.getDns()).cancelTimer(); |
| 1566 |
|
} |
| 1567 |
|
|
| 1568 |
|
|
| 1569 |
|
|
| 1570 |
|
@see |
| 1571 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 1572 |
29
|
@Override... |
| 1573 |
|
public void cancelStateTimer() { |
| 1574 |
29
|
DNSTaskStarter.Factory.getInstance().getStarter(this.getDns()).cancelStateTimer(); |
| 1575 |
|
} |
| 1576 |
|
|
| 1577 |
|
|
| 1578 |
|
|
| 1579 |
|
@see |
| 1580 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 1581 |
49
|
@Override... |
| 1582 |
|
public void startProber() { |
| 1583 |
49
|
DNSTaskStarter.Factory.getInstance().getStarter(this.getDns()).startProber(); |
| 1584 |
|
} |
| 1585 |
|
|
| 1586 |
|
|
| 1587 |
|
|
| 1588 |
|
@see |
| 1589 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 1590 |
51
|
@Override... |
| 1591 |
|
public void startAnnouncer() { |
| 1592 |
51
|
DNSTaskStarter.Factory.getInstance().getStarter(this.getDns()).startAnnouncer(); |
| 1593 |
|
} |
| 1594 |
|
|
| 1595 |
|
|
| 1596 |
|
|
| 1597 |
|
@see |
| 1598 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 1599 |
51
|
@Override... |
| 1600 |
|
public void startRenewer() { |
| 1601 |
51
|
DNSTaskStarter.Factory.getInstance().getStarter(this.getDns()).startRenewer(); |
| 1602 |
|
} |
| 1603 |
|
|
| 1604 |
|
|
| 1605 |
|
|
| 1606 |
|
@see |
| 1607 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 1608 |
33
|
@Override... |
| 1609 |
|
public void startCanceler() { |
| 1610 |
33
|
DNSTaskStarter.Factory.getInstance().getStarter(this.getDns()).startCanceler(); |
| 1611 |
|
} |
| 1612 |
|
|
| 1613 |
|
|
| 1614 |
|
|
| 1615 |
|
@see |
| 1616 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 1617 |
29
|
@Override... |
| 1618 |
|
public void startReaper() { |
| 1619 |
29
|
DNSTaskStarter.Factory.getInstance().getStarter(this.getDns()).startReaper(); |
| 1620 |
|
} |
| 1621 |
|
|
| 1622 |
|
|
| 1623 |
|
|
| 1624 |
|
@see |
| 1625 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 1626 |
21
|
@Override... |
| 1627 |
|
public void startServiceInfoResolver(ServiceInfoImpl info) { |
| 1628 |
21
|
DNSTaskStarter.Factory.getInstance().getStarter(this.getDns()).startServiceInfoResolver(info); |
| 1629 |
|
} |
| 1630 |
|
|
| 1631 |
|
|
| 1632 |
|
|
| 1633 |
|
@see |
| 1634 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 1635 |
0
|
@Override... |
| 1636 |
|
public void startTypeResolver() { |
| 1637 |
0
|
DNSTaskStarter.Factory.getInstance().getStarter(this.getDns()).startTypeResolver(); |
| 1638 |
|
} |
| 1639 |
|
|
| 1640 |
|
|
| 1641 |
|
|
| 1642 |
|
@see |
| 1643 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 1644 |
28
|
@Override... |
| 1645 |
|
public void startServiceResolver(String type) { |
| 1646 |
28
|
DNSTaskStarter.Factory.getInstance().getStarter(this.getDns()).startServiceResolver(type); |
| 1647 |
|
} |
| 1648 |
|
|
| 1649 |
|
|
| 1650 |
|
|
| 1651 |
|
@see |
| 1652 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 1653 |
329
|
@Override... |
| 1654 |
|
public void startResponder(DNSIncoming in, int port) { |
| 1655 |
342
|
DNSTaskStarter.Factory.getInstance().getStarter(this.getDns()).startResponder(in, port); |
| 1656 |
|
} |
| 1657 |
|
|
| 1658 |
|
|
| 1659 |
|
|
| 1660 |
|
|
| 1661 |
|
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.5 |
|
| 1662 |
|
protected class Shutdown implements Runnable { |
| 1663 |
|
@inheritDoc |
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 0.5 |
|
| 1664 |
0
|
@Override... |
| 1665 |
|
public void run() { |
| 1666 |
0
|
try { |
| 1667 |
0
|
_shutdown = null; |
| 1668 |
0
|
close(); |
| 1669 |
|
} catch (Throwable exception) { |
| 1670 |
0
|
System.err.println("Error while shuting down. " + exception); |
| 1671 |
|
} |
| 1672 |
|
} |
| 1673 |
|
} |
| 1674 |
|
|
| 1675 |
|
private final Object _recoverLock = new Object(); |
| 1676 |
|
|
| 1677 |
|
|
| 1678 |
|
|
| 1679 |
|
|
|
|
|
| 0% |
Uncovered Elements: 12 (12) |
Complexity: 6 |
Complexity Density: 0.75 |
|
| 1680 |
0
|
public void recover() {... |
| 1681 |
0
|
logger.finer(this.getName() + "recover()"); |
| 1682 |
|
|
| 1683 |
|
|
| 1684 |
0
|
if (this.isClosing() || this.isClosed() || this.isCanceling() || this.isCanceled()) { |
| 1685 |
0
|
return; |
| 1686 |
|
} |
| 1687 |
|
|
| 1688 |
|
|
| 1689 |
|
|
| 1690 |
0
|
synchronized (_recoverLock) { |
| 1691 |
|
|
| 1692 |
|
|
| 1693 |
0
|
if (this.cancelState()) { |
| 1694 |
0
|
logger.finer(this.getName() + "recover() thread " + Thread.currentThread().getName()); |
| 1695 |
0
|
Thread recover = new Thread(this.getName() + ".recover()") { |
| 1696 |
|
|
| 1697 |
|
@inheritDoc |
| 1698 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 1699 |
0
|
@Override... |
| 1700 |
|
public void run() { |
| 1701 |
0
|
__recover(); |
| 1702 |
|
} |
| 1703 |
|
}; |
| 1704 |
0
|
recover.start(); |
| 1705 |
|
} |
| 1706 |
|
} |
| 1707 |
|
} |
| 1708 |
|
|
|
|
|
| 0% |
Uncovered Elements: 33 (33) |
Complexity: 6 |
Complexity Density: 0.24 |
|
| 1709 |
0
|
void __recover() {... |
| 1710 |
|
|
| 1711 |
|
|
| 1712 |
0
|
if (logger.isLoggable(Level.FINER)) { |
| 1713 |
0
|
logger.finer(this.getName() + "recover() Cleanning up"); |
| 1714 |
|
} |
| 1715 |
|
|
| 1716 |
0
|
logger.warning("RECOVERING"); |
| 1717 |
|
|
| 1718 |
0
|
this.purgeTimer(); |
| 1719 |
|
|
| 1720 |
|
|
| 1721 |
0
|
final Collection<ServiceInfo> oldServiceInfos = new ArrayList<ServiceInfo>(getServices().values()); |
| 1722 |
|
|
| 1723 |
|
|
| 1724 |
0
|
this.unregisterAllServices(); |
| 1725 |
0
|
this.disposeServiceCollectors(); |
| 1726 |
|
|
| 1727 |
0
|
this.waitForCanceled(DNSConstants.CLOSE_TIMEOUT); |
| 1728 |
|
|
| 1729 |
|
|
| 1730 |
0
|
this.purgeStateTimer(); |
| 1731 |
|
|
| 1732 |
|
|
| 1733 |
|
|
| 1734 |
0
|
this.closeMulticastSocket(); |
| 1735 |
|
|
| 1736 |
|
|
| 1737 |
0
|
this.getCache().clear(); |
| 1738 |
0
|
if (logger.isLoggable(Level.FINER)) { |
| 1739 |
0
|
logger.finer(this.getName() + "recover() All is clean"); |
| 1740 |
|
} |
| 1741 |
|
|
| 1742 |
0
|
if (this.isCanceled()) { |
| 1743 |
|
|
| 1744 |
|
|
| 1745 |
|
|
| 1746 |
0
|
for (ServiceInfo info : oldServiceInfos) { |
| 1747 |
0
|
((ServiceInfoImpl) info).recoverState(); |
| 1748 |
|
} |
| 1749 |
0
|
this.recoverState(); |
| 1750 |
|
|
| 1751 |
0
|
try { |
| 1752 |
0
|
this.openMulticastSocket(this.getLocalHost()); |
| 1753 |
0
|
this.start(oldServiceInfos); |
| 1754 |
|
} catch (final Exception exception) { |
| 1755 |
0
|
logger.log(Level.WARNING, this.getName() + "recover() Start services exception ", exception); |
| 1756 |
|
} |
| 1757 |
0
|
logger.log(Level.WARNING, this.getName() + "recover() We are back!"); |
| 1758 |
|
} else { |
| 1759 |
|
|
| 1760 |
0
|
logger.log(Level.WARNING, this.getName() + "recover() Could not recover we are Down!"); |
| 1761 |
0
|
if (this.getDelegate() != null) { |
| 1762 |
0
|
this.getDelegate().cannotRecoverFromIOError(this.getDns(), oldServiceInfos); |
| 1763 |
|
} |
| 1764 |
|
} |
| 1765 |
|
|
| 1766 |
|
} |
| 1767 |
|
|
|
|
|
| 86.7% |
Uncovered Elements: 2 (15) |
Complexity: 4 |
Complexity Density: 0.36 |
|
| 1768 |
90
|
public void cleanCache() {... |
| 1769 |
90
|
long now = System.currentTimeMillis(); |
| 1770 |
90
|
for (DNSEntry entry : this.getCache().allValues()) { |
| 1771 |
505
|
try { |
| 1772 |
505
|
DNSRecord record = (DNSRecord) entry; |
| 1773 |
504
|
if (record.isExpired(now)) { |
| 1774 |
17
|
this.updateRecord(now, record, Operation.Remove); |
| 1775 |
17
|
this.getCache().removeDNSEntry(record); |
| 1776 |
488
|
} else if (record.isStale(now)) { |
| 1777 |
|
|
| 1778 |
40
|
this.renewServiceCollector(record); |
| 1779 |
|
} |
| 1780 |
|
} catch (Exception exception) { |
| 1781 |
0
|
logger.log(Level.SEVERE, this.getName() + ".Error while reaping records: " + entry, exception); |
| 1782 |
0
|
logger.severe(this.toString()); |
| 1783 |
|
} |
| 1784 |
|
} |
| 1785 |
|
} |
| 1786 |
|
|
| 1787 |
|
|
| 1788 |
|
@inheritDoc |
| 1789 |
|
|
|
|
|
| 66.7% |
Uncovered Elements: 11 (33) |
Complexity: 7 |
Complexity Density: 0.33 |
|
| 1790 |
29
|
@Override... |
| 1791 |
|
public void close() { |
| 1792 |
29
|
if (this.isClosing()) { |
| 1793 |
0
|
return; |
| 1794 |
|
} |
| 1795 |
|
|
| 1796 |
29
|
if (logger.isLoggable(Level.FINER)) { |
| 1797 |
0
|
logger.finer("Cancelling JmDNS: " + this); |
| 1798 |
|
} |
| 1799 |
|
|
| 1800 |
|
|
| 1801 |
29
|
if (this.closeState()) { |
| 1802 |
|
|
| 1803 |
|
|
| 1804 |
|
|
| 1805 |
29
|
logger.finer("Canceling the timer"); |
| 1806 |
29
|
this.cancelTimer(); |
| 1807 |
|
|
| 1808 |
|
|
| 1809 |
29
|
this.unregisterAllServices(); |
| 1810 |
29
|
this.disposeServiceCollectors(); |
| 1811 |
|
|
| 1812 |
29
|
if (logger.isLoggable(Level.FINER)) { |
| 1813 |
0
|
logger.finer("Wait for JmDNS cancel: " + this); |
| 1814 |
|
} |
| 1815 |
29
|
this.waitForCanceled(DNSConstants.CLOSE_TIMEOUT); |
| 1816 |
|
|
| 1817 |
|
|
| 1818 |
29
|
logger.finer("Canceling the state timer"); |
| 1819 |
29
|
this.cancelStateTimer(); |
| 1820 |
|
|
| 1821 |
|
|
| 1822 |
29
|
_executor.shutdown(); |
| 1823 |
|
|
| 1824 |
|
|
| 1825 |
29
|
this.closeMulticastSocket(); |
| 1826 |
|
|
| 1827 |
|
|
| 1828 |
29
|
if (_shutdown != null) { |
| 1829 |
0
|
Runtime.getRuntime().removeShutdownHook(_shutdown); |
| 1830 |
|
} |
| 1831 |
|
|
| 1832 |
29
|
if (logger.isLoggable(Level.FINER)) { |
| 1833 |
0
|
logger.finer("JmDNS closed."); |
| 1834 |
|
} |
| 1835 |
|
} |
| 1836 |
29
|
advanceState(null); |
| 1837 |
|
} |
| 1838 |
|
|
| 1839 |
|
|
| 1840 |
|
@inheritDoc |
| 1841 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 1842 |
0
|
@Override... |
| 1843 |
|
@Deprecated |
| 1844 |
|
public void printServices() { |
| 1845 |
0
|
System.err.println(toString()); |
| 1846 |
|
} |
| 1847 |
|
|
| 1848 |
|
|
| 1849 |
|
@inheritDoc |
| 1850 |
|
|
|
|
|
| 0% |
Uncovered Elements: 37 (37) |
Complexity: 2 |
Complexity Density: 0.06 |
|
| 1851 |
0
|
@Override... |
| 1852 |
|
public String toString() { |
| 1853 |
0
|
final StringBuilder aLog = new StringBuilder(2048); |
| 1854 |
0
|
aLog.append("\t---- Local Host -----"); |
| 1855 |
0
|
aLog.append("\n\t"); |
| 1856 |
0
|
aLog.append(_localHost); |
| 1857 |
0
|
aLog.append("\n\t---- Services -----"); |
| 1858 |
0
|
for (String key : _services.keySet()) { |
| 1859 |
0
|
aLog.append("\n\t\tService: "); |
| 1860 |
0
|
aLog.append(key); |
| 1861 |
0
|
aLog.append(": "); |
| 1862 |
0
|
aLog.append(_services.get(key)); |
| 1863 |
|
} |
| 1864 |
0
|
aLog.append("\n"); |
| 1865 |
0
|
aLog.append("\t---- Types ----"); |
| 1866 |
0
|
for (String key : _serviceTypes.keySet()) { |
| 1867 |
0
|
ServiceTypeEntry subtypes = _serviceTypes.get(key); |
| 1868 |
0
|
aLog.append("\n\t\tType: "); |
| 1869 |
0
|
aLog.append(subtypes.getType()); |
| 1870 |
0
|
aLog.append(": "); |
| 1871 |
0
|
aLog.append(subtypes.isEmpty() ? "no subtypes" : subtypes); |
| 1872 |
|
} |
| 1873 |
0
|
aLog.append("\n"); |
| 1874 |
0
|
aLog.append(_cache.toString()); |
| 1875 |
0
|
aLog.append("\n"); |
| 1876 |
0
|
aLog.append("\t---- Service Collectors ----"); |
| 1877 |
0
|
for (String key : _serviceCollectors.keySet()) { |
| 1878 |
0
|
aLog.append("\n\t\tService Collector: "); |
| 1879 |
0
|
aLog.append(key); |
| 1880 |
0
|
aLog.append(": "); |
| 1881 |
0
|
aLog.append(_serviceCollectors.get(key)); |
| 1882 |
|
} |
| 1883 |
0
|
aLog.append("\n"); |
| 1884 |
0
|
aLog.append("\t---- Service Listeners ----"); |
| 1885 |
0
|
for (String key : _serviceListeners.keySet()) { |
| 1886 |
0
|
aLog.append("\n\t\tService Listener: "); |
| 1887 |
0
|
aLog.append(key); |
| 1888 |
0
|
aLog.append(": "); |
| 1889 |
0
|
aLog.append(_serviceListeners.get(key)); |
| 1890 |
|
} |
| 1891 |
0
|
return aLog.toString(); |
| 1892 |
|
} |
| 1893 |
|
|
| 1894 |
|
|
| 1895 |
|
@inheritDoc |
| 1896 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 1897 |
18
|
@Override... |
| 1898 |
|
public ServiceInfo[] list(String type) { |
| 1899 |
18
|
return this.list(type, DNSConstants.SERVICE_INFO_TIMEOUT); |
| 1900 |
|
} |
| 1901 |
|
|
| 1902 |
|
|
| 1903 |
|
@inheritDoc |
| 1904 |
|
|
|
|
|
| 75% |
Uncovered Elements: 6 (24) |
Complexity: 7 |
Complexity Density: 0.5 |
|
| 1905 |
18
|
@Override... |
| 1906 |
|
public ServiceInfo[] list(String type, long timeout) { |
| 1907 |
18
|
this.cleanCache(); |
| 1908 |
|
|
| 1909 |
|
|
| 1910 |
|
|
| 1911 |
|
|
| 1912 |
|
|
| 1913 |
|
|
| 1914 |
|
|
| 1915 |
|
|
| 1916 |
18
|
String loType = type.toLowerCase(); |
| 1917 |
|
|
| 1918 |
18
|
boolean newCollectorCreated = false; |
| 1919 |
18
|
if (this.isCanceling() || this.isCanceled()) { |
| 1920 |
0
|
return new ServiceInfo[0]; |
| 1921 |
|
} |
| 1922 |
|
|
| 1923 |
18
|
ServiceCollector collector = _serviceCollectors.get(loType); |
| 1924 |
18
|
if (collector == null) { |
| 1925 |
7
|
newCollectorCreated = _serviceCollectors.putIfAbsent(loType, new ServiceCollector(type)) == null; |
| 1926 |
7
|
collector = _serviceCollectors.get(loType); |
| 1927 |
7
|
if (newCollectorCreated) { |
| 1928 |
7
|
this.addServiceListener(type, collector, ListenerStatus.SYNCHONEOUS); |
| 1929 |
|
} |
| 1930 |
|
} |
| 1931 |
18
|
if (logger.isLoggable(Level.FINER)) { |
| 1932 |
0
|
logger.finer(this.getName() + ".collector: " + collector); |
| 1933 |
|
} |
| 1934 |
|
|
| 1935 |
18
|
return (collector != null ? collector.list(timeout) : new ServiceInfo[0]); |
| 1936 |
|
} |
| 1937 |
|
|
| 1938 |
|
|
| 1939 |
|
@inheritDoc |
| 1940 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 1941 |
0
|
@Override... |
| 1942 |
|
public Map<String, ServiceInfo[]> listBySubtype(String type) { |
| 1943 |
0
|
return this.listBySubtype(type, DNSConstants.SERVICE_INFO_TIMEOUT); |
| 1944 |
|
} |
| 1945 |
|
|
| 1946 |
|
|
| 1947 |
|
@inheritDoc |
| 1948 |
|
|
|
|
|
| 0% |
Uncovered Elements: 13 (13) |
Complexity: 2 |
Complexity Density: 0.18 |
|
| 1949 |
0
|
@Override... |
| 1950 |
|
public Map<String, ServiceInfo[]> listBySubtype(String type, long timeout) { |
| 1951 |
0
|
Map<String, List<ServiceInfo>> map = new HashMap<String, List<ServiceInfo>>(5); |
| 1952 |
0
|
for (ServiceInfo info : this.list(type, timeout)) { |
| 1953 |
0
|
String subtype = info.getSubtype().toLowerCase(); |
| 1954 |
0
|
if (!map.containsKey(subtype)) { |
| 1955 |
0
|
map.put(subtype, new ArrayList<ServiceInfo>(10)); |
| 1956 |
|
} |
| 1957 |
0
|
map.get(subtype).add(info); |
| 1958 |
|
} |
| 1959 |
|
|
| 1960 |
0
|
Map<String, ServiceInfo[]> result = new HashMap<String, ServiceInfo[]>(map.size()); |
| 1961 |
0
|
for (String subtype : map.keySet()) { |
| 1962 |
0
|
List<ServiceInfo> infoForSubType = map.get(subtype); |
| 1963 |
0
|
result.put(subtype, infoForSubType.toArray(new ServiceInfo[infoForSubType.size()])); |
| 1964 |
|
} |
| 1965 |
|
|
| 1966 |
0
|
return result; |
| 1967 |
|
} |
| 1968 |
|
|
| 1969 |
|
|
| 1970 |
|
|
| 1971 |
|
|
| 1972 |
|
@see |
| 1973 |
|
|
|
|
|
| 72.7% |
Uncovered Elements: 3 (11) |
Complexity: 3 |
Complexity Density: 0.43 |
|
| 1974 |
29
|
private void disposeServiceCollectors() {... |
| 1975 |
29
|
if (logger.isLoggable(Level.FINER)) { |
| 1976 |
0
|
logger.finer("disposeServiceCollectors()"); |
| 1977 |
|
} |
| 1978 |
29
|
for (String type : _serviceCollectors.keySet()) { |
| 1979 |
17
|
ServiceCollector collector = _serviceCollectors.get(type); |
| 1980 |
17
|
if (collector != null) { |
| 1981 |
17
|
this.removeServiceListener(type, collector); |
| 1982 |
17
|
_serviceCollectors.remove(type, collector); |
| 1983 |
|
} |
| 1984 |
|
} |
| 1985 |
|
} |
| 1986 |
|
|
| 1987 |
|
|
| 1988 |
|
|
| 1989 |
|
|
| 1990 |
|
@see |
| 1991 |
|
|
|
|
|
| 57.3% |
Uncovered Elements: 32 (75) |
Complexity: 21 |
Complexity Density: 0.41 |
|
| 1992 |
|
private static class ServiceCollector implements ServiceListener { |
| 1993 |
|
|
| 1994 |
|
|
| 1995 |
|
|
| 1996 |
|
|
| 1997 |
|
|
| 1998 |
|
private final ConcurrentMap<String, ServiceInfo> _infos; |
| 1999 |
|
|
| 2000 |
|
|
| 2001 |
|
|
| 2002 |
|
|
| 2003 |
|
private final ConcurrentMap<String, ServiceEvent> _events; |
| 2004 |
|
|
| 2005 |
|
|
| 2006 |
|
|
| 2007 |
|
|
| 2008 |
|
private final String _type; |
| 2009 |
|
|
| 2010 |
|
|
| 2011 |
|
|
| 2012 |
|
|
| 2013 |
|
private volatile boolean _needToWaitForInfos; |
| 2014 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
| 2015 |
45
|
public ServiceCollector(String type) {... |
| 2016 |
45
|
super(); |
| 2017 |
45
|
_infos = new ConcurrentHashMap<String, ServiceInfo>(); |
| 2018 |
45
|
_events = new ConcurrentHashMap<String, ServiceEvent>(); |
| 2019 |
45
|
_type = type; |
| 2020 |
45
|
_needToWaitForInfos = true; |
| 2021 |
|
} |
| 2022 |
|
|
| 2023 |
|
|
| 2024 |
|
|
| 2025 |
|
|
| 2026 |
|
@param |
| 2027 |
|
|
| 2028 |
|
|
|
|
|
| 80% |
Uncovered Elements: 3 (15) |
Complexity: 5 |
Complexity Density: 0.56 |
|
| 2029 |
18
|
@Override... |
| 2030 |
|
public void serviceAdded(ServiceEvent event) { |
| 2031 |
18
|
synchronized (this) { |
| 2032 |
18
|
ServiceInfo info = event.getInfo(); |
| 2033 |
18
|
if ((info != null) && (info.hasData())) { |
| 2034 |
1
|
_infos.put(event.getName(), info); |
| 2035 |
|
} else { |
| 2036 |
17
|
String subtype = (info != null ? info.getSubtype() : ""); |
| 2037 |
17
|
info = ((JmDNSImpl) event.getDNS()).resolveServiceInfo(event.getType(), event.getName(), subtype, true); |
| 2038 |
17
|
if (info != null) { |
| 2039 |
17
|
_infos.put(event.getName(), info); |
| 2040 |
|
} else { |
| 2041 |
0
|
_events.put(event.getName(), event); |
| 2042 |
|
} |
| 2043 |
|
} |
| 2044 |
|
} |
| 2045 |
|
} |
| 2046 |
|
|
| 2047 |
|
|
| 2048 |
|
|
| 2049 |
|
|
| 2050 |
|
@param |
| 2051 |
|
|
| 2052 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 2053 |
5
|
@Override... |
| 2054 |
|
public void serviceRemoved(ServiceEvent event) { |
| 2055 |
5
|
synchronized (this) { |
| 2056 |
5
|
_infos.remove(event.getName()); |
| 2057 |
5
|
_events.remove(event.getName()); |
| 2058 |
|
} |
| 2059 |
|
} |
| 2060 |
|
|
| 2061 |
|
|
| 2062 |
|
|
| 2063 |
|
|
| 2064 |
|
@param |
| 2065 |
|
|
| 2066 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 2067 |
22
|
@Override... |
| 2068 |
|
public void serviceResolved(ServiceEvent event) { |
| 2069 |
22
|
synchronized (this) { |
| 2070 |
22
|
_infos.put(event.getName(), event.getInfo()); |
| 2071 |
22
|
_events.remove(event.getName()); |
| 2072 |
|
} |
| 2073 |
|
} |
| 2074 |
|
|
| 2075 |
|
|
| 2076 |
|
|
| 2077 |
|
|
| 2078 |
|
@param |
| 2079 |
|
|
| 2080 |
|
@return |
| 2081 |
|
|
|
|
|
| 78.9% |
Uncovered Elements: 4 (19) |
Complexity: 10 |
Complexity Density: 0.91 |
|
| 2082 |
18
|
public ServiceInfo[] list(long timeout) {... |
| 2083 |
18
|
if (_infos.isEmpty() || !_events.isEmpty() || _needToWaitForInfos) { |
| 2084 |
15
|
long loops = (timeout / 200L); |
| 2085 |
15
|
if (loops < 1) { |
| 2086 |
0
|
loops = 1; |
| 2087 |
|
} |
| 2088 |
465
|
for (int i = 0; i < loops; i++) { |
| 2089 |
450
|
try { |
| 2090 |
450
|
Thread.sleep(200); |
| 2091 |
|
} catch (final InterruptedException e) { |
| 2092 |
|
|
| 2093 |
|
} |
| 2094 |
450
|
if (_events.isEmpty() && !_infos.isEmpty() && !_needToWaitForInfos) { |
| 2095 |
0
|
break; |
| 2096 |
|
} |
| 2097 |
|
} |
| 2098 |
|
} |
| 2099 |
18
|
_needToWaitForInfos = false; |
| 2100 |
18
|
return _infos.values().toArray(new ServiceInfo[_infos.size()]); |
| 2101 |
|
} |
| 2102 |
|
|
| 2103 |
|
|
| 2104 |
|
@inheritDoc |
| 2105 |
|
|
|
|
|
| 0% |
Uncovered Elements: 24 (24) |
Complexity: 3 |
Complexity Density: 0.15 |
|
| 2106 |
0
|
@Override... |
| 2107 |
|
public String toString() { |
| 2108 |
0
|
final StringBuffer aLog = new StringBuffer(); |
| 2109 |
0
|
aLog.append("\n\tType: "); |
| 2110 |
0
|
aLog.append(_type); |
| 2111 |
0
|
if (_infos.isEmpty()) { |
| 2112 |
0
|
aLog.append("\n\tNo services collected."); |
| 2113 |
|
} else { |
| 2114 |
0
|
aLog.append("\n\tServices"); |
| 2115 |
0
|
for (String key : _infos.keySet()) { |
| 2116 |
0
|
aLog.append("\n\t\tService: "); |
| 2117 |
0
|
aLog.append(key); |
| 2118 |
0
|
aLog.append(": "); |
| 2119 |
0
|
aLog.append(_infos.get(key)); |
| 2120 |
|
} |
| 2121 |
|
} |
| 2122 |
0
|
if (_events.isEmpty()) { |
| 2123 |
0
|
aLog.append("\n\tNo event queued."); |
| 2124 |
|
} else { |
| 2125 |
0
|
aLog.append("\n\tEvents"); |
| 2126 |
0
|
for (String key : _events.keySet()) { |
| 2127 |
0
|
aLog.append("\n\t\tEvent: "); |
| 2128 |
0
|
aLog.append(key); |
| 2129 |
0
|
aLog.append(": "); |
| 2130 |
0
|
aLog.append(_events.get(key)); |
| 2131 |
|
} |
| 2132 |
|
} |
| 2133 |
0
|
return aLog.toString(); |
| 2134 |
|
} |
| 2135 |
|
} |
| 2136 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 3 |
Complexity Density: 0.6 |
|
| 2137 |
47
|
static String toUnqualifiedName(String type, String qualifiedName) {... |
| 2138 |
49
|
String loType = type.toLowerCase(); |
| 2139 |
49
|
String loQualifiedName = qualifiedName.toLowerCase(); |
| 2140 |
49
|
if (loQualifiedName.endsWith(loType) && !(loQualifiedName.equals(loType))) { |
| 2141 |
41
|
return qualifiedName.substring(0, qualifiedName.length() - type.length() - 1); |
| 2142 |
|
} |
| 2143 |
8
|
return qualifiedName; |
| 2144 |
|
} |
| 2145 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 2146 |
1133
|
public Map<String, ServiceInfo> getServices() {... |
| 2147 |
1138
|
return _services; |
| 2148 |
|
} |
| 2149 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 2150 |
49
|
public void setLastThrottleIncrement(long lastThrottleIncrement) {... |
| 2151 |
49
|
this._lastThrottleIncrement = lastThrottleIncrement; |
| 2152 |
|
} |
| 2153 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 2154 |
49
|
public long getLastThrottleIncrement() {... |
| 2155 |
49
|
return _lastThrottleIncrement; |
| 2156 |
|
} |
| 2157 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 2158 |
49
|
public void setThrottle(int throttle) {... |
| 2159 |
49
|
this._throttle = throttle; |
| 2160 |
|
} |
| 2161 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 2162 |
20
|
public int getThrottle() {... |
| 2163 |
20
|
return _throttle; |
| 2164 |
|
} |
| 2165 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 2166 |
180
|
public static Random getRandom() {... |
| 2167 |
176
|
return _random; |
| 2168 |
|
} |
| 2169 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 2170 |
688
|
public void ioLock() {... |
| 2171 |
694
|
_ioLock.lock(); |
| 2172 |
|
} |
| 2173 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 2174 |
691
|
public void ioUnlock() {... |
| 2175 |
698
|
_ioLock.unlock(); |
| 2176 |
|
} |
| 2177 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 2178 |
0
|
public void setPlannedAnswer(DNSIncoming plannedAnswer) {... |
| 2179 |
0
|
this._plannedAnswer = plannedAnswer; |
| 2180 |
|
} |
| 2181 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 2182 |
0
|
public DNSIncoming getPlannedAnswer() {... |
| 2183 |
0
|
return _plannedAnswer; |
| 2184 |
|
} |
| 2185 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 2186 |
0
|
void setLocalHost(HostInfo localHost) {... |
| 2187 |
0
|
this._localHost = localHost; |
| 2188 |
|
} |
| 2189 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 2190 |
95
|
public Map<String, ServiceTypeEntry> getServiceTypes() {... |
| 2191 |
95
|
return _serviceTypes; |
| 2192 |
|
} |
| 2193 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 2194 |
679
|
public MulticastSocket getSocket() {... |
| 2195 |
685
|
return _socket; |
| 2196 |
|
} |
| 2197 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 2198 |
331
|
public InetAddress getGroup() {... |
| 2199 |
343
|
return _group; |
| 2200 |
|
} |
| 2201 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 2202 |
0
|
@Override... |
| 2203 |
|
public Delegate getDelegate() { |
| 2204 |
0
|
return this._delegate; |
| 2205 |
|
} |
| 2206 |
|
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 2207 |
0
|
@Override... |
| 2208 |
|
public Delegate setDelegate(Delegate delegate) { |
| 2209 |
0
|
Delegate previous = this._delegate; |
| 2210 |
0
|
this._delegate = delegate; |
| 2211 |
0
|
return previous; |
| 2212 |
|
} |
| 2213 |
|
|
| 2214 |
|
} |