use of java.net.MalformedURLException in project android_frameworks_base by ParanoidAndroid.
the class FileFilter method loadTestExpectations.
public void loadTestExpectations() {
URL url = null;
try {
url = new URL(ForwarderManager.getHostSchemePort(false) + "LayoutTests/" + TEST_EXPECTATIONS_TXT_PATH);
} catch (MalformedURLException e) {
assert false;
}
try {
InputStream inputStream = null;
BufferedReader bufferedReader = null;
try {
byte[] httpAnswer = FsUtils.readDataFromUrl(url);
if (httpAnswer == null) {
Log.w(LOG_TAG, "loadTestExpectations(): File not found: " + TEST_EXPECTATIONS_TXT_PATH);
return;
}
bufferedReader = new BufferedReader(new StringReader(new String(httpAnswer)));
String line;
String entry;
String[] parts;
String path;
Set<String> tokens;
while (true) {
line = bufferedReader.readLine();
if (line == null) {
break;
}
/** Remove the comment and trim */
entry = line.split("//", 2)[0].trim();
/** Omit empty lines, advance to next line */
if (entry.isEmpty()) {
continue;
}
/** Split on whitespace into path part and the rest */
parts = entry.split("\\s", 2);
/** At this point parts.length >= 1 */
if (parts.length == 1) {
Log.w(LOG_TAG + "::reloadConfiguration", "There are no options specified for the test!");
continue;
}
path = trimTrailingSlashIfPresent(parts[0]);
/** Split on whitespace */
tokens = new HashSet<String>(Arrays.asList(parts[1].split("\\s", 0)));
/** Chose the right collections to add to */
if (tokens.contains(TOKEN_CRASH)) {
mCrashList.add(path);
/** If test is on skip list we ignore any further options */
continue;
}
if (tokens.contains(TOKEN_FAIL)) {
mFailList.add(path);
}
if (tokens.contains(TOKEN_SLOW)) {
mSlowList.add(path);
}
}
} finally {
if (inputStream != null) {
inputStream.close();
}
if (bufferedReader != null) {
bufferedReader.close();
}
}
} catch (IOException e) {
Log.e(LOG_TAG, "url=" + url, e);
}
}
use of java.net.MalformedURLException in project android_frameworks_base by ParanoidAndroid.
the class FsUtils method getLayoutTestsDirContents.
public static List<String> getLayoutTestsDirContents(String dirRelativePath, boolean recurse, boolean mode) {
String modeString = (mode ? "folders" : "files");
URL url = null;
try {
url = new URL(SCRIPT_URL + "?path=" + dirRelativePath + "&recurse=" + recurse + "&mode=" + modeString);
} catch (MalformedURLException e) {
Log.e(LOG_TAG, "path=" + dirRelativePath + " recurse=" + recurse + " mode=" + modeString, e);
return new LinkedList<String>();
}
HttpGet httpRequest = new HttpGet(url.toString());
ResponseHandler<LinkedList<String>> handler = new ResponseHandler<LinkedList<String>>() {
@Override
public LinkedList<String> handleResponse(HttpResponse response) throws IOException {
LinkedList<String> lines = new LinkedList<String>();
if (response.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {
return lines;
}
HttpEntity entity = response.getEntity();
if (entity == null) {
return lines;
}
BufferedReader reader = new BufferedReader(new InputStreamReader(entity.getContent()));
String line;
try {
while ((line = reader.readLine()) != null) {
lines.add(line);
}
} finally {
if (reader != null) {
reader.close();
}
}
return lines;
}
};
try {
return getHttpClient().execute(httpRequest, handler);
} catch (IOException e) {
Log.e(LOG_TAG, "getLayoutTestsDirContents(): HTTP GET failed for URL " + url);
return null;
}
}
use of java.net.MalformedURLException in project pinpoint by naver.
the class AgentDirBaseClassPathResolver method resolvePlugins.
@Override
public URL[] resolvePlugins() {
final File file = new File(getAgentPluginPath());
if (!file.exists()) {
logger.warn(file + " not found");
return new URL[0];
}
if (!file.isDirectory()) {
logger.warn(file + " is not a directory");
return new URL[0];
}
final File[] jars = file.listFiles(new FilenameFilter() {
@Override
public boolean accept(File dir, String name) {
return name.endsWith(".jar");
}
});
if (jars == null || jars.length == 0) {
return new URL[0];
}
final URL[] urls = new URL[jars.length];
for (int i = 0; i < jars.length; i++) {
try {
urls[i] = jars[i].toURI().toURL();
} catch (MalformedURLException e) {
// TODO have to change to PinpointException AFTER moving the exception to pinpoint-common
throw new RuntimeException("Fail to load plugin jars", e);
}
}
for (File pluginJar : jars) {
logger.info("Found plugins: " + pluginJar.getPath());
}
return urls;
}
use of java.net.MalformedURLException in project neo4j by neo4j.
the class HotspotManagementSupport method createServer.
private JMXConnectorServer createServer(int port, boolean useSSL, Log log) {
MBeanServer server = getMBeanServer();
final JMXServiceURL url;
try {
url = new JMXServiceURL("rmi", null, port);
} catch (MalformedURLException e) {
log.warn("Failed to start JMX Server", e);
return null;
}
Map<String, Object> env = new HashMap<>();
if (useSSL) {
env.put(RMIConnectorServer.RMI_CLIENT_SOCKET_FACTORY_ATTRIBUTE, new SslRMIClientSocketFactory());
env.put(RMIConnectorServer.RMI_SERVER_SOCKET_FACTORY_ATTRIBUTE, new SslRMIServerSocketFactory());
}
try {
return JMXConnectorServerFactory.newJMXConnectorServer(url, env, server);
} catch (IOException e) {
log.warn("Failed to start JMX Server", e);
return null;
}
}
use of java.net.MalformedURLException in project generator by mybatis.
the class ClassloaderUtility method getCustomClassloader.
public static ClassLoader getCustomClassloader(List<String> entries) {
List<URL> urls = new ArrayList<URL>();
File file;
if (entries != null) {
for (String classPathEntry : entries) {
file = new File(classPathEntry);
if (!file.exists()) {
throw new RuntimeException(getString("RuntimeError.9", //$NON-NLS-1$
classPathEntry));
}
try {
urls.add(file.toURI().toURL());
} catch (MalformedURLException e) {
// this shouldn't happen, but just in case...
throw new RuntimeException(getString("RuntimeError.9", //$NON-NLS-1$
classPathEntry));
}
}
}
ClassLoader parent = Thread.currentThread().getContextClassLoader();
URLClassLoader ucl = new URLClassLoader(urls.toArray(new URL[urls.size()]), parent);
return ucl;
}
Aggregations