Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoberto E. Escobar2012-10-22 23:48:30 +0000
committerRoberto E. Escobar2012-10-22 23:48:30 +0000
commit781ac5fd9f048c50a22d97e9cff2b68726404c92 (patch)
tree923f8bf8d706bd80a8c2a66e9218784ec707f81d
parent8b1ee4cbc772eb9ce8d58d8a405d7b3d1e4295b3 (diff)
downloadorg.eclipse.osee-781ac5fd9f048c50a22d97e9cff2b68726404c92.tar.gz
org.eclipse.osee-781ac5fd9f048c50a22d97e9cff2b68726404c92.tar.xz
org.eclipse.osee-781ac5fd9f048c50a22d97e9cff2b68726404c92.zip
bug: Fix NPE when running HttpProcessor outside of OSGI0.10.3.v201210232247_REL0.10.3.v201210230013_RC
-rw-r--r--plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/util/HttpProcessor.java32
1 files changed, 19 insertions, 13 deletions
diff --git a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/util/HttpProcessor.java b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/util/HttpProcessor.java
index 3ba0ff61b56..65349632846 100644
--- a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/util/HttpProcessor.java
+++ b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/util/HttpProcessor.java
@@ -84,25 +84,31 @@ public class HttpProcessor {
if (!proxyBypass) {
if (proxyService == null) {
BundleContext context = Activator.getBundleContext();
- ServiceReference reference = context.getServiceReference(IProxyService.class.getName());
- proxyService = (IProxyService) context.getService(reference);
- proxyService.addProxyChangeListener(new IProxyChangeListener() {
-
- @Override
- public void proxyInfoChanged(IProxyChangeEvent event) {
- proxiedData.clear();
- }
- });
+ if (context != null) {
+ ServiceReference<IProxyService> reference = context.getServiceReference(IProxyService.class);
+ proxyService = context.getService(reference);
+ }
+ if (proxyService != null) {
+ proxyService.addProxyChangeListener(new IProxyChangeListener() {
+
+ @Override
+ public void proxyInfoChanged(IProxyChangeEvent event) {
+ proxiedData.clear();
+ }
+ });
+ }
}
String key = String.format("%s_%s", uri.getScheme(), uri.getHost());
IProxyData[] datas = proxiedData.get(key);
- if (datas == null) {
+ if (datas == null && proxyService != null) {
datas = proxyService.select(uri);
proxiedData.put(key, datas);
}
- for (IProxyData data : datas) {
- config.setProxy(data.getHost(), data.getPort());
+ if (datas != null) {
+ for (IProxyData data : datas) {
+ config.setProxy(data.getHost(), data.getPort());
+ }
}
}
OseeLog.logf(Activator.class, Level.INFO, "Http-Request: [%s] [%s]", requests++, uri.toASCIIString());
@@ -163,7 +169,7 @@ public class HttpProcessor {
params.setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler(0, false));
method.setParams(params);
int responseCode = executeMethod(url, method);
- if (responseCode == HttpURLConnection.HTTP_NOT_FOUND) {
+ if (responseCode == HttpURLConnection.HTTP_NOT_FOUND || responseCode == HttpURLConnection.HTTP_ACCEPTED || responseCode == HttpURLConnection.HTTP_ACCEPTED || responseCode == HttpURLConnection.HTTP_OK) {
isAlive = true;
}
} finally {

Back to the top