From: Robert Varga Date: Tue, 8 Nov 2022 20:16:48 +0000 (+0100) Subject: Fix FB suppression X-Git-Tag: v5.0.0~121 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=33e564153df27586c29de292ca62f0b9f16c4e58;p=netconf.git Fix FB suppression Once we have a ByteSource, use it of a CharSource of UTF8 before reading it. This is the proper way of getting a String. Change-Id: Ifd92fe561b5864791b77342a3c9352ac23bd5048 Signed-off-by: Robert Varga --- diff --git a/netconf/tools/netconf-testtool/src/main/java/org/opendaylight/netconf/test/tool/NetconfDeviceSimulator.java b/netconf/tools/netconf-testtool/src/main/java/org/opendaylight/netconf/test/tool/NetconfDeviceSimulator.java index c776114b72..8407b94064 100644 --- a/netconf/tools/netconf-testtool/src/main/java/org/opendaylight/netconf/test/tool/NetconfDeviceSimulator.java +++ b/netconf/tools/netconf-testtool/src/main/java/org/opendaylight/netconf/test/tool/NetconfDeviceSimulator.java @@ -10,7 +10,6 @@ package org.opendaylight.netconf.test.tool; import com.google.common.collect.Collections2; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ThreadFactoryBuilder; -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import io.netty.channel.Channel; import io.netty.channel.ChannelFuture; import io.netty.channel.local.LocalAddress; @@ -23,6 +22,7 @@ import java.net.Inet4Address; import java.net.InetSocketAddress; import java.net.UnknownHostException; import java.nio.channels.AsynchronousChannelGroup; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.HashSet; import java.util.List; @@ -72,9 +72,7 @@ import org.opendaylight.yangtools.yang.parser.rfc7950.repo.TextToIRTransformer; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -@SuppressFBWarnings("DM_DEFAULT_ENCODING") public class NetconfDeviceSimulator implements Closeable { - private static final Logger LOG = LoggerFactory.getLogger(NetconfDeviceSimulator.class); private final NioEventLoopGroup nettyThreadgroup; @@ -348,8 +346,9 @@ public class NetconfDeviceSimulator implements Closeable { final SourceIdentifier moduleSourceIdentifier = new SourceIdentifier(module.getName(), module.getRevision().map(Revision::toString).orElse(null)); try { - final String moduleContent = new String( - consumer.getSchemaSource(moduleSourceIdentifier, YangTextSchemaSource.class).get().read()); + + final String moduleContent = consumer.getSchemaSource(moduleSourceIdentifier, YangTextSchemaSource.class) + .get().asCharSource(StandardCharsets.UTF_8).read(); capabilities.add(new YangModuleCapability(module, moduleContent)); //IOException would be thrown in creating SchemaContext already } catch (final ExecutionException | InterruptedException | IOException e) {