-
Notifications
You must be signed in to change notification settings - Fork 701
Fix NPE when downloading registry resources from Carbon console #4567
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Tharsanan1
wants to merge
1
commit into
wso2:4.11.x
Choose a base branch
from
Tharsanan1:fix/issue-4848
base: 4.11.x
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+35
−23
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -48,9 +48,11 @@ | |||||||||||||||
| import java.util.Arrays; | ||||||||||||||||
| import java.util.Dictionary; | ||||||||||||||||
| import java.util.Enumeration; | ||||||||||||||||
| import java.util.HashMap; | ||||||||||||||||
| import java.util.Hashtable; | ||||||||||||||||
| import java.util.Iterator; | ||||||||||||||||
| import java.util.List; | ||||||||||||||||
| import java.util.Map; | ||||||||||||||||
|
|
||||||||||||||||
| import javax.servlet.Filter; | ||||||||||||||||
| import javax.servlet.Servlet; | ||||||||||||||||
|
|
@@ -67,6 +69,7 @@ public class UIBundleDeployer implements SynchronousBundleListener { | |||||||||||||||
| new BundleBasedUIResourceProvider(bundleResourcePath); | ||||||||||||||||
| //Used to hide the menus in the management console. | ||||||||||||||||
| private List<String> hideMenuIds = new ArrayList<>(); | ||||||||||||||||
| private Map<String, org.osgi.framework.ServiceRegistration<?>> servletRegistrations = new HashMap<>(); | ||||||||||||||||
|
|
||||||||||||||||
| public UIResourceProvider getBundleBasedUIResourcePrvider() { | ||||||||||||||||
| return bundleBasedUIResourceProvider; | ||||||||||||||||
|
|
@@ -290,34 +293,31 @@ private void processServletDefinitions(Component component, String action) throw | |||||||||||||||
| if (component != null | ||||||||||||||||
| && component.getServlets() != null | ||||||||||||||||
| && component.getServlets().length > 0) { | ||||||||||||||||
| HttpService httpService; | ||||||||||||||||
| try { | ||||||||||||||||
| httpService = CarbonUIServiceComponent.getHttpService(); | ||||||||||||||||
| } catch (Exception e) { | ||||||||||||||||
| throw new CarbonException("An instance of HttpService is not available"); | ||||||||||||||||
| } | ||||||||||||||||
| org.wso2.carbon.ui.deployment.beans.Servlet[] servletDefinitions = component.getServlets(); | ||||||||||||||||
| for (int a = 0; a < servletDefinitions.length; a++) { | ||||||||||||||||
| org.wso2.carbon.ui.deployment.beans.Servlet servlet = servletDefinitions[a]; | ||||||||||||||||
| if (CarbonConstants.ADD_UI_COMPONENT.equals(action)) { | ||||||||||||||||
| if (log.isTraceEnabled()) { | ||||||||||||||||
| log.trace("Registering sevlet : " + servlet); | ||||||||||||||||
| log.trace("Registering servlet : " + servlet); | ||||||||||||||||
| } | ||||||||||||||||
| try { | ||||||||||||||||
| Class clazz = Class.forName(servlet.getServletClass()); | ||||||||||||||||
| //TODO : allow servlet parameters to be passed | ||||||||||||||||
| Dictionary params = new Hashtable(); | ||||||||||||||||
| httpService.registerServlet(servlet.getUrlPatten(), | ||||||||||||||||
| (Servlet) clazz.newInstance(), params, | ||||||||||||||||
| httpContext); | ||||||||||||||||
| Servlet servletInstance = (Servlet) clazz.newInstance(); | ||||||||||||||||
| Dictionary<String, String> props = new Hashtable<>(); | ||||||||||||||||
| props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, | ||||||||||||||||
| servlet.getUrlPatten()); | ||||||||||||||||
| props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, | ||||||||||||||||
| "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME | ||||||||||||||||
| + "=carbonContext)"); | ||||||||||||||||
| props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_NAME, | ||||||||||||||||
| servlet.getName() != null ? servlet.getName() | ||||||||||||||||
| : servlet.getServletClass()); | ||||||||||||||||
| org.osgi.framework.ServiceRegistration<?> reg = | ||||||||||||||||
| bundleContext.registerService( | ||||||||||||||||
| Servlet.class.getName(), servletInstance, props); | ||||||||||||||||
| servletRegistrations.put(servlet.getUrlPatten(), reg); | ||||||||||||||||
| } catch (ClassNotFoundException e) { | ||||||||||||||||
| log.error("Servlet class : " + servlet.getServletClass() + " not found.", e); | ||||||||||||||||
| } catch (ServletException e) { | ||||||||||||||||
| log.error("Problem registering Servlet class : " + | ||||||||||||||||
| servlet.getServletClass() + ".", e); | ||||||||||||||||
| } catch (NamespaceException e) { | ||||||||||||||||
| log.error("Problem registering Servlet class : " + | ||||||||||||||||
| servlet.getServletClass() + ".", e); | ||||||||||||||||
| } catch (InstantiationException e) { | ||||||||||||||||
| log.error("Problem registering Servlet class : " + | ||||||||||||||||
| servlet.getServletClass() + ".", e); | ||||||||||||||||
|
|
@@ -327,15 +327,16 @@ private void processServletDefinitions(Component component, String action) throw | |||||||||||||||
| } | ||||||||||||||||
| } else if (CarbonConstants.REMOVE_UI_COMPONENT.equals(action)) { | ||||||||||||||||
| if (log.isTraceEnabled()) { | ||||||||||||||||
| log.trace("Unregistering sevlet : " + servlet); | ||||||||||||||||
| log.trace("Unregistering servlet : " + servlet); | ||||||||||||||||
| } | ||||||||||||||||
| org.osgi.framework.ServiceRegistration<?> reg = | ||||||||||||||||
| servletRegistrations.remove(servlet.getUrlPatten()); | ||||||||||||||||
| if (reg != null) { | ||||||||||||||||
| reg.unregister(); | ||||||||||||||||
| } | ||||||||||||||||
|
Comment on lines
+334
to
336
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Log Improvement Suggestion No: 2
Suggested change
|
||||||||||||||||
| httpService.unregister(servlet.getUrlPatten()); | ||||||||||||||||
| } | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
|
|
||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| private void processCustomRegistryDefinitions(Component component, String action) throws | ||||||||||||||||
|
|
||||||||||||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -839,6 +839,17 @@ private static String getServerURL(String url, ConfigurationContext configCtx) { | |||||||||||||||||
| String carbonMgtParam = "${carbon.management.port}"; | ||||||||||||||||||
| String mgtTransport = getManagementTransport(); | ||||||||||||||||||
| String returnUrl = url; | ||||||||||||||||||
| if (returnUrl == null) { | ||||||||||||||||||
| String httpsPort = | ||||||||||||||||||
| CarbonUtils.getTransportPort(configCtx, mgtTransport) + ""; | ||||||||||||||||||
|
Comment on lines
841
to
+844
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Log Improvement Suggestion No: 3
Suggested change
|
||||||||||||||||||
| String host = System.getProperty(ServerConstants.LOCAL_IP_ADDRESS, "localhost"); | ||||||||||||||||||
| String context = ServerConfiguration.getInstance().getFirstProperty("WebContextRoot"); | ||||||||||||||||||
| if (context == null || context.equals("/")) { | ||||||||||||||||||
| context = ""; | ||||||||||||||||||
| } | ||||||||||||||||||
| returnUrl = mgtTransport + "://" + host + ":" + httpsPort + context + "/services/"; | ||||||||||||||||||
| return returnUrl; | ||||||||||||||||||
| } | ||||||||||||||||||
|
Comment on lines
+849
to
+852
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Log Improvement Suggestion No: 4
Suggested change
|
||||||||||||||||||
| if (returnUrl.indexOf(carbonMgtParam) != -1) { | ||||||||||||||||||
| String httpsPort = | ||||||||||||||||||
| CarbonUtils.getTransportPort(configCtx, mgtTransport) + ""; | ||||||||||||||||||
|
|
||||||||||||||||||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Log Improvement Suggestion No: 1