More robust line-ending detection for Bundles

This commit is contained in:
Zack Shoylev 2015-01-21 18:24:50 -06:00
parent f5523c9412
commit 46f4a4e454

View File

@ -41,7 +41,7 @@ public final class Bundles {
/**
* instantiates the supplied classnames using the bundle classloader, and casts to the supplied type. Any errors are
* silently ignored.
*
*
* @return instances that could be instantiated without error.
*/
public static <T> ImmutableSet<T> instantiateAvailableClasses(Bundle bundle, Iterable<String> classNames,
@ -60,7 +60,7 @@ public final class Bundles {
/**
* A function that loads classes from the bundle, or returns null if the class isn't found or assignable by the input
* parameter
*
*
* @param bundle
* where to find classes
* @param clazz
@ -87,7 +87,7 @@ public final class Bundles {
/**
* A function that instantiates classes or returns null, if it encounters any problems.
*
*
* @param clazz
* superclass to cast as
*/
@ -108,7 +108,7 @@ public final class Bundles {
/**
* Reads the resource from a {@link Bundle}.
*
*
* @param resourcePath
* The path to the resource.
* @param bundle
@ -131,6 +131,6 @@ public final class Bundles {
}
private static Iterable<String> splitOrEmptyAndClose(InputStream in) throws IOException {
return Splitter.on('\n').omitEmptyStrings().split(toStringAndClose(in));
return Splitter.onPattern("\r?\n").omitEmptyStrings().split(toStringAndClose(in));
}
}