[
https://issues.apache.org/jira/browse/KNOX-2809?focusedWorklogId=836415&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-836415
]
ASF GitHub Bot logged work on KNOX-2809:
----------------------------------------
Author: ASF GitHub Bot
Created on: 02/Jan/23 16:05
Start Date: 02/Jan/23 16:05
Worklog Time Spent: 10m
Work Description: smolnar82 commented on code in PR #638:
URL: https://github.com/apache/knox/pull/638#discussion_r1060110657
##########
gateway-spi/src/main/java/org/apache/knox/gateway/util/URLUtils.java:
##########
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
under
+ * the License.
+ */
+package org.apache.knox.gateway.util;
+
+import java.net.URI;
+import java.net.URLDecoder;
+import java.nio.charset.StandardCharsets;
+
+public class URLUtils {
+
+ /**
+ * A method that decode url and concat query params, return result as URI.
+ *
+ * @param encoded encoded url
+ * @param queryStr query params
+ * @return decoded URI
+ */
+ public static URI getDecodeUri(String encoded, String queryStr) {
+ String decoded;
+ try {
+ decoded = URLDecoder.decode(encoded, StandardCharsets.UTF_8.name());
+ } catch (final Exception e) {
+ /* fall back in case of exception */
+ decoded = encoded;
+ }
+
+ final StringBuilder str = new StringBuilder(decoded);
+ if (queryStr != null) {
Review Comment:
You may want to check for being `not blank` here
(`StringUtils.isNotBlank(queryStr)`). Even if this is not null, it may be a
blank string that makes no sense to append at the end of the decoded URI.
##########
gateway-spi/src/test/java/org/apache/knox/gateway/util/URLUtilsTest.java:
##########
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
under
+ * the License.
+ */
+package org.apache.knox.gateway.util;
+
+import org.junit.Test;
+
+import java.net.URI;
+
+import static org.junit.Assert.assertEquals;
+
+public class URLUtilsTest {
Review Comment:
Please add other test cases with null and empty query strings.
##########
gateway-spi/src/main/java/org/apache/knox/gateway/util/URLUtils.java:
##########
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
under
+ * the License.
+ */
+package org.apache.knox.gateway.util;
+
+import java.net.URI;
+import java.net.URLDecoder;
+import java.nio.charset.StandardCharsets;
+
+public class URLUtils {
+
+ /**
+ * A method that decode url and concat query params, return result as URI.
+ *
+ * @param encoded encoded url
+ * @param queryStr query params
+ * @return decoded URI
+ */
+ public static URI getDecodeUri(String encoded, String queryStr) {
Review Comment:
nit: I think there is a typo here; it should be `getDecodedUri` (note the
`d` at the end of `Decoded`)or the method name should be changed to a verb:
`decodeUri`
Issue Time Tracking
-------------------
Worklog Id: (was: 836415)
Time Spent: 1h 20m (was: 1h 10m)
> HDFSUI is not high available
> ----------------------------
>
> Key: KNOX-2809
> URL: https://issues.apache.org/jira/browse/KNOX-2809
> Project: Apache Knox
> Issue Type: Bug
> Components: Server
> Affects Versions: 1.5.0, 1.6.0
> Reporter: Chang Zhichao
> Priority: Major
> Fix For: 1.6.0
>
> Time Spent: 1h 20m
> Remaining Estimate: 0h
>
> HDFSUI use org.apache.knox.gateway.dispatch.URLDecodingDispatch for request,
> it didn't do failoverRequest when executeRequest failed.
> Â
--
This message was sent by Atlassian Jira
(v8.20.10#820010)