Do not instantiate a ByteSource 86/26986/3
authorRobert Varga <rovarga@cisco.com>
Tue, 15 Sep 2015 01:08:52 +0000 (03:08 +0200)
committerGerrit Code Review <gerrit@opendaylight.org>
Fri, 18 Sep 2015 08:42:17 +0000 (08:42 +0000)
YangTextSchemaSource is already a ByteSource, no need to wrap it again.

Change-Id: I938704862c44d7eef6fdc55996580026a4b755bb
Signed-off-by: Robert Varga <rovarga@cisco.com>
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/util/TextToASTTransformer.java

index ae39e45aefe2b12044d99c26b8e78df149797d72..560ac833735e833104d6ebca5842878cd1d32929 100644 (file)
@@ -10,13 +10,10 @@ package org.opendaylight.yangtools.yang.parser.util;
 
 import com.google.common.annotations.Beta;
 import com.google.common.base.Charsets;
-import com.google.common.io.ByteSource;
 import com.google.common.util.concurrent.CheckedFuture;
 import com.google.common.util.concurrent.Futures;
-
 import java.io.IOException;
 import java.io.InputStream;
-
 import org.antlr.v4.runtime.tree.ParseTreeWalker;
 import org.opendaylight.yangtools.antlrv4.code.gen.YangParser.YangContext;
 import org.opendaylight.yangtools.yang.model.parser.api.YangSyntaxErrorException;
@@ -49,12 +46,7 @@ public final class TextToASTTransformer extends SchemaSourceTransformer<YangText
                 LOG.debug("Model {} validated successfully", input);
 
                 // Backwards compatibility
-                final String text = new ByteSource() {
-                    @Override
-                    public InputStream openStream() throws IOException {
-                        return input.openStream();
-                    }
-                }.asCharSource(Charsets.UTF_8).read();
+                final String text = input.asCharSource(Charsets.UTF_8).read();
 
                 return Futures.immediateCheckedFuture(ASTSchemaSource.create(input.getIdentifier().getName(), ctx, text));
             }