Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDani Megert2012-03-01 08:43:38 +0000
committerDani Megert2012-03-01 08:43:38 +0000
commitf13d55d9b4ced505fbcc8816c64083e0c5ab4935 (patch)
tree85f65285afa93727a6f66ce2f9d4cceb71503525 /org.eclipse.help.webapp/src/org
parent17ad249386b7741f371ee21dea69c61b508535fa (diff)
downloadeclipse.platform.ua-f13d55d9b4ced505fbcc8816c64083e0c5ab4935.tar.gz
eclipse.platform.ua-f13d55d9b4ced505fbcc8816c64083e0c5ab4935.tar.xz
eclipse.platform.ua-f13d55d9b4ced505fbcc8816c64083e0c5ab4935.zip
Fixed potential null pointer accessv20120301-0843
Diffstat (limited to 'org.eclipse.help.webapp/src/org')
-rw-r--r--org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/WebappResources.java38
-rw-r--r--org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/PrintData.java9
-rw-r--r--org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/TopicFinder.java4
-rw-r--r--org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/UrlUtil.java15
4 files changed, 32 insertions, 34 deletions
diff --git a/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/WebappResources.java b/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/WebappResources.java
index 03bc9ffcd..0da3e8d45 100644
--- a/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/WebappResources.java
+++ b/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/WebappResources.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -21,9 +21,10 @@ import java.util.PropertyResourceBundle;
import java.util.ResourceBundle;
import java.util.StringTokenizer;
-import org.eclipse.core.runtime.Platform;
import org.osgi.framework.Bundle;
+import org.eclipse.core.runtime.Platform;
+
/**
* Uses a resource bundle to load images and strings from a property file in a
* documentation plugin
@@ -155,25 +156,24 @@ public class WebappResources {
ResourceBundle bundle;
Bundle hostBundle = Platform.getBundle(HelpWebappPlugin.getDefault()
.getBundle().getSymbolicName());
- if (null == hostBundle) {
- bundle = null;
- }
+ if (hostBundle == null)
+ return null;
+
URL url = hostBundle.getResource("org/eclipse/help/internal/webapp/WebappResources" + key + ".properties"); //$NON-NLS-1$//$NON-NLS-2$
- if (null == url) {
+ if (url == null)
+ return null;
+
+ InputStream in= null;
+ try {
+ in= url.openStream();
+ bundle= new PropertyResourceBundle(in);
+ } catch (IOException e) {
bundle = null;
- } else {
- InputStream in = null;
- try {
- in = url.openStream();
- bundle = new PropertyResourceBundle(in);
- } catch (IOException e) {
- bundle = null;
- } finally {
- if (null != in) {
- try {
- in.close();
- } catch (IOException e) {
- }
+ } finally {
+ if (in != null) {
+ try {
+ in.close();
+ } catch (IOException e) {
}
}
}
diff --git a/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/PrintData.java b/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/PrintData.java
index f1872f1a1..ee0a2ecfe 100644
--- a/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/PrintData.java
+++ b/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/PrintData.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2011 IBM Corporation and others.
+ * Copyright (c) 2007, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -406,10 +406,11 @@ public class PrintData extends RequestData {
try {
in.close();
}
- catch (Exception e) {}
+ catch (IOException e) {
+ }
try {
-
- rawInput.close();
+ if (rawInput != null)
+ rawInput.close();
}
catch (Exception e) {}
}
diff --git a/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/TopicFinder.java b/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/TopicFinder.java
index 1651fcc06..cd00d1509 100644
--- a/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/TopicFinder.java
+++ b/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/TopicFinder.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2010 IBM Corporation and others.
+ * Copyright (c) 2007, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -52,7 +52,7 @@ public class TopicFinder {
}
}
// if no match has been found, check if there is an anchor
- if (foundTopicPath == null && topicHref != null) {
+ if (foundTopicPath == null) {
index = topicHref.indexOf('#');
if (index != -1)
topicHref = topicHref.substring(0, index);
diff --git a/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/UrlUtil.java b/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/UrlUtil.java
index 36f512624..e4d8347d9 100644
--- a/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/UrlUtil.java
+++ b/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/UrlUtil.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -28,12 +28,13 @@ import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import org.eclipse.core.runtime.Platform;
import org.eclipse.help.internal.HelpPlugin;
import org.eclipse.help.internal.base.BaseHelpSystem;
import org.eclipse.help.internal.base.HelpBasePlugin;
import org.eclipse.help.internal.util.ProductPreferences;
+import org.eclipse.core.runtime.Platform;
+
public class UrlUtil {
// for Safari build 125.1 finds version 125
@@ -630,7 +631,7 @@ public class UrlUtil {
}
// locale strings as passed in command line or in preferences
- List infocenterLocales = null;
+ final List infocenterLocales= new ArrayList();
// first check if locales passed as command line arguments
String[] args = Platform.getCommandLineArgs();
@@ -638,7 +639,6 @@ public class UrlUtil {
for (int i = 0; i < args.length; i++) {
if ("-locales".equalsIgnoreCase(args[i])) { //$NON-NLS-1$
localeOption = true;
- infocenterLocales = new ArrayList();
continue;
} else if (args[i].startsWith("-")) { //$NON-NLS-1$
localeOption = false;
@@ -649,21 +649,18 @@ public class UrlUtil {
}
}
// if no locales from command line, get them from preferences
- if (infocenterLocales == null) {
+ if (infocenterLocales.isEmpty()) {
String preferredLocales = Platform.getPreferencesService().getString
(HelpBasePlugin.PLUGIN_ID, ("locales"), "", null); //$NON-NLS-1$ //$NON-NLS-2$
StringTokenizer tokenizer = new StringTokenizer(preferredLocales,
" ,\t"); //$NON-NLS-1$
while (tokenizer.hasMoreTokens()) {
- if (infocenterLocales == null) {
- infocenterLocales = new ArrayList();
- }
infocenterLocales.add(tokenizer.nextToken());
}
}
// format locales and collect in a set for lookup
- if (infocenterLocales != null) {
+ if (!infocenterLocales.isEmpty()) {
locales = new HashSet(10, 0.4f);
for (Iterator it = infocenterLocales.iterator(); it.hasNext();) {
String locale = (String) it.next();

Back to the top