This is an automated email from the ASF dual-hosted git repository.
krisden pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/knox.git
The following commit(s) were added to refs/heads/master by this push:
new 1d19a80 Cleanup SonarQube warnings from recent commits
1d19a80 is described below
commit 1d19a804ebc7b50c948ce97fa2106b46b2c2aff5
Author: Kevin Risden <[email protected]>
AuthorDate: Fri Jan 11 13:45:42 2019 -0500
Cleanup SonarQube warnings from recent commits
* Remove unnecessary initializers
* Fix order of variables/methods to match Java style
Signed-off-by: Kevin Risden <[email protected]>
---
.../security/ldap/SimpleDirectoryService.java | 5 +-
.../dispatch/AtlasApiTrustedProxyHaDispatch.java | 49 +++++--------
.../ha/dispatch/AtlasTrustedProxyHaDispatch.java | 82 +++++++++-------------
.../org/apache/knox/gateway/GatewayServlet.java | 4 +-
.../gateway/config/impl/GatewayConfigImpl.java | 13 +---
.../knox/gateway/deploy/DeploymentFactory.java | 24 +++----
.../impl/ApplicationDeploymentContributor.java | 16 ++---
.../topology/impl/DefaultTopologyService.java | 26 +++----
.../simple/ProviderConfigurationParser.java | 16 ++---
.../gateway/util/ServiceDefinitionsLoader.java | 12 ++--
.../knox/gateway/service/admin/AliasResource.java | 17 +++--
.../gateway/service/definition/CustomDispatch.java | 12 ++--
.../gateway/service/knoxtoken/TokenResource.java | 6 +-
.../org/apache/knox/gateway/shell/KnoxSession.java | 32 ++++-----
14 files changed, 138 insertions(+), 176 deletions(-)
diff --git
a/gateway-demo-ldap/src/main/java/org/apache/knox/gateway/security/ldap/SimpleDirectoryService.java
b/gateway-demo-ldap/src/main/java/org/apache/knox/gateway/security/ldap/SimpleDirectoryService.java
index 8b61003..0c6948c 100644
---
a/gateway-demo-ldap/src/main/java/org/apache/knox/gateway/security/ldap/SimpleDirectoryService.java
+++
b/gateway-demo-ldap/src/main/java/org/apache/knox/gateway/security/ldap/SimpleDirectoryService.java
@@ -22,13 +22,12 @@ import
org.apache.directory.server.core.DefaultDirectoryService;
public class SimpleDirectoryService extends DefaultDirectoryService {
- public SimpleDirectoryService() throws Exception {
+ public SimpleDirectoryService() throws LdapException {
super();
}
@Override
- protected void showSecurityWarnings() throws LdapException {
+ protected void showSecurityWarnings() {
// NoOp - This prevents confusing warnings from being output.
}
-
}
diff --git
a/gateway-provider-ha/src/main/java/org/apache/knox/gateway/ha/dispatch/AtlasApiTrustedProxyHaDispatch.java
b/gateway-provider-ha/src/main/java/org/apache/knox/gateway/ha/dispatch/AtlasApiTrustedProxyHaDispatch.java
index b3d3e42..fdf4b91 100644
---
a/gateway-provider-ha/src/main/java/org/apache/knox/gateway/ha/dispatch/AtlasApiTrustedProxyHaDispatch.java
+++
b/gateway-provider-ha/src/main/java/org/apache/knox/gateway/ha/dispatch/AtlasApiTrustedProxyHaDispatch.java
@@ -15,7 +15,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.apache.knox.gateway.ha.dispatch;
import org.apache.http.Header;
@@ -26,40 +25,30 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
-
public class AtlasApiTrustedProxyHaDispatch extends DefaultHaDispatch {
+ public AtlasApiTrustedProxyHaDispatch() {
+ setServiceRole("ATLAS-API");
+ }
+ @Override
+ protected void executeRequest(HttpUriRequest outboundRequest,
HttpServletRequest inboundRequest, HttpServletResponse outboundResponse) throws
IOException {
+ HttpResponse inboundResponse = null;
+ try {
+ inboundResponse = executeOutboundRequest(outboundRequest);
+ int statusCode = inboundResponse.getStatusLine().getStatusCode();
+ Header originalLocationHeader =
inboundResponse.getFirstHeader("Location");
- public AtlasApiTrustedProxyHaDispatch() {
- setServiceRole("ATLAS-API");
- }
-
- @Override
- public void init() {
- super.init();
- }
+ if ((statusCode == HttpServletResponse.SC_MOVED_TEMPORARILY ||
statusCode == HttpServletResponse.SC_TEMPORARY_REDIRECT) &&
originalLocationHeader != null) {
+ inboundResponse.removeHeaders("Location");
+ failoverRequest(outboundRequest, inboundRequest, outboundResponse,
inboundResponse, new Exception("Atlas HA redirection"));
+ }
- @Override
- protected void executeRequest(HttpUriRequest outboundRequest,
HttpServletRequest inboundRequest, HttpServletResponse outboundResponse) throws
IOException {
- HttpResponse inboundResponse = null;
- try {
- inboundResponse = executeOutboundRequest(outboundRequest);
- int statusCode = inboundResponse.getStatusLine().getStatusCode();
- Header originalLocationHeader =
inboundResponse.getFirstHeader("Location");
+ writeOutboundResponse(outboundRequest, inboundRequest, outboundResponse,
inboundResponse);
-
- if ((statusCode == HttpServletResponse.SC_MOVED_TEMPORARILY ||
statusCode == HttpServletResponse.SC_TEMPORARY_REDIRECT) &&
originalLocationHeader != null) {
- inboundResponse.removeHeaders("Location");
- failoverRequest(outboundRequest, inboundRequest,
outboundResponse, inboundResponse, new Exception("Atlas HA redirection"));
- }
-
- writeOutboundResponse(outboundRequest, inboundRequest,
outboundResponse, inboundResponse);
-
- } catch (IOException e) {
- LOG.errorConnectingToServer(outboundRequest.getURI().toString(),
e);
- failoverRequest(outboundRequest, inboundRequest, outboundResponse,
inboundResponse, e);
- }
+ } catch (IOException e) {
+ LOG.errorConnectingToServer(outboundRequest.getURI().toString(), e);
+ failoverRequest(outboundRequest, inboundRequest, outboundResponse,
inboundResponse, e);
}
-
+ }
}
diff --git
a/gateway-provider-ha/src/main/java/org/apache/knox/gateway/ha/dispatch/AtlasTrustedProxyHaDispatch.java
b/gateway-provider-ha/src/main/java/org/apache/knox/gateway/ha/dispatch/AtlasTrustedProxyHaDispatch.java
index 0a38e5e..9ea3be1 100644
---
a/gateway-provider-ha/src/main/java/org/apache/knox/gateway/ha/dispatch/AtlasTrustedProxyHaDispatch.java
+++
b/gateway-provider-ha/src/main/java/org/apache/knox/gateway/ha/dispatch/AtlasTrustedProxyHaDispatch.java
@@ -15,7 +15,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.apache.knox.gateway.ha.dispatch;
import org.apache.http.Header;
@@ -25,61 +24,46 @@ import org.apache.http.client.methods.HttpUriRequest;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
-import java.util.HashSet;
-import java.util.Set;
public class AtlasTrustedProxyHaDispatch extends DefaultHaDispatch {
- private static Set<String> REQUEST_EXCLUDE_HEADERS = new HashSet<>();
-
- static {
- REQUEST_EXCLUDE_HEADERS.add("Content-Length");
- }
-
- public AtlasTrustedProxyHaDispatch() {
- setServiceRole("ATLAS");
- }
-
- @Override
- public void init() {
- super.init();
- }
-
+ public AtlasTrustedProxyHaDispatch() {
+ setServiceRole("ATLAS");
+ }
- @Override
- protected void executeRequest(HttpUriRequest outboundRequest,
- HttpServletRequest inboundRequest,
- HttpServletResponse outboundResponse) throws
IOException {
- HttpResponse inboundResponse = null;
- try {
- inboundResponse = executeOutboundRequest(outboundRequest);
+ @Override
+ protected void executeRequest(HttpUriRequest outboundRequest,
+ HttpServletRequest inboundRequest,
+ HttpServletResponse outboundResponse) throws
IOException {
+ HttpResponse inboundResponse = null;
+ try {
+ inboundResponse = executeOutboundRequest(outboundRequest);
- int sc = inboundResponse.getStatusLine().getStatusCode();
- if (sc == HttpServletResponse.SC_MOVED_TEMPORARILY || sc ==
HttpServletResponse.SC_TEMPORARY_REDIRECT) {
- if
(!isLoginRedirect(inboundResponse.getFirstHeader("Location"))) {
- inboundResponse.removeHeaders("Location");
- failoverRequest(outboundRequest,
- inboundRequest,
- outboundResponse,
- inboundResponse,
- new Exception("Atlas HA redirection"));
- }
- }
+ int sc = inboundResponse.getStatusLine().getStatusCode();
+ if (sc == HttpServletResponse.SC_MOVED_TEMPORARILY || sc ==
HttpServletResponse.SC_TEMPORARY_REDIRECT) {
+ if (!isLoginRedirect(inboundResponse.getFirstHeader("Location"))) {
+ inboundResponse.removeHeaders("Location");
+ failoverRequest(outboundRequest,
+ inboundRequest,
+ outboundResponse,
+ inboundResponse,
+ new Exception("Atlas HA redirection"));
+ }
+ }
- writeOutboundResponse(outboundRequest, inboundRequest,
outboundResponse, inboundResponse);
+ writeOutboundResponse(outboundRequest, inboundRequest, outboundResponse,
inboundResponse);
- } catch (IOException e) {
- LOG.errorConnectingToServer(outboundRequest.getURI().toString(),
e);
- failoverRequest(outboundRequest, inboundRequest, outboundResponse,
inboundResponse, e);
- }
+ } catch (IOException e) {
+ LOG.errorConnectingToServer(outboundRequest.getURI().toString(), e);
+ failoverRequest(outboundRequest, inboundRequest, outboundResponse,
inboundResponse, e);
}
+ }
- private boolean isLoginRedirect(Header locationHeader) {
- boolean result = false;
- if (locationHeader != null) {
- String value = locationHeader.getValue();
- result = (value.endsWith("login.jsp") ||
value.contains("originalUrl"));
- }
- return result;
+ private boolean isLoginRedirect(Header locationHeader) {
+ boolean result = false;
+ if (locationHeader != null) {
+ String value = locationHeader.getValue();
+ result = (value.endsWith("login.jsp") || value.contains("originalUrl"));
}
-
+ return result;
+ }
}
diff --git
a/gateway-server/src/main/java/org/apache/knox/gateway/GatewayServlet.java
b/gateway-server/src/main/java/org/apache/knox/gateway/GatewayServlet.java
index dcfe6ce..548dc8c 100644
--- a/gateway-server/src/main/java/org/apache/knox/gateway/GatewayServlet.java
+++ b/gateway-server/src/main/java/org/apache/knox/gateway/GatewayServlet.java
@@ -51,7 +51,6 @@ import java.nio.charset.StandardCharsets;
import java.util.Enumeration;
public class GatewayServlet implements Servlet, Filter {
-
public static final String GATEWAY_DESCRIPTOR_LOCATION_DEFAULT =
"gateway.xml";
public static final String GATEWAY_DESCRIPTOR_LOCATION_PARAM =
"gatewayDescriptorLocation";
@@ -85,7 +84,7 @@ public class GatewayServlet implements Servlet, Filter {
}
this.filter = filter;
if( filter != null && filterConfig != null ) {
- ((Filter) filter).destroy();
+ filter.destroy();
}
}
@@ -283,5 +282,4 @@ public class GatewayServlet implements Servlet, Filter {
return config.getInitParameterNames();
}
}
-
}
diff --git
a/gateway-server/src/main/java/org/apache/knox/gateway/config/impl/GatewayConfigImpl.java
b/gateway-server/src/main/java/org/apache/knox/gateway/config/impl/GatewayConfigImpl.java
index 35f872a..5060831 100644
---
a/gateway-server/src/main/java/org/apache/knox/gateway/config/impl/GatewayConfigImpl.java
+++
b/gateway-server/src/main/java/org/apache/knox/gateway/config/impl/GatewayConfigImpl.java
@@ -75,7 +75,6 @@ import java.util.concurrent.TimeUnit;
* name of the directory containing cluster topologies. This value default to
"clusters".
*/
public class GatewayConfigImpl extends Configuration implements GatewayConfig {
-
private static final String GATEWAY_DEFAULT_TOPOLOGY_NAME_PARAM =
"default.app.topology.name";
private static final String GATEWAY_DEFAULT_TOPOLOGY_NAME = null;
@@ -228,7 +227,9 @@ public class GatewayConfigImpl extends Configuration
implements GatewayConfig {
static final String DISPATCH_HOST_WHITELIST =
GATEWAY_CONFIG_FILE_PREFIX + ".dispatch.whitelist";
static final String DISPATCH_HOST_WHITELIST_SERVICES =
DISPATCH_HOST_WHITELIST + ".services";
- private List<String> DEFAULT_GLOBAL_RULES_SERVICES;
+ private static final List<String> DEFAULT_GLOBAL_RULES_SERVICES =
Arrays.asList(
+ "NAMENODE", "JOBTRACKER", "WEBHDFS", "WEBHCAT",
+ "OOZIE", "WEBHBASE", "HIVE", "RESOURCEMANAGER");
public GatewayConfigImpl() {
init();
@@ -300,8 +301,6 @@ public class GatewayConfigImpl extends Configuration
implements GatewayConfig {
for( String fileName : GATEWAY_CONFIG_FILENAMES ) {
lastFileUrl = loadConfig( fileName, lastFileUrl );
}
- //set default services list
- setDefaultGlobalRulesServices();
initGatewayHomeDir( lastFileUrl );
@@ -309,12 +308,6 @@ public class GatewayConfigImpl extends Configuration
implements GatewayConfig {
log.cookieScopingFeatureEnabled(isCookieScopingToPathEnabled());
}
- private void setDefaultGlobalRulesServices() {
- DEFAULT_GLOBAL_RULES_SERVICES = Arrays.asList(
- "NAMENODE", "JOBTRACKER", "WEBHDFS", "WEBHCAT",
- "OOZIE", "WEBHBASE", "HIVE", "RESOURCEMANAGER");
- }
-
private void initGatewayHomeDir( URL lastFileUrl ) {
String home = System.getProperty( GATEWAY_HOME_VAR );
if( home != null ) {
diff --git
a/gateway-server/src/main/java/org/apache/knox/gateway/deploy/DeploymentFactory.java
b/gateway-server/src/main/java/org/apache/knox/gateway/deploy/DeploymentFactory.java
index 7caf054..72c3b13 100644
---
a/gateway-server/src/main/java/org/apache/knox/gateway/deploy/DeploymentFactory.java
+++
b/gateway-server/src/main/java/org/apache/knox/gateway/deploy/DeploymentFactory.java
@@ -67,18 +67,6 @@ import java.util.TreeMap;
public abstract class DeploymentFactory {
private static final JAXBContext jaxbContext = getJAXBContext();
- private static JAXBContext getJAXBContext() {
- Map<String,String> properties = new HashMap<>(2);
- properties.put( "eclipselink-oxm-xml",
"org/apache/knox/gateway/topology/topology_binding-xml.xml");
- properties.put( "eclipselink.media-type", "application/xml" );
-
- try {
- return JAXBContext.newInstance(Topology.class.getPackage().getName(),
Topology.class.getClassLoader(), properties);
- } catch (JAXBException e) {
- throw new IllegalStateException(e);
- }
- }
-
private static final String SERVLET_NAME_SUFFIX = "-knox-gateway-servlet";
private static final String FILTER_NAME_SUFFIX = "-knox-gateway-filter";
private static final GatewayMessages log = MessagesFactory.get(
GatewayMessages.class );
@@ -95,6 +83,18 @@ public abstract class DeploymentFactory {
loadProviderContributors();
}
+ private static JAXBContext getJAXBContext() {
+ Map<String,String> properties = new HashMap<>(2);
+ properties.put( "eclipselink-oxm-xml",
"org/apache/knox/gateway/topology/topology_binding-xml.xml");
+ properties.put( "eclipselink.media-type", "application/xml" );
+
+ try {
+ return JAXBContext.newInstance(Topology.class.getPackage().getName(),
Topology.class.getClassLoader(), properties);
+ } catch (JAXBException e) {
+ throw new IllegalStateException(e);
+ }
+ }
+
public static void setGatewayServices(GatewayServices services) {
DeploymentFactory.gatewayServices = services;
}
diff --git
a/gateway-server/src/main/java/org/apache/knox/gateway/deploy/impl/ApplicationDeploymentContributor.java
b/gateway-server/src/main/java/org/apache/knox/gateway/deploy/impl/ApplicationDeploymentContributor.java
index b4d065d..f8e3114 100644
---
a/gateway-server/src/main/java/org/apache/knox/gateway/deploy/impl/ApplicationDeploymentContributor.java
+++
b/gateway-server/src/main/java/org/apache/knox/gateway/deploy/impl/ApplicationDeploymentContributor.java
@@ -58,14 +58,6 @@ import java.util.Map;
public class ApplicationDeploymentContributor extends
ServiceDeploymentContributorBase {
private static final JAXBContext jaxbContext = getJAXBContext();
- private static JAXBContext getJAXBContext() {
- try {
- return JAXBContext.newInstance( ServiceDefinition.class );
- } catch (JAXBException e) {
- throw new IllegalStateException(e);
- }
- }
-
private static final String SERVICE_DEFINITION_FILE_NAME = "service.xml";
private static final String REWRITE_RULES_FILE_NAME = "rewrite.xml";
private static final String XFORWARDED_FILTER_NAME =
"XForwardedHeaderFilter";
@@ -77,6 +69,14 @@ public class ApplicationDeploymentContributor extends
ServiceDeploymentContribut
private UrlRewriteRulesDescriptor serviceRules;
+ private static JAXBContext getJAXBContext() {
+ try {
+ return JAXBContext.newInstance( ServiceDefinition.class );
+ } catch (JAXBException e) {
+ throw new IllegalStateException(e);
+ }
+ }
+
private static ServiceDefinition loadServiceDefinition( Application
application, File file ) throws JAXBException, FileNotFoundException,
IOException {
ServiceDefinition definition;
if( !file.exists() ) {
diff --git
a/gateway-server/src/main/java/org/apache/knox/gateway/services/topology/impl/DefaultTopologyService.java
b/gateway-server/src/main/java/org/apache/knox/gateway/services/topology/impl/DefaultTopologyService.java
index d92ed38..f1612fe 100644
---
a/gateway-server/src/main/java/org/apache/knox/gateway/services/topology/impl/DefaultTopologyService.java
+++
b/gateway-server/src/main/java/org/apache/knox/gateway/services/topology/impl/DefaultTopologyService.java
@@ -90,19 +90,6 @@ public class DefaultTopologyService
private static final JAXBContext jaxbContext = getJAXBContext();
- private static JAXBContext getJAXBContext() {
- String pkgName = Topology.class.getPackage().getName();
- String bindingFile = pkgName.replace(".", "/") +
"/topology_binding-xml.xml";
-
- Map<String, Object> properties = new HashMap<>(1);
- properties.put(JAXBContextProperties.OXM_METADATA_SOURCE, bindingFile);
- try {
- return JAXBContext.newInstance(pkgName, Topology.class.getClassLoader(),
properties);
- } catch (JAXBException e) {
- throw new IllegalStateException(e);
- }
- }
-
private static Auditor auditor =
AuditServiceFactory.getAuditService().getAuditor(
AuditConstants.DEFAULT_AUDITOR_NAME, AuditConstants.KNOX_SERVICE_NAME,
AuditConstants.KNOX_COMPONENT_NAME);
@@ -130,6 +117,19 @@ public class DefaultTopologyService
private GatewayConfig config;
+ private static JAXBContext getJAXBContext() {
+ String pkgName = Topology.class.getPackage().getName();
+ String bindingFile = pkgName.replace(".", "/") +
"/topology_binding-xml.xml";
+
+ Map<String, Object> properties = new HashMap<>(1);
+ properties.put(JAXBContextProperties.OXM_METADATA_SOURCE, bindingFile);
+ try {
+ return JAXBContext.newInstance(pkgName, Topology.class.getClassLoader(),
properties);
+ } catch (JAXBException e) {
+ throw new IllegalStateException(e);
+ }
+ }
+
private Topology loadTopology(File file) throws IOException, SAXException,
URISyntaxException, InterruptedException {
final long TIMEOUT = 250; //ms
final long DELAY = 50; //ms
diff --git
a/gateway-server/src/main/java/org/apache/knox/gateway/topology/simple/ProviderConfigurationParser.java
b/gateway-server/src/main/java/org/apache/knox/gateway/topology/simple/ProviderConfigurationParser.java
index 26ce59b..73b707c 100644
---
a/gateway-server/src/main/java/org/apache/knox/gateway/topology/simple/ProviderConfigurationParser.java
+++
b/gateway-server/src/main/java/org/apache/knox/gateway/topology/simple/ProviderConfigurationParser.java
@@ -40,17 +40,8 @@ import java.util.List;
import java.util.Map;
public class ProviderConfigurationParser {
-
private static final JAXBContext jaxbContext = getJAXBContext();
- private static JAXBContext getJAXBContext() {
- try {
- return JAXBContext.newInstance(XMLProviderConfiguration.class);
- } catch (JAXBException e) {
- throw new IllegalStateException(e);
- }
- }
-
private static final String EXT_XML = "xml";
private static final String EXT_JSON = "json";
private static final String EXT_YML = "yml";
@@ -58,6 +49,13 @@ public class ProviderConfigurationParser {
public static final List<String> SUPPORTED_EXTENSIONS =
Collections.unmodifiableList(Arrays.asList(EXT_XML, EXT_JSON, EXT_YML,
EXT_YAML));
+ private static JAXBContext getJAXBContext() {
+ try {
+ return JAXBContext.newInstance(XMLProviderConfiguration.class);
+ } catch (JAXBException e) {
+ throw new IllegalStateException(e);
+ }
+ }
public static ProviderConfiguration parse(String path) throws Exception {
return parse(new File(path));
diff --git
a/gateway-server/src/main/java/org/apache/knox/gateway/util/ServiceDefinitionsLoader.java
b/gateway-server/src/main/java/org/apache/knox/gateway/util/ServiceDefinitionsLoader.java
index a4a2ca4..c26e654 100644
---
a/gateway-server/src/main/java/org/apache/knox/gateway/util/ServiceDefinitionsLoader.java
+++
b/gateway-server/src/main/java/org/apache/knox/gateway/util/ServiceDefinitionsLoader.java
@@ -46,6 +46,12 @@ import java.util.Set;
public class ServiceDefinitionsLoader {
private static final JAXBContext jaxbContext = getJAXBContext();
+ private static final GatewayMessages log =
MessagesFactory.get(GatewayMessages.class);
+
+ private static final String SERVICE_FILE_NAME = "service";
+
+ private static final String REWRITE_FILE = "rewrite.xml";
+
private static JAXBContext getJAXBContext() {
try {
return JAXBContext.newInstance(ServiceDefinition.class);
@@ -54,12 +60,6 @@ public class ServiceDefinitionsLoader {
}
}
- private static final GatewayMessages log =
MessagesFactory.get(GatewayMessages.class);
-
- private static final String SERVICE_FILE_NAME = "service";
-
- private static final String REWRITE_FILE = "rewrite.xml";
-
public static Set<ServiceDeploymentContributor> loadServiceDefinitions(File
servicesDir) {
Set<ServiceDeploymentContributor> contributors = new HashSet<>();
if ( servicesDir.exists() && servicesDir.isDirectory() ) {
diff --git
a/gateway-service-admin/src/main/java/org/apache/knox/gateway/service/admin/AliasResource.java
b/gateway-service-admin/src/main/java/org/apache/knox/gateway/service/admin/AliasResource.java
index b4113cd..de9f9db 100644
---
a/gateway-service-admin/src/main/java/org/apache/knox/gateway/service/admin/AliasResource.java
+++
b/gateway-service-admin/src/main/java/org/apache/knox/gateway/service/admin/AliasResource.java
@@ -51,7 +51,6 @@ import static javax.ws.rs.core.Response.status;
*/
@Path("/api/v1")
public class AliasResource {
-
private static final String ALIASES_API_PATH = "aliases";
private static final String ALIASES_TOPOLOGY_API_PATH =
ALIASES_API_PATH + "/{topology}";
@@ -72,8 +71,8 @@ public class AliasResource {
@Produces({ APPLICATION_JSON })
@Consumes({ APPLICATION_XML, APPLICATION_JSON, TEXT_PLAIN })
@Path(ALIAS_API_PATH)
- public Response putAlias(final @PathParam("topology") String topology,
- final @PathParam("alias") String alias, final String value) {
+ public Response putAlias(@PathParam("topology") final String topology,
+ @PathParam("alias") final String alias, final String value) {
return postAlias(topology, alias, value);
}
@@ -88,9 +87,9 @@ public class AliasResource {
@Produces({ APPLICATION_JSON })
@Consumes(APPLICATION_FORM_URLENCODED)
@Path(ALIAS_API_PATH)
- public Response postAlias(final @PathParam("topology") String topology,
- final @PathParam("alias") String alias,
- final @FormParam("value") String value) {
+ public Response postAlias(@PathParam("topology") final String topology,
+ @PathParam("alias") final String alias,
+ @FormParam("value") final String value) {
if (value == null || value.isEmpty()) {
return status(BAD_REQUEST).
@@ -125,8 +124,8 @@ public class AliasResource {
@DELETE
@Produces({ APPLICATION_JSON })
@Path(ALIAS_API_PATH)
- public Response deleteAlias(final @PathParam("topology") String topology,
- final @PathParam("alias") String alias) {
+ public Response deleteAlias(@PathParam("topology") final String topology,
+ @PathParam("alias") final String alias) {
final AliasService as = getAliasService();
@@ -155,7 +154,7 @@ public class AliasResource {
@GET
@Produces({ APPLICATION_JSON })
@Path(ALIASES_TOPOLOGY_API_PATH)
- public Response getAliases(final @PathParam("topology") String topology) {
+ public Response getAliases(@PathParam("topology") final String topology) {
final ObjectMapper mapper = new ObjectMapper();
final AliasService as = getAliasService();
diff --git
a/gateway-service-definitions/src/main/java/org/apache/knox/gateway/service/definition/CustomDispatch.java
b/gateway-service-definitions/src/main/java/org/apache/knox/gateway/service/definition/CustomDispatch.java
index bad7879..bc1735a 100644
---
a/gateway-service-definitions/src/main/java/org/apache/knox/gateway/service/definition/CustomDispatch.java
+++
b/gateway-service-definitions/src/main/java/org/apache/knox/gateway/service/definition/CustomDispatch.java
@@ -120,6 +120,13 @@ public class CustomDispatch {
@XmlAccessorType(XmlAccessType.NONE)
private static class XMLParam {
+ @XmlElement
+ private String name;
+
+ @XmlElement
+ private String value;
+
+ @SuppressWarnings("unused")
XMLParam() {
}
@@ -128,11 +135,6 @@ public class CustomDispatch {
this.name = name;
this.value = value;
}
- @XmlElement
- private String name;
-
- @XmlElement
- private String value;
String getName() {
return name;
diff --git
a/gateway-service-knoxtoken/src/main/java/org/apache/knox/gateway/service/knoxtoken/TokenResource.java
b/gateway-service-knoxtoken/src/main/java/org/apache/knox/gateway/service/knoxtoken/TokenResource.java
index 0da2def..c9362f5 100644
---
a/gateway-service-knoxtoken/src/main/java/org/apache/knox/gateway/service/knoxtoken/TokenResource.java
+++
b/gateway-service-knoxtoken/src/main/java/org/apache/knox/gateway/service/knoxtoken/TokenResource.java
@@ -174,7 +174,7 @@ public class TokenResource {
.getAttribute(GatewayServices.GATEWAY_SERVICES_ATTRIBUTE);
JWTokenAuthority ts = services.getService(GatewayServices.TOKEN_SERVICE);
- Principal p = ((HttpServletRequest) request).getUserPrincipal();
+ Principal p = request.getUserPrincipal();
long expires = getExpiry();
if (endpointPublicCert == null) {
@@ -194,7 +194,7 @@ public class TokenResource {
}
try {
- JWT token = null;
+ JWT token;
if (targetAudiences.isEmpty()) {
token = ts.issueToken(p, signatureAlgorithm, expires);
} else {
@@ -242,7 +242,7 @@ public class TokenResource {
}
private long getExpiry() {
- long expiry = 0L;
+ long expiry;
if (tokenTTL == -1) {
expiry = -1;
} else {
diff --git
a/gateway-shell/src/main/java/org/apache/knox/gateway/shell/KnoxSession.java
b/gateway-shell/src/main/java/org/apache/knox/gateway/shell/KnoxSession.java
index da7036a..f2d57e8 100644
--- a/gateway-shell/src/main/java/org/apache/knox/gateway/shell/KnoxSession.java
+++ b/gateway-shell/src/main/java/org/apache/knox/gateway/shell/KnoxSession.java
@@ -119,6 +119,20 @@ public class KnoxSession implements Closeable {
this.headers = headers;
}
+ protected KnoxSession() throws KnoxShellException, URISyntaxException {
+ }
+
+ public KnoxSession( final ClientContext clientContext) throws
KnoxShellException, URISyntaxException {
+ this.executor = Executors.newCachedThreadPool();
+ this.base = clientContext.url();
+
+ try {
+ client = createClient(clientContext);
+ } catch (GeneralSecurityException e) {
+ throw new KnoxShellException("Failed to create HTTP client.", e);
+ }
+ }
+
public static KnoxSession login( String url, Map<String,String> headers )
throws URISyntaxException {
KnoxSession instance = new KnoxSession(ClientContext.with(url));
instance.setHeaders(headers);
@@ -197,20 +211,6 @@ public class KnoxSession implements Closeable {
.connection().secure(false).end());
}
- protected KnoxSession() throws KnoxShellException, URISyntaxException {
- }
-
- public KnoxSession( final ClientContext clientContext) throws
KnoxShellException, URISyntaxException {
- this.executor = Executors.newCachedThreadPool();
- this.base = clientContext.url();
-
- try {
- client = createClient(clientContext);
- } catch (GeneralSecurityException e) {
- throw new KnoxShellException("Failed to create HTTP client.", e);
- }
- }
-
protected CloseableHttpClient createClient(ClientContext clientContext)
throws GeneralSecurityException {
// SSL
@@ -410,8 +410,8 @@ public class KnoxSession implements Closeable {
}
protected void discoverTruststoreDetails(ClientContext clientContext) {
- String truststoreDir = null;
- String truststoreFileName = null;
+ String truststoreDir;
+ String truststoreFileName;
if (clientContext.connection().truststoreLocation() != null &&
clientContext.connection().truststorePass() != null) {
return;