Commit 4dc95339 by nixonrodrigues

ATLAS-2310:- Fix URL encoding incase of HA in passive node which caused wrong…

ATLAS-2310:- Fix URL encoding incase of HA in passive node which caused wrong redirection url. (bpgergo via nixonrodrigues).
parent 7f7af565
......@@ -23,6 +23,7 @@ import org.apache.atlas.web.service.ServiceState;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.util.UriUtils;
import javax.inject.Inject;
import javax.servlet.Filter;
......@@ -36,7 +37,6 @@ import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.HttpMethod;
import javax.ws.rs.core.HttpHeaders;
import java.io.IOException;
import java.net.URLEncoder;
/**
* A servlet {@link Filter} that redirects web requests from a passive Atlas server instance to an active one.
......@@ -129,7 +129,7 @@ public class ActiveServerFilter implements Filter {
String queryString = servletRequest.getQueryString();
if (queryString != null && (!queryString.isEmpty())) {
queryString = URLEncoder.encode(queryString, "UTF-8");
queryString = UriUtils.encodeQuery(queryString, "UTF-8");
}
if ((queryString != null) && (!queryString.isEmpty())) {
......
......@@ -150,12 +150,12 @@ public class ActiveServerFilterTest {
when(activeInstanceState.getActiveServerAddress()).thenReturn(ACTIVE_SERVER_ADDRESS);
when(servletRequest.getMethod()).thenReturn(HttpMethod.GET);
when(servletRequest.getRequestURI()).thenReturn("api/atlas/v2/search/basic");
when(servletRequest.getQueryString()).thenReturn("limit=25&excludeDeletedEntities=true&classification=ETL&_=1500969656054");
when(servletRequest.getQueryString()).thenReturn("limit=25&excludeDeletedEntities=true&spaceParam=firstpart secondpart&_=1500969656054&listParam=value1,value2");
activeServerFilter.doFilter(servletRequest, servletResponse, filterChain);
verify(servletResponse).sendRedirect(ACTIVE_SERVER_ADDRESS +
"api/atlas/v2/search/basic?limit%3D25%26excludeDeletedEntities%3Dtrue%26classification%3DETL%26_%3D1500969656054");
"api/atlas/v2/search/basic?limit=25&excludeDeletedEntities=true&spaceParam=firstpart%20secondpart&_=1500969656054&listParam=value1,value2");
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment