False Resource Warning?

I get resource leak warnings in 's' and 'p' in this snippet. Is this warning valid?

try (StringWriter s = new StringWriter(); PrintWriter p = new PrintWriter(s)) { p.print(InetAddress.getLocalHost().getHostName()); p.print('/'); Enumeration<NetworkInterface> e = NetworkInterface.getNetworkInterfaces(); while (e.hasMoreElements()) { NetworkInterface i = e.nextElement(); System.out.println(i); if (i.getHardwareAddress() == null || i.getHardwareAddress().length == 0) continue; for (byte b : i.getHardwareAddress()) p.printf("%02x", b); return s.toString(); } throw new RuntimeException("Unable to determine Host ID"); } 
+4
source share
1 answer

In this fragment - no. There are no resources to talk about other than those managed by the JVM.

0
source

All Articles