Deprecate Tools.slurp(..)
Change-Id: Id88c7e03a5bfcdfba2fb743ee7816576de25f59d
Showing
2 changed files
with
15 additions
and
4 deletions
| ... | @@ -24,7 +24,6 @@ import org.apache.felix.scr.annotations.Reference; | ... | @@ -24,7 +24,6 @@ import org.apache.felix.scr.annotations.Reference; |
| 24 | import org.apache.felix.scr.annotations.ReferenceCardinality; | 24 | import org.apache.felix.scr.annotations.ReferenceCardinality; |
| 25 | import org.apache.felix.scr.annotations.Service; | 25 | import org.apache.felix.scr.annotations.Service; |
| 26 | import org.onlab.util.SharedExecutors; | 26 | import org.onlab.util.SharedExecutors; |
| 27 | -import org.onlab.util.Tools; | ||
| 28 | import org.onosproject.cfg.ComponentConfigService; | 27 | import org.onosproject.cfg.ComponentConfigService; |
| 29 | import org.onosproject.core.ApplicationId; | 28 | import org.onosproject.core.ApplicationId; |
| 30 | import org.onosproject.core.ApplicationIdStore; | 29 | import org.onosproject.core.ApplicationIdStore; |
| ... | @@ -38,6 +37,10 @@ import org.slf4j.Logger; | ... | @@ -38,6 +37,10 @@ import org.slf4j.Logger; |
| 38 | import org.slf4j.LoggerFactory; | 37 | import org.slf4j.LoggerFactory; |
| 39 | 38 | ||
| 40 | import java.io.File; | 39 | import java.io.File; |
| 40 | +import java.io.IOException; | ||
| 41 | +import java.nio.file.Files; | ||
| 42 | +import java.nio.file.Path; | ||
| 43 | +import java.nio.file.Paths; | ||
| 41 | import java.util.Dictionary; | 44 | import java.util.Dictionary; |
| 42 | import java.util.List; | 45 | import java.util.List; |
| 43 | import java.util.Set; | 46 | import java.util.Set; |
| ... | @@ -87,9 +90,15 @@ public class CoreManager implements CoreService { | ... | @@ -87,9 +90,15 @@ public class CoreManager implements CoreService { |
| 87 | public void activate() { | 90 | public void activate() { |
| 88 | registerApplication(CORE_APP_NAME); | 91 | registerApplication(CORE_APP_NAME); |
| 89 | cfgService.registerProperties(getClass()); | 92 | cfgService.registerProperties(getClass()); |
| 90 | - List<String> versionLines = Tools.slurp(VERSION_FILE); | 93 | + try { |
| 91 | - if (versionLines != null && !versionLines.isEmpty()) { | 94 | + Path path = Paths.get(VERSION_FILE.getPath()); |
| 92 | - version = Version.version(versionLines.get(0)); | 95 | + List<String> versionLines = Files.readAllLines(path); |
| 96 | + if (versionLines != null && !versionLines.isEmpty()) { | ||
| 97 | + version = Version.version(versionLines.get(0)); | ||
| 98 | + } | ||
| 99 | + } catch (IOException e) { | ||
| 100 | + // version file not found, using default | ||
| 101 | + log.trace("Version file not found", e); | ||
| 93 | } | 102 | } |
| 94 | } | 103 | } |
| 95 | 104 | ... | ... |
| ... | @@ -299,7 +299,9 @@ public abstract class Tools { | ... | @@ -299,7 +299,9 @@ public abstract class Tools { |
| 299 | * | 299 | * |
| 300 | * @param path file path | 300 | * @param path file path |
| 301 | * @return file contents | 301 | * @return file contents |
| 302 | + * @deprecated in Emu release | ||
| 302 | */ | 303 | */ |
| 304 | + @Deprecated | ||
| 303 | public static List<String> slurp(File path) { | 305 | public static List<String> slurp(File path) { |
| 304 | try ( | 306 | try ( |
| 305 | BufferedReader br = new BufferedReader( | 307 | BufferedReader br = new BufferedReader( | ... | ... |
-
Please register or login to post a comment