BUG-1173: ensure compatibility with Guava 17+ 31/7831/8
authorRobert Varga <rovarga@cisco.com>
Mon, 9 Jun 2014 17:35:21 +0000 (19:35 +0200)
committerRobert Varga <rovarga@cisco.com>
Sat, 14 Feb 2015 08:13:52 +0000 (09:13 +0100)
This migrates the sole user to the Guava-15+ API, as the API is removed
in version 17.

Change-Id: Ia587465e0289f5d98ec3da83cc3fc6765f8a8b38
Signed-off-by: Robert Varga <rovarga@cisco.com>
opendaylight/netconf/config-persister-impl/src/main/java/org/opendaylight/controller/netconf/persist/impl/ConfigPusherImpl.java
opendaylight/netconf/netconf-util/src/test/java/org/opendaylight/controller/netconf/util/test/XmlFileLoader.java

index cf9958e7f8abf44303aeb18f79a77d01b62d7a9b..0aebc68bbe3f653d9a738a3ec6121ee0c162d2a9 100644 (file)
@@ -115,7 +115,7 @@ public class ConfigPusherImpl implements ConfigPusher {
      */
     private synchronized EditAndCommitResponse pushConfigWithConflictingVersionRetries(ConfigSnapshotHolder configSnapshotHolder) throws NetconfDocumentedException {
         ConflictingVersionException lastException;
-        Stopwatch stopwatch = new Stopwatch();
+        Stopwatch stopwatch = Stopwatch.createUnstarted();
         do {
             String idForReporting = configSnapshotHolder.toString();
             SortedSet<String> expectedCapabilities = checkNotNull(configSnapshotHolder.getCapabilities(),
@@ -137,7 +137,7 @@ public class ConfigPusherImpl implements ConfigPusher {
     }
 
     private NetconfOperationService getOperationServiceWithRetries(Set<String> expectedCapabilities, String idForReporting) {
-        Stopwatch stopwatch = new Stopwatch().start();
+        Stopwatch stopwatch = Stopwatch.createStarted();
         NotEnoughCapabilitiesException lastException;
         do {
             try {
@@ -230,7 +230,7 @@ public class ConfigPusherImpl implements ConfigPusher {
             throw new IllegalStateException("Cannot parse " + configSnapshotHolder);
         }
         LOG.trace("Pushing last configuration to netconf: {}", configSnapshotHolder);
-        Stopwatch stopwatch = new Stopwatch().start();
+        Stopwatch stopwatch = Stopwatch.createStarted();
         NetconfMessage editConfigMessage = createEditConfigMessage(xmlToBePersisted);
 
         Document editResponseMessage = sendRequestGetResponseCheckIsOK(editConfigMessage, operationService,
index e1331b1380935e86bad9fa962060e8c02210ce24..176a0de9a48f1d87a7eebb4ac2e48a74b89cac6e 100644 (file)
@@ -10,11 +10,9 @@ package org.opendaylight.controller.netconf.util.test;
 
 import com.google.common.base.Charsets;
 import com.google.common.base.Preconditions;
-import com.google.common.io.CharStreams;
-import com.google.common.io.InputSupplier;
+import com.google.common.io.ByteSource;
 import java.io.IOException;
 import java.io.InputStream;
-import java.io.InputStreamReader;
 import javax.xml.parsers.ParserConfigurationException;
 import org.opendaylight.controller.netconf.api.NetconfMessage;
 import org.opendaylight.controller.netconf.util.xml.XmlUtil;
@@ -51,17 +49,13 @@ public class XmlFileLoader {
     public static String fileToString(final String fileName) throws IOException {
         try (InputStream resourceAsStream = XmlFileLoader.class.getClassLoader().getResourceAsStream(fileName)) {
             Preconditions.checkNotNull(resourceAsStream);
-
-            InputSupplier<? extends InputStream> supplier = new InputSupplier<InputStream>() {
+            return new ByteSource() {
                 @Override
-                public InputStream getInput() throws IOException {
+                public InputStream openStream() {
                     return resourceAsStream;
                 }
-            };
-
-            InputSupplier<InputStreamReader> readerSupplier = CharStreams.newReaderSupplier(supplier, Charsets.UTF_8);
+            }.asCharSource(Charsets.UTF_8).read();
 
-            return CharStreams.toString(readerSupplier);
         }
     }