import com.google.common.io.ByteStreams;
import com.google.common.util.concurrent.ListenableFuture;
import java.io.IOException;
+import java.nio.charset.Charset;
import java.util.concurrent.ExecutionException;
import org.opendaylight.yanglib.api.YangLibService;
import org.opendaylight.yangtools.yang.common.Revision;
public class YangLibServiceImpl implements YangLibService {
private static final Logger LOG = LoggerFactory.getLogger(YangLibServiceImpl.class);
- private volatile SchemaRepository schemaRepository;
+ private final SchemaRepository schemaRepository;
- public YangLibServiceImpl() {
-
- }
-
- public void setSchemaRepository(final SchemaRepository schemaRepository) {
- LOG.debug("Setting schema repository {}", schemaRepository);
+ public YangLibServiceImpl(final SchemaRepository schemaRepository) {
this.schemaRepository = schemaRepository;
}
try {
final YangTextSchemaSource source = sourceFuture.get();
- return new String(ByteStreams.toByteArray(source.openStream()));
+ return new String(ByteStreams.toByteArray(source.openStream()), Charset.defaultCharset());
} catch (InterruptedException | ExecutionException | IOException e) {
throw new IllegalStateException("Unable to get schema " + sourceId, e);
}