Fix findbugs violations in netconf
[netconf.git] / netconf / sal-netconf-connector / src / main / java / org / opendaylight / netconf / sal / connect / netconf / schema / YangLibrarySchemaYangSourceProvider.java
index 33af8ec298be82279c80e9d13b3170eb0a16eaf1..4fa5127c6e32f328e08f0d282824443b5986240e 100644 (file)
@@ -10,11 +10,12 @@ package org.opendaylight.netconf.sal.connect.netconf.schema;
 import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import com.google.common.io.ByteStreams;
-import com.google.common.util.concurrent.CheckedFuture;
 import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.ListenableFuture;
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.URL;
+import java.nio.charset.Charset;
 import java.util.Map;
 import org.opendaylight.netconf.sal.connect.util.RemoteDeviceId;
 import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceException;
@@ -41,28 +42,26 @@ public final class YangLibrarySchemaYangSourceProvider implements SchemaSourcePr
     }
 
     @Override
-    public CheckedFuture<? extends YangTextSchemaSource, SchemaSourceException> getSource(
+    public ListenableFuture<? extends YangTextSchemaSource> getSource(
             final SourceIdentifier sourceIdentifier) {
         Preconditions.checkNotNull(sourceIdentifier);
         Preconditions.checkArgument(availableSources.containsKey(sourceIdentifier));
         return download(sourceIdentifier);
     }
 
-    private CheckedFuture<? extends YangTextSchemaSource, SchemaSourceException> download(
-            final SourceIdentifier sourceIdentifier) {
+    private ListenableFuture<? extends YangTextSchemaSource> download(final SourceIdentifier sourceIdentifier) {
         final URL url = availableSources.get(sourceIdentifier);
         try (InputStream in = url.openStream()) {
-            final String schemaContent = new String(ByteStreams.toByteArray(in));
+            final String schemaContent = new String(ByteStreams.toByteArray(in), Charset.defaultCharset());
             final NetconfRemoteSchemaYangSourceProvider.NetconfYangTextSchemaSource yangSource =
                     new NetconfRemoteSchemaYangSourceProvider
                             .NetconfYangTextSchemaSource(id, sourceIdentifier, Optional.of(schemaContent));
             LOG.debug("Source {} downloaded from a yang library's url {}", sourceIdentifier, url);
-            return Futures.immediateCheckedFuture(yangSource);
+            return Futures.immediateFuture(yangSource);
         } catch (IOException e) {
             LOG.warn("Unable to download source {} from a yang library's url {}", sourceIdentifier, url, e);
-            return Futures.immediateFailedCheckedFuture(
-                    new SchemaSourceException(
-                            "Unable to download remote schema for " + sourceIdentifier + " from " + url, e));
+            return Futures.immediateFailedFuture(new SchemaSourceException(
+                "Unable to download remote schema for " + sourceIdentifier + " from " + url, e));
         }
     }
 }